@@ -46,8 +46,8 @@ func Test_NewTrie(t *testing.T) {
46
46
func Test_Trie_Snapshot (t * testing.T ) {
47
47
t .Parallel ()
48
48
49
- emptyDeltas := newDeltas (nil )
50
- setDeltas := newDeltas ([]common. Hash {{ 1 }} )
49
+ emptyDeltas := newDeltas ()
50
+ setDeltas := newDeltas ("0x01" )
51
51
52
52
trie := & Trie {
53
53
generation : 8 ,
@@ -102,34 +102,34 @@ func Test_Trie_handleTrackedDeltas(t *testing.T) {
102
102
"no success and generation 1" : {
103
103
trie : Trie {
104
104
generation : 1 ,
105
- deltas : newDeltas ([]common. Hash {{ 1 }} ),
105
+ deltas : newDeltas ("0x01" ),
106
106
},
107
- pendingDeltas : newDeltas ([]common. Hash {{ 2 }} ),
107
+ pendingDeltas : newDeltas ("0x02" ),
108
108
expectedTrie : Trie {
109
109
generation : 1 ,
110
- deltas : newDeltas ([]common. Hash {{ 1 }} ),
110
+ deltas : newDeltas ("0x01" ),
111
111
},
112
112
},
113
113
"success and generation 0" : {
114
114
trie : Trie {
115
- deltas : newDeltas ([]common. Hash {{ 1 }} ),
115
+ deltas : newDeltas ("0x01" ),
116
116
},
117
117
success : true ,
118
- pendingDeltas : newDeltas ([]common. Hash {{ 2 }} ),
118
+ pendingDeltas : newDeltas ("0x02" ),
119
119
expectedTrie : Trie {
120
- deltas : newDeltas ([]common. Hash {{ 1 }} ),
120
+ deltas : newDeltas ("0x01" ),
121
121
},
122
122
},
123
123
"success and generation 1" : {
124
124
trie : Trie {
125
125
generation : 1 ,
126
- deltas : newDeltas ([]common. Hash {{ 1 }} ),
126
+ deltas : newDeltas ("0x01" ),
127
127
},
128
128
success : true ,
129
- pendingDeltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
129
+ pendingDeltas : newDeltas ("0x01" , "0x02" ),
130
130
expectedTrie : Trie {
131
131
generation : 1 ,
132
- deltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
132
+ deltas : newDeltas ("0x01" , "0x02" ),
133
133
},
134
134
},
135
135
}
@@ -196,7 +196,7 @@ func Test_Trie_prepForMutation(t *testing.T) {
196
196
trie : Trie {
197
197
generation : 2 ,
198
198
},
199
- pendingDeltas : newDeltas (nil ),
199
+ pendingDeltas : newDeltas (),
200
200
currentNode : & Node {
201
201
Generation : 1 ,
202
202
Key : []byte {1 },
@@ -217,11 +217,8 @@ func Test_Trie_prepForMutation(t *testing.T) {
217
217
25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 },
218
218
Dirty : true ,
219
219
},
220
- copied : true ,
221
- expectedPendingDeltas : newDeltas ([]common.Hash {{
222
- 0x98 , 0xfc , 0xd6 , 0x6b , 0xa3 , 0x12 , 0xc2 , 0x9e , 0xf1 , 0x93 , 0x5 , 0x2f , 0xd0 , 0xc1 , 0x4c , 0x6e ,
223
- 0x38 , 0xb1 , 0x58 , 0xbd , 0x5c , 0x2 , 0x35 , 0x6 , 0x45 , 0x94 , 0xca , 0xcc , 0x1a , 0xb5 , 0x96 , 0x5d ,
224
- }}),
220
+ copied : true ,
221
+ expectedPendingDeltas : newDeltas ("0x98fcd66ba312c29ef193052fd0c14c6e38b158bd5c0235064594cacc1ab5965d" ),
225
222
},
226
223
}
227
224
@@ -276,15 +273,10 @@ func Test_Trie_registerDeletedMerkleValue(t *testing.T) {
276
273
node : & Node {Dirty : true },
277
274
},
278
275
"clean root node registered" : {
279
- node : someSmallNode ,
280
- trie : Trie {root : someSmallNode },
281
- pendingDeltas : newDeltas (nil ),
282
- expectedPendingDeltas : newDeltas ([]common.Hash {{
283
- 0x60 , 0x51 , 0x6d , 0x0b , 0xb6 , 0xe1 , 0xbb , 0xfb ,
284
- 0x12 , 0x93 , 0xf1 , 0xb2 , 0x76 , 0xea , 0x95 , 0x05 ,
285
- 0xe9 , 0xf4 , 0xa4 , 0xe7 , 0xd9 , 0x8f , 0x62 , 0x0d ,
286
- 0x05 , 0x11 , 0x5e , 0x0b , 0x85 , 0x27 , 0x4a , 0xe1 ,
287
- }}),
276
+ node : someSmallNode ,
277
+ trie : Trie {root : someSmallNode },
278
+ pendingDeltas : newDeltas (),
279
+ expectedPendingDeltas : newDeltas ("0x60516d0bb6e1bbfb1293f1b276ea9505e9f4a4e7d98f620d05115e0b85274ae1" ),
288
280
expectedTrie : Trie {
289
281
root : & Node {
290
282
Key : []byte {1 },
@@ -313,11 +305,8 @@ func Test_Trie_registerDeletedMerkleValue(t *testing.T) {
313
305
17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 ,
314
306
25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 },
315
307
},
316
- pendingDeltas : newDeltas (nil ),
317
- expectedPendingDeltas : newDeltas ([]common.Hash {{
318
- 0x98 , 0xfc , 0xd6 , 0x6b , 0xa3 , 0x12 , 0xc2 , 0x9e , 0xf1 , 0x93 , 0x5 , 0x2f , 0xd0 , 0xc1 , 0x4c , 0x6e ,
319
- 0x38 , 0xb1 , 0x58 , 0xbd , 0x5c , 0x2 , 0x35 , 0x6 , 0x45 , 0x94 , 0xca , 0xcc , 0x1a , 0xb5 , 0x96 , 0x5d ,
320
- }}),
308
+ pendingDeltas : newDeltas (),
309
+ expectedPendingDeltas : newDeltas ("0x98fcd66ba312c29ef193052fd0c14c6e38b158bd5c0235064594cacc1ab5965d" ),
321
310
},
322
311
}
323
312
@@ -400,10 +389,10 @@ func Test_Trie_DeepCopy(t *testing.T) {
400
389
{1 , 2 , 3 }: {
401
390
generation : 2 ,
402
391
root : & Node {Key : []byte {1 }, SubValue : []byte {1 }},
403
- deltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
392
+ deltas : newDeltas ("0x01" , "0x02" ),
404
393
},
405
394
},
406
- deltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
395
+ deltas : newDeltas ("0x01" , "0x02" ),
407
396
},
408
397
trieCopy : & Trie {
409
398
generation : 1 ,
@@ -412,10 +401,10 @@ func Test_Trie_DeepCopy(t *testing.T) {
412
401
{1 , 2 , 3 }: {
413
402
generation : 2 ,
414
403
root : & Node {Key : []byte {1 }, SubValue : []byte {1 }},
415
- deltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
404
+ deltas : newDeltas ("0x01" , "0x02" ),
416
405
},
417
406
},
418
- deltas : newDeltas ([]common. Hash {{ 1 }, { 2 }} ),
407
+ deltas : newDeltas ("0x01" , "0x02" ),
419
408
},
420
409
},
421
410
}
@@ -1171,7 +1160,7 @@ func Test_Trie_Put(t *testing.T) {
1171
1160
"trie with key and value" : {
1172
1161
trie : Trie {
1173
1162
generation : 1 ,
1174
- deltas : newDeltas (nil ),
1163
+ deltas : newDeltas (),
1175
1164
root : & Node {
1176
1165
Key : []byte {1 , 2 , 0 , 5 },
1177
1166
SubValue : []byte {1 },
@@ -1181,12 +1170,7 @@ func Test_Trie_Put(t *testing.T) {
1181
1170
value : []byte {2 },
1182
1171
expectedTrie : Trie {
1183
1172
generation : 1 ,
1184
- deltas : newDeltas ([]common.Hash {
1185
- {
1186
- 0xa1 , 0x95 , 0x08 , 0x9c , 0x3e , 0x8f , 0x8b , 0x5b , 0x36 , 0x97 , 0x87 , 0x00 , 0xad , 0x95 , 0x4a , 0xed ,
1187
- 0x99 , 0xe0 , 0x84 , 0x13 , 0xcf , 0xc1 , 0xe2 , 0xb4 , 0xc0 , 0x0a , 0x5d , 0x06 , 0x4a , 0xbe , 0x66 , 0xa9 ,
1188
- },
1189
- }),
1173
+ deltas : newDeltas ("0xa195089c3e8f8b5b36978700ad954aed99e08413cfc1e2b4c00a5d064abe66a9" ),
1190
1174
root : & Node {
1191
1175
Key : []byte {1 , 2 },
1192
1176
Generation : 1 ,
@@ -1772,14 +1756,14 @@ func Test_LoadFromMap(t *testing.T) {
1772
1756
"nil data" : {
1773
1757
expectedTrie : Trie {
1774
1758
childTries : map [common.Hash ]* Trie {},
1775
- deltas : newDeltas (nil ),
1759
+ deltas : newDeltas (),
1776
1760
},
1777
1761
},
1778
1762
"empty data" : {
1779
1763
data : map [string ]string {},
1780
1764
expectedTrie : Trie {
1781
1765
childTries : map [common.Hash ]* Trie {},
1782
- deltas : newDeltas (nil ),
1766
+ deltas : newDeltas (),
1783
1767
},
1784
1768
},
1785
1769
"bad key" : {
@@ -1812,7 +1796,7 @@ func Test_LoadFromMap(t *testing.T) {
1812
1796
Dirty : true ,
1813
1797
},
1814
1798
childTries : map [common.Hash ]* Trie {},
1815
- deltas : newDeltas (nil ),
1799
+ deltas : newDeltas (),
1816
1800
},
1817
1801
},
1818
1802
"load key values" : {
@@ -1842,7 +1826,7 @@ func Test_LoadFromMap(t *testing.T) {
1842
1826
}),
1843
1827
},
1844
1828
childTries : map [common.Hash ]* Trie {},
1845
- deltas : newDeltas (nil ),
1829
+ deltas : newDeltas (),
1846
1830
},
1847
1831
},
1848
1832
}
@@ -3110,29 +3094,23 @@ func Test_Trie_ClearPrefix(t *testing.T) {
3110
3094
trie : Trie {
3111
3095
root : & Node {SubValue : []byte {1 }},
3112
3096
generation : 1 ,
3113
- deltas : newDeltas (nil ),
3097
+ deltas : newDeltas (),
3114
3098
},
3115
3099
expectedTrie : Trie {
3116
3100
generation : 1 ,
3117
- deltas : newDeltas ([]common.Hash {{
3118
- 0xf9 , 0x6a , 0x74 , 0x15 , 0x22 , 0xbc , 0xc1 , 0x4f , 0x0a , 0xea , 0x2f , 0x70 , 0x60 , 0x44 , 0x52 , 0x24 ,
3119
- 0x1d , 0x59 , 0xb5 , 0xf2 , 0xdd , 0xab , 0x9a , 0x69 , 0x48 , 0xfd , 0xb3 , 0xfe , 0xf5 , 0xf9 , 0x86 , 0x43 ,
3120
- }}),
3101
+ deltas : newDeltas ("0xf96a741522bcc14f0aea2f70604452241d59b5f2ddab9a6948fdb3fef5f98643" ),
3121
3102
},
3122
3103
},
3123
3104
"empty prefix" : {
3124
3105
trie : Trie {
3125
3106
root : & Node {SubValue : []byte {1 }},
3126
3107
generation : 1 ,
3127
- deltas : newDeltas (nil ),
3108
+ deltas : newDeltas (),
3128
3109
},
3129
3110
prefix : []byte {},
3130
3111
expectedTrie : Trie {
3131
3112
generation : 1 ,
3132
- deltas : newDeltas ([]common.Hash {{
3133
- 0xf9 , 0x6a , 0x74 , 0x15 , 0x22 , 0xbc , 0xc1 , 0x4f , 0x0a , 0xea , 0x2f , 0x70 , 0x60 , 0x44 , 0x52 , 0x24 ,
3134
- 0x1d , 0x59 , 0xb5 , 0xf2 , 0xdd , 0xab , 0x9a , 0x69 , 0x48 , 0xfd , 0xb3 , 0xfe , 0xf5 , 0xf9 , 0x86 , 0x43 ,
3135
- }}),
3113
+ deltas : newDeltas ("0xf96a741522bcc14f0aea2f70604452241d59b5f2ddab9a6948fdb3fef5f98643" ),
3136
3114
},
3137
3115
},
3138
3116
"empty trie" : {
@@ -3161,7 +3139,7 @@ func Test_Trie_ClearPrefix(t *testing.T) {
3161
3139
},
3162
3140
}),
3163
3141
},
3164
- deltas : newDeltas (nil ),
3142
+ deltas : newDeltas (),
3165
3143
},
3166
3144
prefix : []byte {0x12 , 0x16 },
3167
3145
expectedTrie : Trie {
@@ -3172,10 +3150,7 @@ func Test_Trie_ClearPrefix(t *testing.T) {
3172
3150
Generation : 1 ,
3173
3151
Dirty : true ,
3174
3152
},
3175
- deltas : newDeltas ([]common.Hash {{
3176
- 0x5f , 0xe1 , 0x08 , 0xc8 , 0x3d , 0x08 , 0x32 , 0x93 , 0x53 , 0xd6 , 0x91 , 0x8e , 0x01 , 0x04 , 0xda , 0xcc ,
3177
- 0x9d , 0x21 , 0x87 , 0xfd , 0x9d , 0xaf , 0xa5 , 0x82 , 0xd1 , 0xc5 , 0x32 , 0xe5 , 0xfe , 0x7b , 0x2e , 0x50 ,
3178
- }}),
3153
+ deltas : newDeltas ("0x5fe108c83d08329353d6918e0104dacc9d2187fd9dafa582d1c532e5fe7b2e50" ),
3179
3154
},
3180
3155
},
3181
3156
}
@@ -3546,28 +3521,22 @@ func Test_Trie_Delete(t *testing.T) {
3546
3521
trie : Trie {
3547
3522
root : & Node {SubValue : []byte {1 }},
3548
3523
generation : 1 ,
3549
- deltas : newDeltas (nil ),
3524
+ deltas : newDeltas (),
3550
3525
},
3551
3526
expectedTrie : Trie {
3552
3527
generation : 1 ,
3553
- deltas : newDeltas ([]common.Hash {{
3554
- 0xf9 , 0x6a , 0x74 , 0x15 , 0x22 , 0xbc , 0xc1 , 0x4f , 0x0a , 0xea , 0x2f , 0x70 , 0x60 , 0x44 , 0x52 , 0x24 ,
3555
- 0x1d , 0x59 , 0xb5 , 0xf2 , 0xdd , 0xab , 0x9a , 0x69 , 0x48 , 0xfd , 0xb3 , 0xfe , 0xf5 , 0xf9 , 0x86 , 0x43 ,
3556
- }}),
3528
+ deltas : newDeltas ("0xf96a741522bcc14f0aea2f70604452241d59b5f2ddab9a6948fdb3fef5f98643" ),
3557
3529
},
3558
3530
},
3559
3531
"empty key" : {
3560
3532
trie : Trie {
3561
3533
root : & Node {SubValue : []byte {1 }},
3562
3534
generation : 1 ,
3563
- deltas : newDeltas (nil ),
3535
+ deltas : newDeltas (),
3564
3536
},
3565
3537
expectedTrie : Trie {
3566
3538
generation : 1 ,
3567
- deltas : newDeltas ([]common.Hash {{
3568
- 0xf9 , 0x6a , 0x74 , 0x15 , 0x22 , 0xbc , 0xc1 , 0x4f , 0x0a , 0xea , 0x2f , 0x70 , 0x60 , 0x44 , 0x52 , 0x24 ,
3569
- 0x1d , 0x59 , 0xb5 , 0xf2 , 0xdd , 0xab , 0x9a , 0x69 , 0x48 , 0xfd , 0xb3 , 0xfe , 0xf5 , 0xf9 , 0x86 , 0x43 ,
3570
- }}),
3539
+ deltas : newDeltas ("0xf96a741522bcc14f0aea2f70604452241d59b5f2ddab9a6948fdb3fef5f98643" ),
3571
3540
},
3572
3541
},
3573
3542
"empty trie" : {
@@ -3597,7 +3566,7 @@ func Test_Trie_Delete(t *testing.T) {
3597
3566
},
3598
3567
}),
3599
3568
},
3600
- deltas : newDeltas (nil ),
3569
+ deltas : newDeltas (),
3601
3570
},
3602
3571
key : []byte {0x12 , 0x16 },
3603
3572
expectedTrie : Trie {
@@ -3622,10 +3591,7 @@ func Test_Trie_Delete(t *testing.T) {
3622
3591
},
3623
3592
}),
3624
3593
},
3625
- deltas : newDeltas ([]common.Hash {{
3626
- 0x3d , 0x1b , 0x3d , 0x72 , 0x7e , 0xe4 , 0x04 , 0x54 , 0x9a , 0x5d , 0x25 , 0x31 , 0xaa , 0xb9 , 0xff , 0xf0 ,
3627
- 0xee , 0xdd , 0xc5 , 0x8b , 0xc3 , 0x0b , 0xfe , 0x2f , 0xe8 , 0x2b , 0x1a , 0x0c , 0xfe , 0x7e , 0x76 , 0xd5 ,
3628
- }}),
3594
+ deltas : newDeltas ("0x3d1b3d727ee404549a5d2531aab9fff0eeddc58bc30bfe2fe82b1a0cfe7e76d5" ),
3629
3595
},
3630
3596
},
3631
3597
}
0 commit comments