Skip to content

Commit

Permalink
verkle: adjust util tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrocheleau committed Jul 16, 2024
1 parent d787f40 commit c8dca62
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/util/test/verkle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ describe('Verkle cryptographic helpers', () => {
const prestateRoot = hexToBytes(
'0x64e1a647f42e5c2e3c434531ccf529e1b3e93363a40db9fc8eec81f492123510'
)
const executionWitness = verkleBlockJSON.executionWitness as VerkleExecutionWitness
assert.isTrue(verifyVerkleProof(verkle, prestateRoot, executionWitness))
const executionWitness = {
...verkleBlockJSON.default.executionWitness,
parentStateRoot: bytesToHex(prestateRoot),
} as VerkleExecutionWitness
assert.isTrue(verifyVerkleProof(verkle, executionWitness))
})

it('verifyVerkleProof(): should return false for invalid verkle proofs', () => {
// Random preStateRoot
const prestateRoot = randomBytes(32)
const executionWitness = verkleBlockJSON.executionWitness as VerkleExecutionWitness
const executionWitness = {
...verkleBlockJSON.default.executionWitness,
parentStateRoot: bytesToHex(prestateRoot),
} as VerkleExecutionWitness
// Modify the proof to make it invalid
assert.isFalse(verifyVerkleProof(verkle, prestateRoot, executionWitness))
assert.isFalse(verifyVerkleProof(verkle, executionWitness))
})
})

describe('should generate valid tree keys', () => {
it('should generate valid keys for each VerkleLeafType', () => {
const stem = hexToBytes('0x318dea512b6f3237a2d4763cf49bf26de3b617fb0cabe38a97807a5549df4d')
for (const leaf of [
VerkleLeafType.Version,
VerkleLeafType.Balance,
VerkleLeafType.Nonce,
VerkleLeafType.CodeHash,
VerkleLeafType.CodeSize,
]) {
for (const leaf of [VerkleLeafType.BasicData, VerkleLeafType.CodeHash]) {
const key = getVerkleKey(stem, leaf)
assert.equal(key.length, 32)
assert.deepEqual(key, concatBytes(stem, intToBytes(leaf)))
Expand Down

0 comments on commit c8dca62

Please sign in to comment.