Skip to content

Commit 5c7ec38

Browse files
renaming Test to keyValue
1 parent 31d2b8e commit 5c7ec38

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

lib/trie/database_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func newTestDB(t *testing.T) chaindb.Database {
2222
}
2323

2424
func TestTrie_DatabaseStoreAndLoad(t *testing.T) {
25-
cases := [][]Test{
25+
cases := [][]keyValues{
2626
{
2727
{key: []byte{0x01, 0x35}, value: []byte("pen")},
2828
{key: []byte{0x01, 0x35, 0x79}, value: []byte("penguin")},
@@ -77,7 +77,7 @@ func TestTrie_DatabaseStoreAndLoad(t *testing.T) {
7777
}
7878

7979
func TestTrie_WriteDirty_Put(t *testing.T) {
80-
cases := [][]Test{
80+
cases := [][]keyValues{
8181
{
8282
{key: []byte{0x01, 0x35}, value: []byte("pen")},
8383
{key: []byte{0x01, 0x35, 0x79}, value: []byte("penguin")},
@@ -155,7 +155,7 @@ func TestTrie_WriteDirty_Put(t *testing.T) {
155155
}
156156

157157
func TestTrie_WriteDirty_PutReplace(t *testing.T) {
158-
cases := [][]Test{
158+
cases := [][]keyValues{
159159
{
160160
{key: []byte{0x01, 0x35}, value: []byte("pen")},
161161
{key: []byte{0x01, 0x35, 0x79}, value: []byte("penguin")},
@@ -218,7 +218,7 @@ func TestTrie_WriteDirty_PutReplace(t *testing.T) {
218218
}
219219

220220
func TestTrie_WriteDirty_Delete(t *testing.T) {
221-
cases := [][]Test{
221+
cases := [][]keyValues{
222222
{
223223
{key: []byte{0x01, 0x35}, value: []byte("pen")},
224224
{key: []byte{0x01, 0x35, 0x79}, value: []byte("penguin")},
@@ -285,7 +285,7 @@ func TestTrie_WriteDirty_Delete(t *testing.T) {
285285
}
286286

287287
func TestTrie_WriteDirty_ClearPrefix(t *testing.T) {
288-
cases := [][]Test{
288+
cases := [][]keyValues{
289289
{
290290
{key: []byte{0x01, 0x35}, value: []byte("pen")},
291291
{key: []byte{0x01, 0x35, 0x79}, value: []byte("penguin")},
@@ -338,7 +338,7 @@ func TestTrie_WriteDirty_ClearPrefix(t *testing.T) {
338338
}
339339

340340
func TestTrie_GetFromDB(t *testing.T) {
341-
cases := [][]Test{
341+
cases := [][]keyValues{
342342
{
343343
{key: []byte{0x01, 0x35}, value: []byte("pen")},
344344
{key: []byte{0x01, 0x35, 0x79}, value: []byte("penguin")},
@@ -390,7 +390,7 @@ func TestTrie_GetFromDB(t *testing.T) {
390390
}
391391

392392
func TestStoreAndLoadWithChildTries(t *testing.T) {
393-
testCase := []Test{
393+
keyValue := []keyValues{
394394
{key: []byte{0xf2, 0x3}, value: []byte("f")},
395395
{key: []byte{0x09, 0xd3}, value: []byte("noot")},
396396
{key: []byte{0x07}, value: []byte("ramen")},
@@ -420,7 +420,7 @@ func TestStoreAndLoadWithChildTries(t *testing.T) {
420420
for _, keyToChild := range keysToTest {
421421
trie := NewEmptyTrie()
422422

423-
for _, test := range testCase {
423+
for _, test := range keyValue {
424424
trie.Put(test.key, test.value)
425425
}
426426

lib/trie/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type writeCall struct {
2020

2121
var errTest = errors.New("test error")
2222

23-
type Test struct {
23+
type keyValues struct {
2424
key []byte
2525
value []byte
2626
op int

lib/trie/trie_endtoend_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func writeFailedData(t *testing.T, kv map[string][]byte, path string) {
6060
func buildSmallTrie() *Trie {
6161
trie := NewEmptyTrie()
6262

63-
tests := []Test{
63+
tests := []keyValues{
6464
{key: []byte{0x01, 0x35}, value: []byte("pen")},
6565
{key: []byte{0x01, 0x35, 0x79}, value: []byte("penguin")},
6666
{key: []byte{0xf2}, value: []byte("feather")},
@@ -76,7 +76,7 @@ func buildSmallTrie() *Trie {
7676
return trie
7777
}
7878

79-
func runTests(t *testing.T, trie *Trie, tests []Test) {
79+
func runTests(t *testing.T, trie *Trie, tests []keyValues) {
8080
for _, test := range tests {
8181
switch test.op {
8282
case put:
@@ -96,7 +96,7 @@ func runTests(t *testing.T, trie *Trie, tests []Test) {
9696
func TestPutAndGetBranch(t *testing.T) {
9797
trie := NewEmptyTrie()
9898

99-
tests := []Test{
99+
tests := []keyValues{
100100
{key: []byte{0x01, 0x35}, value: []byte("spaghetti"), op: put},
101101
{key: []byte{0x01, 0x35, 0x79}, value: []byte("gnocchi"), op: put},
102102
{key: []byte{0x07}, value: []byte("ramen"), op: put},
@@ -115,7 +115,7 @@ func TestPutAndGetBranch(t *testing.T) {
115115
func TestPutAndGetOddKeyLengths(t *testing.T) {
116116
trie := NewEmptyTrie()
117117

118-
tests := []Test{
118+
tests := []keyValues{
119119
{key: []byte{0x43, 0xc1}, value: []byte("noot"), op: put},
120120
{key: []byte{0x49, 0x29}, value: []byte("nootagain"), op: put},
121121
{key: []byte{0x43, 0x0c}, value: []byte("odd"), op: put},
@@ -210,7 +210,7 @@ func Test_Trie_PutAndGet_FailedData(t *testing.T) {
210210
func TestGetPartialKey(t *testing.T) {
211211
trie := NewEmptyTrie()
212212

213-
tests := []Test{
213+
tests := []keyValues{
214214
{key: []byte{0x01, 0x35}, value: []byte("pen"), op: put},
215215
{key: []byte{0x01, 0x35, 0x79}, value: []byte("penguin"), op: put},
216216
{key: []byte{0x01, 0x35, 0x07}, value: []byte("odd"), op: put},
@@ -235,7 +235,7 @@ func TestGetPartialKey(t *testing.T) {
235235
func TestDeleteSmall(t *testing.T) {
236236
trie := buildSmallTrie()
237237

238-
tests := []Test{
238+
tests := []keyValues{
239239
{key: []byte{}, value: []byte("floof"), op: del},
240240
{key: []byte{}, value: nil, op: get},
241241
{key: []byte{}, value: []byte("floof"), op: put},
@@ -279,7 +279,7 @@ func TestDeleteSmall(t *testing.T) {
279279
func TestDeleteCombineBranch(t *testing.T) {
280280
trie := buildSmallTrie()
281281

282-
tests := []Test{
282+
tests := []keyValues{
283283
{key: []byte{0x01, 0x35, 0x46}, value: []byte("raccoon"), op: put},
284284
{key: []byte{0x01, 0x35, 0x46, 0x77}, value: []byte("rat"), op: put},
285285
{key: []byte{0x09, 0xd3}, value: []byte("noot"), op: del},
@@ -292,7 +292,7 @@ func TestDeleteCombineBranch(t *testing.T) {
292292
func TestDeleteFromBranch(t *testing.T) {
293293
trie := NewEmptyTrie()
294294

295-
tests := []Test{
295+
tests := []keyValues{
296296
{key: []byte{0x06, 0x15, 0xfc}, value: []byte("noot"), op: put},
297297
{key: []byte{0x06, 0x2b, 0xa9}, value: []byte("nootagain"), op: put},
298298
{key: []byte{0x06, 0xaf, 0xb1}, value: []byte("odd"), op: put},
@@ -317,7 +317,7 @@ func TestDeleteFromBranch(t *testing.T) {
317317
func TestDeleteOddKeyLengths(t *testing.T) {
318318
trie := NewEmptyTrie()
319319

320-
tests := []Test{
320+
tests := []keyValues{
321321
{key: []byte{0x43, 0xc1}, value: []byte("noot"), op: put},
322322
{key: []byte{0x43, 0xc1}, value: []byte("noot"), op: get},
323323
{key: []byte{0x49, 0x29}, value: []byte("nootagain"), op: put},
@@ -360,7 +360,7 @@ func TestTrieDiff(t *testing.T) {
360360

361361
var testKey = []byte("testKey")
362362

363-
tests := []Test{
363+
tests := []keyValues{
364364
{key: testKey, value: testKey},
365365
{key: []byte("testKey1"), value: []byte("testKey1")},
366366
{key: []byte("testKey2"), value: []byte("testKey2")},
@@ -374,7 +374,7 @@ func TestTrieDiff(t *testing.T) {
374374
err = trie.Store(storageDB)
375375
require.NoError(t, err)
376376

377-
tests = []Test{
377+
tests = []keyValues{
378378
{key: testKey, value: []byte("newTestKey2")},
379379
{key: []byte("testKey2"), value: []byte("newKey")},
380380
{key: []byte("testKey3"), value: []byte("testKey3")},
@@ -462,7 +462,7 @@ func TestDelete(t *testing.T) {
462462
}
463463

464464
func TestClearPrefix(t *testing.T) {
465-
tests := []Test{
465+
tests := []keyValues{
466466
{key: []byte{0x01, 0x35}, value: []byte("spaghetti"), op: put},
467467
{key: []byte{0x01, 0x35, 0x79}, value: []byte("gnocchi"), op: put},
468468
{key: []byte{0x01, 0x35, 0x79, 0xab}, value: []byte("spaghetti"), op: put},
@@ -627,7 +627,7 @@ func TestTrie_ClearPrefixVsDelete(t *testing.T) {
627627
[]byte("a"),
628628
}
629629

630-
cases := [][]Test{
630+
cases := [][]keyValues{
631631
{
632632
{key: []byte{0x01, 0x35}, value: []byte("pen")},
633633
{key: []byte{0x01, 0x35, 0x79}, value: []byte("penguin")},
@@ -681,7 +681,7 @@ func TestTrie_ClearPrefixVsDelete(t *testing.T) {
681681
}
682682

683683
func TestSnapshot(t *testing.T) {
684-
tests := []Test{
684+
tests := []keyValues{
685685
{key: []byte{0x01, 0x35}, value: []byte("spaghetti"), op: put},
686686
{key: []byte{0x01, 0x35, 0x79}, value: []byte("gnocchi"), op: put},
687687
{key: []byte{0x01, 0x35, 0x79, 0xab}, value: []byte("spaghetti"), op: put},
@@ -784,11 +784,11 @@ func TestTrie_ConcurrentSnapshotWrites(t *testing.T) {
784784
const size = 1000
785785
const workers = 4
786786

787-
testCases := make([][]Test, workers)
787+
testCases := make([][]keyValues, workers)
788788
expectedTries := make([]*Trie, workers)
789789

790790
for i := 0; i < workers; i++ {
791-
testCases[i] = make([]Test, size)
791+
testCases[i] = make([]keyValues, size)
792792
expectedTries[i] = buildSmallTrie()
793793
for j := 0; j < size; j++ {
794794
k := make([]byte, 2)
@@ -805,7 +805,7 @@ func TestTrie_ConcurrentSnapshotWrites(t *testing.T) {
805805
expectedTries[i].ClearPrefix(k)
806806
}
807807

808-
testCases[i][j] = Test{
808+
testCases[i][j] = keyValues{
809809
key: k,
810810
op: op,
811811
}
@@ -821,7 +821,7 @@ func TestTrie_ConcurrentSnapshotWrites(t *testing.T) {
821821
for i := 0; i < workers; i++ {
822822
snapshotedTries[i] = buildSmallTrie().Snapshot()
823823

824-
go func(trie *Trie, operations []Test,
824+
go func(trie *Trie, operations []keyValues,
825825
startWg, finishWg *sync.WaitGroup) {
826826
defer finishWg.Done()
827827
startWg.Done()
@@ -864,7 +864,7 @@ func TestTrie_ClearPrefixLimit(t *testing.T) {
864864
{0x09},
865865
}
866866

867-
cases := [][]Test{
867+
cases := [][]keyValues{
868868
{
869869
{key: []byte{0x01, 0x35}, value: []byte("pen")},
870870
{key: []byte{0x01, 0x36}, value: []byte("pencil")},
@@ -900,7 +900,7 @@ func TestTrie_ClearPrefixLimit(t *testing.T) {
900900
},
901901
}
902902

903-
testFn := func(t *testing.T, testCase []Test, prefix []byte) {
903+
testFn := func(t *testing.T, testCase []keyValues, prefix []byte) {
904904
prefixNibbles := codec.KeyLEToNibbles(prefix)
905905
if len(prefixNibbles) > 0 && prefixNibbles[len(prefixNibbles)-1] == 0 {
906906
prefixNibbles = prefixNibbles[:len(prefixNibbles)-1]
@@ -965,7 +965,7 @@ func TestTrie_ClearPrefixLimitSnapshot(t *testing.T) {
965965
{0x09},
966966
}
967967

968-
cases := [][]Test{
968+
cases := [][]keyValues{
969969
{
970970
{key: []byte{0x01}, value: []byte("feather")},
971971
},

0 commit comments

Comments
 (0)