@@ -60,7 +60,7 @@ func writeFailedData(t *testing.T, kv map[string][]byte, path string) {
60
60
func buildSmallTrie () * Trie {
61
61
trie := NewEmptyTrie ()
62
62
63
- tests := []Test {
63
+ tests := []keyValues {
64
64
{key : []byte {0x01 , 0x35 }, value : []byte ("pen" )},
65
65
{key : []byte {0x01 , 0x35 , 0x79 }, value : []byte ("penguin" )},
66
66
{key : []byte {0xf2 }, value : []byte ("feather" )},
@@ -76,7 +76,7 @@ func buildSmallTrie() *Trie {
76
76
return trie
77
77
}
78
78
79
- func runTests (t * testing.T , trie * Trie , tests []Test ) {
79
+ func runTests (t * testing.T , trie * Trie , tests []keyValues ) {
80
80
for _ , test := range tests {
81
81
switch test .op {
82
82
case put :
@@ -96,7 +96,7 @@ func runTests(t *testing.T, trie *Trie, tests []Test) {
96
96
func TestPutAndGetBranch (t * testing.T ) {
97
97
trie := NewEmptyTrie ()
98
98
99
- tests := []Test {
99
+ tests := []keyValues {
100
100
{key : []byte {0x01 , 0x35 }, value : []byte ("spaghetti" ), op : put },
101
101
{key : []byte {0x01 , 0x35 , 0x79 }, value : []byte ("gnocchi" ), op : put },
102
102
{key : []byte {0x07 }, value : []byte ("ramen" ), op : put },
@@ -115,7 +115,7 @@ func TestPutAndGetBranch(t *testing.T) {
115
115
func TestPutAndGetOddKeyLengths (t * testing.T ) {
116
116
trie := NewEmptyTrie ()
117
117
118
- tests := []Test {
118
+ tests := []keyValues {
119
119
{key : []byte {0x43 , 0xc1 }, value : []byte ("noot" ), op : put },
120
120
{key : []byte {0x49 , 0x29 }, value : []byte ("nootagain" ), op : put },
121
121
{key : []byte {0x43 , 0x0c }, value : []byte ("odd" ), op : put },
@@ -210,7 +210,7 @@ func Test_Trie_PutAndGet_FailedData(t *testing.T) {
210
210
func TestGetPartialKey (t * testing.T ) {
211
211
trie := NewEmptyTrie ()
212
212
213
- tests := []Test {
213
+ tests := []keyValues {
214
214
{key : []byte {0x01 , 0x35 }, value : []byte ("pen" ), op : put },
215
215
{key : []byte {0x01 , 0x35 , 0x79 }, value : []byte ("penguin" ), op : put },
216
216
{key : []byte {0x01 , 0x35 , 0x07 }, value : []byte ("odd" ), op : put },
@@ -235,7 +235,7 @@ func TestGetPartialKey(t *testing.T) {
235
235
func TestDeleteSmall (t * testing.T ) {
236
236
trie := buildSmallTrie ()
237
237
238
- tests := []Test {
238
+ tests := []keyValues {
239
239
{key : []byte {}, value : []byte ("floof" ), op : del },
240
240
{key : []byte {}, value : nil , op : get },
241
241
{key : []byte {}, value : []byte ("floof" ), op : put },
@@ -279,7 +279,7 @@ func TestDeleteSmall(t *testing.T) {
279
279
func TestDeleteCombineBranch (t * testing.T ) {
280
280
trie := buildSmallTrie ()
281
281
282
- tests := []Test {
282
+ tests := []keyValues {
283
283
{key : []byte {0x01 , 0x35 , 0x46 }, value : []byte ("raccoon" ), op : put },
284
284
{key : []byte {0x01 , 0x35 , 0x46 , 0x77 }, value : []byte ("rat" ), op : put },
285
285
{key : []byte {0x09 , 0xd3 }, value : []byte ("noot" ), op : del },
@@ -292,7 +292,7 @@ func TestDeleteCombineBranch(t *testing.T) {
292
292
func TestDeleteFromBranch (t * testing.T ) {
293
293
trie := NewEmptyTrie ()
294
294
295
- tests := []Test {
295
+ tests := []keyValues {
296
296
{key : []byte {0x06 , 0x15 , 0xfc }, value : []byte ("noot" ), op : put },
297
297
{key : []byte {0x06 , 0x2b , 0xa9 }, value : []byte ("nootagain" ), op : put },
298
298
{key : []byte {0x06 , 0xaf , 0xb1 }, value : []byte ("odd" ), op : put },
@@ -317,7 +317,7 @@ func TestDeleteFromBranch(t *testing.T) {
317
317
func TestDeleteOddKeyLengths (t * testing.T ) {
318
318
trie := NewEmptyTrie ()
319
319
320
- tests := []Test {
320
+ tests := []keyValues {
321
321
{key : []byte {0x43 , 0xc1 }, value : []byte ("noot" ), op : put },
322
322
{key : []byte {0x43 , 0xc1 }, value : []byte ("noot" ), op : get },
323
323
{key : []byte {0x49 , 0x29 }, value : []byte ("nootagain" ), op : put },
@@ -360,7 +360,7 @@ func TestTrieDiff(t *testing.T) {
360
360
361
361
var testKey = []byte ("testKey" )
362
362
363
- tests := []Test {
363
+ tests := []keyValues {
364
364
{key : testKey , value : testKey },
365
365
{key : []byte ("testKey1" ), value : []byte ("testKey1" )},
366
366
{key : []byte ("testKey2" ), value : []byte ("testKey2" )},
@@ -374,7 +374,7 @@ func TestTrieDiff(t *testing.T) {
374
374
err = trie .Store (storageDB )
375
375
require .NoError (t , err )
376
376
377
- tests = []Test {
377
+ tests = []keyValues {
378
378
{key : testKey , value : []byte ("newTestKey2" )},
379
379
{key : []byte ("testKey2" ), value : []byte ("newKey" )},
380
380
{key : []byte ("testKey3" ), value : []byte ("testKey3" )},
@@ -462,7 +462,7 @@ func TestDelete(t *testing.T) {
462
462
}
463
463
464
464
func TestClearPrefix (t * testing.T ) {
465
- tests := []Test {
465
+ tests := []keyValues {
466
466
{key : []byte {0x01 , 0x35 }, value : []byte ("spaghetti" ), op : put },
467
467
{key : []byte {0x01 , 0x35 , 0x79 }, value : []byte ("gnocchi" ), op : put },
468
468
{key : []byte {0x01 , 0x35 , 0x79 , 0xab }, value : []byte ("spaghetti" ), op : put },
@@ -627,7 +627,7 @@ func TestTrie_ClearPrefixVsDelete(t *testing.T) {
627
627
[]byte ("a" ),
628
628
}
629
629
630
- cases := [][]Test {
630
+ cases := [][]keyValues {
631
631
{
632
632
{key : []byte {0x01 , 0x35 }, value : []byte ("pen" )},
633
633
{key : []byte {0x01 , 0x35 , 0x79 }, value : []byte ("penguin" )},
@@ -681,7 +681,7 @@ func TestTrie_ClearPrefixVsDelete(t *testing.T) {
681
681
}
682
682
683
683
func TestSnapshot (t * testing.T ) {
684
- tests := []Test {
684
+ tests := []keyValues {
685
685
{key : []byte {0x01 , 0x35 }, value : []byte ("spaghetti" ), op : put },
686
686
{key : []byte {0x01 , 0x35 , 0x79 }, value : []byte ("gnocchi" ), op : put },
687
687
{key : []byte {0x01 , 0x35 , 0x79 , 0xab }, value : []byte ("spaghetti" ), op : put },
@@ -784,11 +784,11 @@ func TestTrie_ConcurrentSnapshotWrites(t *testing.T) {
784
784
const size = 1000
785
785
const workers = 4
786
786
787
- testCases := make ([][]Test , workers )
787
+ testCases := make ([][]keyValues , workers )
788
788
expectedTries := make ([]* Trie , workers )
789
789
790
790
for i := 0 ; i < workers ; i ++ {
791
- testCases [i ] = make ([]Test , size )
791
+ testCases [i ] = make ([]keyValues , size )
792
792
expectedTries [i ] = buildSmallTrie ()
793
793
for j := 0 ; j < size ; j ++ {
794
794
k := make ([]byte , 2 )
@@ -805,7 +805,7 @@ func TestTrie_ConcurrentSnapshotWrites(t *testing.T) {
805
805
expectedTries [i ].ClearPrefix (k )
806
806
}
807
807
808
- testCases [i ][j ] = Test {
808
+ testCases [i ][j ] = keyValues {
809
809
key : k ,
810
810
op : op ,
811
811
}
@@ -821,7 +821,7 @@ func TestTrie_ConcurrentSnapshotWrites(t *testing.T) {
821
821
for i := 0 ; i < workers ; i ++ {
822
822
snapshotedTries [i ] = buildSmallTrie ().Snapshot ()
823
823
824
- go func (trie * Trie , operations []Test ,
824
+ go func (trie * Trie , operations []keyValues ,
825
825
startWg , finishWg * sync.WaitGroup ) {
826
826
defer finishWg .Done ()
827
827
startWg .Done ()
@@ -864,7 +864,7 @@ func TestTrie_ClearPrefixLimit(t *testing.T) {
864
864
{0x09 },
865
865
}
866
866
867
- cases := [][]Test {
867
+ cases := [][]keyValues {
868
868
{
869
869
{key : []byte {0x01 , 0x35 }, value : []byte ("pen" )},
870
870
{key : []byte {0x01 , 0x36 }, value : []byte ("pencil" )},
@@ -900,7 +900,7 @@ func TestTrie_ClearPrefixLimit(t *testing.T) {
900
900
},
901
901
}
902
902
903
- testFn := func (t * testing.T , testCase []Test , prefix []byte ) {
903
+ testFn := func (t * testing.T , testCase []keyValues , prefix []byte ) {
904
904
prefixNibbles := codec .KeyLEToNibbles (prefix )
905
905
if len (prefixNibbles ) > 0 && prefixNibbles [len (prefixNibbles )- 1 ] == 0 {
906
906
prefixNibbles = prefixNibbles [:len (prefixNibbles )- 1 ]
@@ -965,7 +965,7 @@ func TestTrie_ClearPrefixLimitSnapshot(t *testing.T) {
965
965
{0x09 },
966
966
}
967
967
968
- cases := [][]Test {
968
+ cases := [][]keyValues {
969
969
{
970
970
{key : []byte {0x01 }, value : []byte ("feather" )},
971
971
},
0 commit comments