@@ -29,27 +29,19 @@ describe('standard merkle tree', () => {
29
29
30
30
assert ( t . verify ( id , proof1 ) ) ;
31
31
assert ( t . verify ( leaf , proof1 ) ) ;
32
+ assert ( StandardMerkleTree . verify ( t . root , [ 'string' ] , leaf , proof1 ) ) ;
32
33
}
33
34
} ) ;
34
35
35
- it ( 'generates valid single proofs for all leaves from root and encoding ' , ( ) => {
36
+ it ( 'rejects invalid proofs' , ( ) => {
36
37
const { t } = characters ( 'abcdef' ) ;
38
+ const { t : otherTree } = characters ( 'abc' ) ;
37
39
38
- for ( const [ , leaf ] of t . entries ( ) ) {
39
- const proof = t . getProof ( leaf ) ;
40
+ const leaf = [ 'a' ] ;
41
+ const invalidProof = otherTree . getProof ( leaf ) ;
40
42
41
- assert ( StandardMerkleTree . verify ( t . root , [ 'string' ] , leaf , proof ) ) ;
42
- }
43
- } ) ;
44
-
45
- it ( 'rejects invalid proof using static verify method' , ( ) => {
46
- const { t } = characters ( 'abcdef' ) ;
47
- const { t : fakeTree } = characters ( 'xyz' ) ;
48
-
49
- const testLeaf = [ 'x' ] ;
50
- const proof = fakeTree . getProof ( testLeaf ) ;
51
-
52
- assert ( ! StandardMerkleTree . verify ( t . root , [ 'string' ] , testLeaf , proof ) ) ;
43
+ assert ( ! t . verify ( leaf , invalidProof ) ) ;
44
+ assert ( ! StandardMerkleTree . verify ( t . root , [ 'string' ] , leaf , invalidProof ) ) ;
53
45
} ) ;
54
46
55
47
it ( 'generates valid multiproofs' , ( ) => {
@@ -62,38 +54,19 @@ describe('standard merkle tree', () => {
62
54
assert . deepEqual ( proof1 , proof2 ) ;
63
55
64
56
assert ( t . verifyMultiProof ( proof1 ) ) ;
57
+ assert ( StandardMerkleTree . verifyMultiProof ( t . root , [ 'string' ] , proof1 ) ) ;
65
58
}
66
59
} ) ;
67
60
68
- it ( 'generates valid multi-proofs for all leaves from root and encoding ' , ( ) => {
61
+ it ( 'rejects invalid multiproofs ' , ( ) => {
69
62
const { t } = characters ( 'abcdef' ) ;
70
- const leaves = Array . from ( t . entries ( ) ) . map ( ( [ _ , leaf ] ) => leaf ) ;
71
-
72
- const multiproof = t . getMultiProof ( leaves ) ;
73
-
74
- assert ( StandardMerkleTree . verifyMultiProof ( t . root , [ 'string' ] , multiproof ) ) ;
75
- } ) ;
76
-
77
- it ( 'rejects invalid multi-proof using static verifyMultiProof method' , ( ) => {
78
- const { t } = characters ( 'abcdef' ) ;
79
- const { t : fakeTree } = characters ( 'xyz' ) ;
80
-
81
- const fakeLeaves = Array . from ( fakeTree . entries ( ) ) . map ( ( [ _ , leaf ] ) => leaf ) ;
82
- const fakeMultiProof = fakeTree . getMultiProof ( fakeLeaves ) ;
83
-
84
- assert ( ! StandardMerkleTree . verifyMultiProof ( t . root , [ 'string' ] , fakeMultiProof ) ) ;
85
- } ) ;
86
-
87
- it ( 'verifies partial multi-proof using static verifyMultiProof method' , ( ) => {
88
- const { t } = characters ( 'abcdef' ) ;
89
-
90
- const leaves = Array . from ( t . entries ( ) )
91
- . filter ( ( [ index ] ) => index % 2 === 0 )
92
- . map ( ( [ _ , leaf ] ) => leaf ) ;
63
+ const { t : otherTree } = characters ( 'abc' ) ;
93
64
94
- const multiproof = t . getMultiProof ( leaves ) ;
65
+ const leaves = [ [ 'a' ] , [ 'b' ] , [ 'c' ] ] ;
66
+ const multiProof = otherTree . getMultiProof ( leaves ) ;
95
67
96
- assert ( StandardMerkleTree . verifyMultiProof ( t . root , [ 'string' ] , multiproof ) ) ;
68
+ assert ( ! t . verifyMultiProof ( multiProof ) ) ;
69
+ assert ( ! StandardMerkleTree . verifyMultiProof ( t . root , [ 'string' ] , multiProof ) ) ;
97
70
} ) ;
98
71
99
72
it ( 'renders tree representation' , ( ) => {
0 commit comments