@@ -5,7 +5,7 @@ import { Poseidon2, SparseMerkleProof } from "../../../typechain-types";
55import merkleProofTestData from "../_testData/merkle-proof-data-poseidon2.json" ;
66import { deployFromFactory } from "../common/deployment" ;
77import { expectRevertWithCustomError } from "../common/helpers" ;
8- import { dataSlice , zeroPadBytes } from "ethers" ;
8+ import { dataSlice } from "ethers" ;
99
1010describe ( "SparseMerkleProof" , ( ) => {
1111 let sparseMerkleProof : SparseMerkleProof ;
@@ -325,24 +325,19 @@ describe("SparseMerkleProof", () => {
325325 } ) ;
326326 } ) ;
327327
328- describe ( "hashKey " , ( ) => {
328+ describe ( "hashAccountKey " , ( ) => {
329329 it ( "Should return account key hash" , async ( ) => {
330330 const {
331331 accountProof : { key } ,
332332 } = merkleProofTestData ;
333333
334- const rightPaddedKey = zeroPadBytes ( key , 32 ) ;
335- const hKey = await sparseMerkleProof . hashKey ( rightPaddedKey ) ;
334+ const hKey = await sparseMerkleProof . hashAccountKey ( key ) ;
336335 expect ( hKey ) . to . be . equal ( ACCOUNT_KEY_HASH ) ;
337336 } ) ;
338337
339- it ( "Should return storage key hash" , async ( ) => {
340- const {
341- storageProofs : [ { key } ] ,
342- } = merkleProofTestData ;
343-
344- const hKey = await sparseMerkleProof . hashKey ( key ) ;
345- expect ( hKey ) . to . be . equal ( STORAGE_KEY_HASH ) ;
338+ it ( "Should return account key hash for addresses with non zero 14-19 bytes" , async ( ) => {
339+ const hKey = await sparseMerkleProof . hashAccountKey ( "0x67feaf59f9a311707d935dda2f10a9c577398e34" ) ;
340+ expect ( hKey ) . to . be . equal ( "0x3bc7a71c1f207312790ba36858f144e630cd7cb0703a0d3569a128a923bbfb35" ) ;
346341 } ) ;
347342 } ) ;
348343
@@ -385,7 +380,7 @@ describe("SparseMerkleProof", () => {
385380 } = merkleProofTestData ;
386381
387382 const leaf = await sparseMerkleProof . getLeaf ( proofRelatedNodes [ proofRelatedNodes . length - 1 ] ) ;
388- const expectedHKey = await sparseMerkleProof . hashKey ( zeroPadBytes ( key , 32 ) ) ;
383+ const expectedHKey = await sparseMerkleProof . hashAccountKey ( key ) ;
389384 const expectedHValue = await sparseMerkleProof . hashAccountValue ( value ) ;
390385
391386 expect ( leaf . prev [ 0 ] ) . to . be . equal ( 0n ) ;
@@ -427,7 +422,7 @@ describe("SparseMerkleProof", () => {
427422 } = merkleProofTestData ;
428423
429424 const leaf = await sparseMerkleProof . getLeaf ( proofRelatedNodes [ proofRelatedNodes . length - 1 ] ) ;
430- const expectedHKey = await sparseMerkleProof . hashKey ( zeroPadBytes ( key , 32 ) ) ;
425+ const expectedHKey = await sparseMerkleProof . hashStorageValue ( key ) ;
431426 const expectedHValue = await sparseMerkleProof . hashStorageValue ( value ) ;
432427
433428 expect ( leaf . prev [ 0 ] ) . to . be . equal ( 0n ) ;
0 commit comments