@@ -57,8 +57,8 @@ func Test_NewTrie(t *testing.T) {
57
57
func Test_Trie_Snapshot (t * testing.T ) {
58
58
t .Parallel ()
59
59
60
- emptyDeltas := newDeltas (nil )
61
- setDeltas := newDeltas ([]common. Hash {{ 1 }} )
60
+ emptyDeltas := newDeltas ()
61
+ setDeltas := newDeltas ("0x01" )
62
62
63
63
trie := & Trie {
64
64
generation : 8 ,
@@ -113,34 +113,34 @@ func Test_Trie_handleTrackedDeltas(t *testing.T) {
113
113
"no success and generation 1" : {
114
114
trie : Trie {
115
115
generation : 1 ,
116
- deltas : newDeltas ([]common. Hash {{ 1 }} ),
116
+ deltas : newDeltas ("0x01" ),
117
117
},
118
- pendingDeltas : newDeltas ([]common. Hash {{ 2 }} ),
118
+ pendingDeltas : newDeltas ("0x02" ),
119
119
expectedTrie : Trie {
120
120
generation : 1 ,
121
- deltas : newDeltas ([]common. Hash {{ 1 }} ),
121
+ deltas : newDeltas ("0x01" ),
122
122
},
123
123
},
124
124
"success and generation 0" : {
125
125
trie : Trie {
126
- deltas : newDeltas ([]common. Hash {{ 1 }} ),
126
+ deltas : newDeltas ("0x01" ),
127
127
},
128
128
success : true ,
129
- pendingDeltas : newDeltas ([]common. Hash {{ 2 }} ),
129
+ pendingDeltas : newDeltas ("0x02" ),
130
130
expectedTrie : Trie {
131
- deltas : newDeltas ([]common. Hash {{ 1 }} ),
131
+ deltas : newDeltas ("0x01" ),
132
132
},
133
133
},
134
134
"success and generation 1" : {
135
135
trie : Trie {
136
136
generation : 1 ,
137
- deltas : newDeltas ([]common. Hash {{ 1 }} ),
137
+ deltas : newDeltas ("0x01" ),
138
138
},
139
139
success : true ,
140
- pendingDeltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
140
+ pendingDeltas : newDeltas ("0x01" , "0x02" ),
141
141
expectedTrie : Trie {
142
142
generation : 1 ,
143
- deltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
143
+ deltas : newDeltas ("0x01" , "0x02" ),
144
144
},
145
145
},
146
146
}
@@ -207,7 +207,7 @@ func Test_Trie_prepForMutation(t *testing.T) {
207
207
trie : Trie {
208
208
generation : 2 ,
209
209
},
210
- pendingDeltas : newDeltas (nil ),
210
+ pendingDeltas : newDeltas (),
211
211
currentNode : & Node {
212
212
Generation : 1 ,
213
213
PartialKey : []byte {1 },
@@ -228,11 +228,8 @@ func Test_Trie_prepForMutation(t *testing.T) {
228
228
25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 },
229
229
Dirty : true ,
230
230
},
231
- copied : true ,
232
- expectedPendingDeltas : newDeltas ([]common.Hash {{
233
- 0x98 , 0xfc , 0xd6 , 0x6b , 0xa3 , 0x12 , 0xc2 , 0x9e , 0xf1 , 0x93 , 0x5 , 0x2f , 0xd0 , 0xc1 , 0x4c , 0x6e ,
234
- 0x38 , 0xb1 , 0x58 , 0xbd , 0x5c , 0x2 , 0x35 , 0x6 , 0x45 , 0x94 , 0xca , 0xcc , 0x1a , 0xb5 , 0x96 , 0x5d ,
235
- }}),
231
+ copied : true ,
232
+ expectedPendingDeltas : newDeltas ("0x98fcd66ba312c29ef193052fd0c14c6e38b158bd5c0235064594cacc1ab5965d" ),
236
233
},
237
234
}
238
235
@@ -287,15 +284,10 @@ func Test_Trie_registerDeletedMerkleValue(t *testing.T) {
287
284
node : & Node {Dirty : true },
288
285
},
289
286
"clean root node registered" : {
290
- node : someSmallNode ,
291
- trie : Trie {root : someSmallNode },
292
- pendingDeltas : newDeltas (nil ),
293
- expectedPendingDeltas : newDeltas ([]common.Hash {{
294
- 0x60 , 0x51 , 0x6d , 0x0b , 0xb6 , 0xe1 , 0xbb , 0xfb ,
295
- 0x12 , 0x93 , 0xf1 , 0xb2 , 0x76 , 0xea , 0x95 , 0x05 ,
296
- 0xe9 , 0xf4 , 0xa4 , 0xe7 , 0xd9 , 0x8f , 0x62 , 0x0d ,
297
- 0x05 , 0x11 , 0x5e , 0x0b , 0x85 , 0x27 , 0x4a , 0xe1 ,
298
- }}),
287
+ node : someSmallNode ,
288
+ trie : Trie {root : someSmallNode },
289
+ pendingDeltas : newDeltas (),
290
+ expectedPendingDeltas : newDeltas ("0x60516d0bb6e1bbfb1293f1b276ea9505e9f4a4e7d98f620d05115e0b85274ae1" ),
299
291
expectedTrie : Trie {
300
292
root : & Node {
301
293
PartialKey : []byte {1 },
@@ -323,11 +315,8 @@ func Test_Trie_registerDeletedMerkleValue(t *testing.T) {
323
315
17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 ,
324
316
25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 },
325
317
},
326
- pendingDeltas : newDeltas (nil ),
327
- expectedPendingDeltas : newDeltas ([]common.Hash {{
328
- 0x98 , 0xfc , 0xd6 , 0x6b , 0xa3 , 0x12 , 0xc2 , 0x9e , 0xf1 , 0x93 , 0x5 , 0x2f , 0xd0 , 0xc1 , 0x4c , 0x6e ,
329
- 0x38 , 0xb1 , 0x58 , 0xbd , 0x5c , 0x2 , 0x35 , 0x6 , 0x45 , 0x94 , 0xca , 0xcc , 0x1a , 0xb5 , 0x96 , 0x5d ,
330
- }}),
318
+ pendingDeltas : newDeltas (),
319
+ expectedPendingDeltas : newDeltas ("0x98fcd66ba312c29ef193052fd0c14c6e38b158bd5c0235064594cacc1ab5965d" ),
331
320
},
332
321
}
333
322
@@ -410,10 +399,10 @@ func Test_Trie_DeepCopy(t *testing.T) {
410
399
{1 , 2 , 3 }: {
411
400
generation : 2 ,
412
401
root : & Node {PartialKey : []byte {1 }, StorageValue : []byte {1 }},
413
- deltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
402
+ deltas : newDeltas ("0x01" , "0x02" ),
414
403
},
415
404
},
416
- deltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
405
+ deltas : newDeltas ("0x01" , "0x02" ),
417
406
},
418
407
trieCopy : & Trie {
419
408
generation : 1 ,
@@ -422,10 +411,10 @@ func Test_Trie_DeepCopy(t *testing.T) {
422
411
{1 , 2 , 3 }: {
423
412
generation : 2 ,
424
413
root : & Node {PartialKey : []byte {1 }, StorageValue : []byte {1 }},
425
- deltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
414
+ deltas : newDeltas ("0x01" , "0x02" ),
426
415
},
427
416
},
428
- deltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
417
+ deltas : newDeltas ("0x01" , "0x02" ),
429
418
},
430
419
},
431
420
}
@@ -1069,7 +1058,7 @@ func Test_Trie_Put(t *testing.T) {
1069
1058
"trie with key and value" : {
1070
1059
trie : Trie {
1071
1060
generation : 1 ,
1072
- deltas : newDeltas (nil ),
1061
+ deltas : newDeltas (),
1073
1062
root : & Node {
1074
1063
PartialKey : []byte {1 , 2 , 0 , 5 },
1075
1064
StorageValue : []byte {1 },
@@ -1079,12 +1068,7 @@ func Test_Trie_Put(t *testing.T) {
1079
1068
value : []byte {2 },
1080
1069
expectedTrie : Trie {
1081
1070
generation : 1 ,
1082
- deltas : newDeltas ([]common.Hash {
1083
- {
1084
- 0xa1 , 0x95 , 0x08 , 0x9c , 0x3e , 0x8f , 0x8b , 0x5b , 0x36 , 0x97 , 0x87 , 0x00 , 0xad , 0x95 , 0x4a , 0xed ,
1085
- 0x99 , 0xe0 , 0x84 , 0x13 , 0xcf , 0xc1 , 0xe2 , 0xb4 , 0xc0 , 0x0a , 0x5d , 0x06 , 0x4a , 0xbe , 0x66 , 0xa9 ,
1086
- },
1087
- }),
1071
+ deltas : newDeltas ("0xa195089c3e8f8b5b36978700ad954aed99e08413cfc1e2b4c00a5d064abe66a9" ),
1088
1072
root : & Node {
1089
1073
PartialKey : []byte {1 , 2 },
1090
1074
Generation : 1 ,
@@ -1669,14 +1653,14 @@ func Test_LoadFromMap(t *testing.T) {
1669
1653
"nil data" : {
1670
1654
expectedTrie : Trie {
1671
1655
childTries : map [common.Hash ]* Trie {},
1672
- deltas : newDeltas (nil ),
1656
+ deltas : newDeltas (),
1673
1657
},
1674
1658
},
1675
1659
"empty data" : {
1676
1660
data : map [string ]string {},
1677
1661
expectedTrie : Trie {
1678
1662
childTries : map [common.Hash ]* Trie {},
1679
- deltas : newDeltas (nil ),
1663
+ deltas : newDeltas (),
1680
1664
},
1681
1665
},
1682
1666
"bad key" : {
@@ -1709,7 +1693,7 @@ func Test_LoadFromMap(t *testing.T) {
1709
1693
Dirty : true ,
1710
1694
},
1711
1695
childTries : map [common.Hash ]* Trie {},
1712
- deltas : newDeltas (nil ),
1696
+ deltas : newDeltas (),
1713
1697
},
1714
1698
},
1715
1699
"load key values" : {
@@ -1739,7 +1723,7 @@ func Test_LoadFromMap(t *testing.T) {
1739
1723
}),
1740
1724
},
1741
1725
childTries : map [common.Hash ]* Trie {},
1742
- deltas : newDeltas (nil ),
1726
+ deltas : newDeltas (),
1743
1727
},
1744
1728
},
1745
1729
}
@@ -3004,29 +2988,23 @@ func Test_Trie_ClearPrefix(t *testing.T) {
3004
2988
trie : Trie {
3005
2989
root : & Node {StorageValue : []byte {1 }},
3006
2990
generation : 1 ,
3007
- deltas : newDeltas (nil ),
2991
+ deltas : newDeltas (),
3008
2992
},
3009
2993
expectedTrie : Trie {
3010
2994
generation : 1 ,
3011
- deltas : newDeltas ([]common.Hash {{
3012
- 0xf9 , 0x6a , 0x74 , 0x15 , 0x22 , 0xbc , 0xc1 , 0x4f , 0x0a , 0xea , 0x2f , 0x70 , 0x60 , 0x44 , 0x52 , 0x24 ,
3013
- 0x1d , 0x59 , 0xb5 , 0xf2 , 0xdd , 0xab , 0x9a , 0x69 , 0x48 , 0xfd , 0xb3 , 0xfe , 0xf5 , 0xf9 , 0x86 , 0x43 ,
3014
- }}),
2995
+ deltas : newDeltas ("0xf96a741522bcc14f0aea2f70604452241d59b5f2ddab9a6948fdb3fef5f98643" ),
3015
2996
},
3016
2997
},
3017
2998
"empty prefix" : {
3018
2999
trie : Trie {
3019
3000
root : & Node {StorageValue : []byte {1 }},
3020
3001
generation : 1 ,
3021
- deltas : newDeltas (nil ),
3002
+ deltas : newDeltas (),
3022
3003
},
3023
3004
prefix : []byte {},
3024
3005
expectedTrie : Trie {
3025
3006
generation : 1 ,
3026
- deltas : newDeltas ([]common.Hash {{
3027
- 0xf9 , 0x6a , 0x74 , 0x15 , 0x22 , 0xbc , 0xc1 , 0x4f , 0x0a , 0xea , 0x2f , 0x70 , 0x60 , 0x44 , 0x52 , 0x24 ,
3028
- 0x1d , 0x59 , 0xb5 , 0xf2 , 0xdd , 0xab , 0x9a , 0x69 , 0x48 , 0xfd , 0xb3 , 0xfe , 0xf5 , 0xf9 , 0x86 , 0x43 ,
3029
- }}),
3007
+ deltas : newDeltas ("0xf96a741522bcc14f0aea2f70604452241d59b5f2ddab9a6948fdb3fef5f98643" ),
3030
3008
},
3031
3009
},
3032
3010
"empty trie" : {
@@ -3055,7 +3033,7 @@ func Test_Trie_ClearPrefix(t *testing.T) {
3055
3033
},
3056
3034
}),
3057
3035
},
3058
- deltas : newDeltas (nil ),
3036
+ deltas : newDeltas (),
3059
3037
},
3060
3038
prefix : []byte {0x12 , 0x16 },
3061
3039
expectedTrie : Trie {
@@ -3066,10 +3044,7 @@ func Test_Trie_ClearPrefix(t *testing.T) {
3066
3044
Generation : 1 ,
3067
3045
Dirty : true ,
3068
3046
},
3069
- deltas : newDeltas ([]common.Hash {{
3070
- 0x5f , 0xe1 , 0x08 , 0xc8 , 0x3d , 0x08 , 0x32 , 0x93 , 0x53 , 0xd6 , 0x91 , 0x8e , 0x01 , 0x04 , 0xda , 0xcc ,
3071
- 0x9d , 0x21 , 0x87 , 0xfd , 0x9d , 0xaf , 0xa5 , 0x82 , 0xd1 , 0xc5 , 0x32 , 0xe5 , 0xfe , 0x7b , 0x2e , 0x50 ,
3072
- }}),
3047
+ deltas : newDeltas ("0x5fe108c83d08329353d6918e0104dacc9d2187fd9dafa582d1c532e5fe7b2e50" ),
3073
3048
},
3074
3049
},
3075
3050
}
@@ -3439,28 +3414,22 @@ func Test_Trie_Delete(t *testing.T) {
3439
3414
trie : Trie {
3440
3415
root : & Node {StorageValue : []byte {1 }},
3441
3416
generation : 1 ,
3442
- deltas : newDeltas (nil ),
3417
+ deltas : newDeltas (),
3443
3418
},
3444
3419
expectedTrie : Trie {
3445
3420
generation : 1 ,
3446
- deltas : newDeltas ([]common.Hash {{
3447
- 0xf9 , 0x6a , 0x74 , 0x15 , 0x22 , 0xbc , 0xc1 , 0x4f , 0x0a , 0xea , 0x2f , 0x70 , 0x60 , 0x44 , 0x52 , 0x24 ,
3448
- 0x1d , 0x59 , 0xb5 , 0xf2 , 0xdd , 0xab , 0x9a , 0x69 , 0x48 , 0xfd , 0xb3 , 0xfe , 0xf5 , 0xf9 , 0x86 , 0x43 ,
3449
- }}),
3421
+ deltas : newDeltas ("0xf96a741522bcc14f0aea2f70604452241d59b5f2ddab9a6948fdb3fef5f98643" ),
3450
3422
},
3451
3423
},
3452
3424
"empty key" : {
3453
3425
trie : Trie {
3454
3426
root : & Node {StorageValue : []byte {1 }},
3455
3427
generation : 1 ,
3456
- deltas : newDeltas (nil ),
3428
+ deltas : newDeltas (),
3457
3429
},
3458
3430
expectedTrie : Trie {
3459
3431
generation : 1 ,
3460
- deltas : newDeltas ([]common.Hash {{
3461
- 0xf9 , 0x6a , 0x74 , 0x15 , 0x22 , 0xbc , 0xc1 , 0x4f , 0x0a , 0xea , 0x2f , 0x70 , 0x60 , 0x44 , 0x52 , 0x24 ,
3462
- 0x1d , 0x59 , 0xb5 , 0xf2 , 0xdd , 0xab , 0x9a , 0x69 , 0x48 , 0xfd , 0xb3 , 0xfe , 0xf5 , 0xf9 , 0x86 , 0x43 ,
3463
- }}),
3432
+ deltas : newDeltas ("0xf96a741522bcc14f0aea2f70604452241d59b5f2ddab9a6948fdb3fef5f98643" ),
3464
3433
},
3465
3434
},
3466
3435
"empty trie" : {
@@ -3490,7 +3459,7 @@ func Test_Trie_Delete(t *testing.T) {
3490
3459
},
3491
3460
}),
3492
3461
},
3493
- deltas : newDeltas (nil ),
3462
+ deltas : newDeltas (),
3494
3463
},
3495
3464
key : []byte {0x12 , 0x16 },
3496
3465
expectedTrie : Trie {
@@ -3514,10 +3483,7 @@ func Test_Trie_Delete(t *testing.T) {
3514
3483
},
3515
3484
}),
3516
3485
},
3517
- deltas : newDeltas ([]common.Hash {{
3518
- 0x3d , 0x1b , 0x3d , 0x72 , 0x7e , 0xe4 , 0x04 , 0x54 , 0x9a , 0x5d , 0x25 , 0x31 , 0xaa , 0xb9 , 0xff , 0xf0 ,
3519
- 0xee , 0xdd , 0xc5 , 0x8b , 0xc3 , 0x0b , 0xfe , 0x2f , 0xe8 , 0x2b , 0x1a , 0x0c , 0xfe , 0x7e , 0x76 , 0xd5 ,
3520
- }}),
3486
+ deltas : newDeltas ("0x3d1b3d727ee404549a5d2531aab9fff0eeddc58bc30bfe2fe82b1a0cfe7e76d5" ),
3521
3487
},
3522
3488
},
3523
3489
}
0 commit comments