@@ -23,11 +23,9 @@ func TestExistenceProof(t *testing.T) {
23
23
proof : & ExistenceProof {
24
24
Key : []byte ("food" ),
25
25
Value : []byte ("some longer text" ),
26
- Steps : []* ProofOp {
27
- WrapLeaf (& LeafOp {
28
- Hash : HashOp_SHA256 ,
29
- Length : LengthOp_VAR_PROTO ,
30
- }),
26
+ Leaf : & LeafOp {
27
+ Hash : HashOp_SHA256 ,
28
+ Length : LengthOp_VAR_PROTO ,
31
29
},
32
30
},
33
31
expected : fromHex ("b68f5d298e915ae1753dd333da1f9cf605411a5f2e12516be6758f365e6db265" ),
@@ -38,10 +36,8 @@ func TestExistenceProof(t *testing.T) {
38
36
proof : & ExistenceProof {
39
37
Key : append ([]byte {4 }, []byte ("food" )... ),
40
38
Value : append ([]byte {16 }, []byte ("some longer text" )... ),
41
- Steps : []* ProofOp {
42
- WrapLeaf (& LeafOp {
43
- Hash : HashOp_SHA256 ,
44
- }),
39
+ Leaf : & LeafOp {
40
+ Hash : HashOp_SHA256 ,
45
41
},
46
42
},
47
43
expected : fromHex ("b68f5d298e915ae1753dd333da1f9cf605411a5f2e12516be6758f365e6db265" ),
@@ -50,59 +46,40 @@ func TestExistenceProof(t *testing.T) {
50
46
proof : & ExistenceProof {
51
47
Key : append ([]byte ("od" ), byte (16 )),
52
48
Value : []byte ("some longer text" ),
53
- Steps : []* ProofOp {
54
- WrapLeaf (& LeafOp {
55
- Prefix : []byte {4 , 'f' , 'o' },
56
- Hash : HashOp_SHA256 ,
57
- }),
49
+ Leaf : & LeafOp {
50
+ Prefix : []byte {4 , 'f' , 'o' },
51
+ Hash : HashOp_SHA256 ,
58
52
},
59
53
},
60
54
expected : fromHex ("b68f5d298e915ae1753dd333da1f9cf605411a5f2e12516be6758f365e6db265" ),
61
55
},
62
- "cannot execute two leafs" : {
63
- proof : & ExistenceProof {
64
- Key : []byte ("food" ),
65
- Value : []byte ("some longer text" ),
66
- Steps : []* ProofOp {
67
- WrapLeaf (& LeafOp {
68
- Hash : HashOp_SHA256 ,
69
- Length : LengthOp_VAR_PROTO ,
70
- }),
71
- WrapLeaf (& LeafOp {
72
- Hash : HashOp_SHA256 ,
73
- Length : LengthOp_VAR_PROTO ,
74
- }),
75
- },
76
- },
77
- isErr : true ,
78
- },
79
56
"cannot execute inner first" : {
80
57
proof : & ExistenceProof {
81
58
Key : []byte ("food" ),
82
59
Value : []byte ("some longer text" ),
83
- Steps : []* ProofOp {
84
- WrapInner ( & InnerOp {
60
+ Path : []* InnerOp {
61
+ & InnerOp {
85
62
Hash : HashOp_SHA256 ,
86
63
Prefix : fromHex ("deadbeef00cafe00" ),
87
- }) ,
64
+ },
88
65
},
89
66
},
90
67
isErr : true ,
91
68
},
92
- "executes lead then inner op" : {
69
+ "executes leaf then inner op" : {
93
70
proof : & ExistenceProof {
94
71
Key : []byte ("food" ),
95
72
Value : []byte ("some longer text" ),
96
- Steps : [] * ProofOp {
97
- WrapLeaf ( & LeafOp {
98
- Hash : HashOp_SHA256 ,
99
- Length : LengthOp_VAR_PROTO ,
100
- }),
101
- // output: b68f5d298e915ae1753dd333da1f9cf605411a5f2e12516be6758f365e6db265
102
- WrapInner ( & InnerOp {
73
+ Leaf : & LeafOp {
74
+ Hash : HashOp_SHA256 ,
75
+ Length : LengthOp_VAR_PROTO ,
76
+ } ,
77
+ // output: b68f5d298e915ae1753dd333da1f9cf605411a5f2e12516be6758f365e6db265
78
+ Path : [] * InnerOp {
79
+ & InnerOp {
103
80
Hash : HashOp_SHA256 ,
104
81
Prefix : fromHex ("deadbeef00cafe00" ),
105
- }) ,
82
+ },
106
83
// echo -n deadbeef00cafe00b68f5d298e915ae1753dd333da1f9cf605411a5f2e12516be6758f365e6db265 | xxd -r -p | sha256sum
107
84
},
108
85
},
@@ -259,13 +236,13 @@ func TestCheckLeaf(t *testing.T) {
259
236
}
260
237
261
238
func TestCheckAgainstSpec (t * testing.T ) {
262
- validInner := WrapInner ( & InnerOp {
239
+ validInner := & InnerOp {
263
240
Prefix : fromHex ("aa" ),
264
- })
265
- invalidInner := WrapInner ( & InnerOp {
241
+ }
242
+ invalidInner := & InnerOp {
266
243
Prefix : fromHex ("00aa" ),
267
244
Suffix : fromHex ("bb" ),
268
- })
245
+ }
269
246
270
247
cases := map [string ]struct {
271
248
proof * ExistenceProof
@@ -284,22 +261,18 @@ func TestCheckAgainstSpec(t *testing.T) {
284
261
proof : & ExistenceProof {
285
262
Key : []byte ("food" ),
286
263
Value : []byte ("bar" ),
287
- Steps : []* ProofOp {
288
- WrapLeaf (IavlSpec .LeafSpec ),
289
- },
264
+ Leaf : IavlSpec .LeafSpec ,
290
265
},
291
266
spec : IavlSpec ,
292
267
},
293
268
"rejects invalid leaf" : {
294
269
proof : & ExistenceProof {
295
270
Key : []byte ("food" ),
296
271
Value : []byte ("bar" ),
297
- Steps : []* ProofOp {
298
- WrapLeaf (& LeafOp {
299
- Prefix : []byte {0 },
300
- Hash : HashOp_SHA256 ,
301
- Length : LengthOp_VAR_PROTO ,
302
- }),
272
+ Leaf : & LeafOp {
273
+ Prefix : []byte {0 },
274
+ Hash : HashOp_SHA256 ,
275
+ Length : LengthOp_VAR_PROTO ,
303
276
},
304
277
},
305
278
spec : IavlSpec ,
@@ -309,7 +282,7 @@ func TestCheckAgainstSpec(t *testing.T) {
309
282
proof : & ExistenceProof {
310
283
Key : []byte ("food" ),
311
284
Value : []byte ("bar" ),
312
- Steps : []* ProofOp {
285
+ Path : []* InnerOp {
313
286
validInner ,
314
287
},
315
288
},
@@ -320,8 +293,8 @@ func TestCheckAgainstSpec(t *testing.T) {
320
293
proof : & ExistenceProof {
321
294
Key : []byte ("food" ),
322
295
Value : []byte ("bar" ),
323
- Steps : [] * ProofOp {
324
- WrapLeaf ( IavlSpec . LeafSpec ),
296
+ Leaf : IavlSpec . LeafSpec ,
297
+ Path : [] * InnerOp {
325
298
validInner ,
326
299
validInner ,
327
300
},
@@ -332,8 +305,8 @@ func TestCheckAgainstSpec(t *testing.T) {
332
305
proof : & ExistenceProof {
333
306
Key : []byte ("food" ),
334
307
Value : []byte ("bar" ),
335
- Steps : [] * ProofOp {
336
- WrapLeaf ( IavlSpec . LeafSpec ),
308
+ Leaf : IavlSpec . LeafSpec ,
309
+ Path : [] * InnerOp {
337
310
validInner ,
338
311
invalidInner ,
339
312
validInner ,
0 commit comments