aboutsummaryrefslogtreecommitdiffstats
path: root/trie/sync_test.go
diff options
context:
space:
mode:
authorWenbiao Zheng <delweng@gmail.com>2018-05-29 23:48:43 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-05-29 23:48:43 +0800
commit38c7eb0f26eaa8df229d27e92f12e253313a6c8d (patch)
tree93b57c84013170b006b3cb47dd7b6341c387afcf /trie/sync_test.go
parentd51faee2402072a6af66b8f08f6334944585419d (diff)
downloadgo-tangerine-38c7eb0f26eaa8df229d27e92f12e253313a6c8d.tar
go-tangerine-38c7eb0f26eaa8df229d27e92f12e253313a6c8d.tar.gz
go-tangerine-38c7eb0f26eaa8df229d27e92f12e253313a6c8d.tar.bz2
go-tangerine-38c7eb0f26eaa8df229d27e92f12e253313a6c8d.tar.lz
go-tangerine-38c7eb0f26eaa8df229d27e92f12e253313a6c8d.tar.xz
go-tangerine-38c7eb0f26eaa8df229d27e92f12e253313a6c8d.tar.zst
go-tangerine-38c7eb0f26eaa8df229d27e92f12e253313a6c8d.zip
trie: rename TrieSync to Sync and improve hexToKeybytes (#16804)
This removes a golint warning: type name will be used as trie.TrieSync by other packages, and that stutters; consider calling this Sync. In hexToKeybytes len(hex) is even and (even+1)/2 == even/2, remove the +1.
Diffstat (limited to 'trie/sync_test.go')
-rw-r--r--trie/sync_test.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/trie/sync_test.go b/trie/sync_test.go
index 142a6f5b1..c76779e5c 100644
--- a/trie/sync_test.go
+++ b/trie/sync_test.go
@@ -87,14 +87,14 @@ func checkTrieConsistency(db *Database, root common.Hash) error {
}
// Tests that an empty trie is not scheduled for syncing.
-func TestEmptyTrieSync(t *testing.T) {
+func TestEmptySync(t *testing.T) {
dbA := NewDatabase(ethdb.NewMemDatabase())
dbB := NewDatabase(ethdb.NewMemDatabase())
emptyA, _ := New(common.Hash{}, dbA)
emptyB, _ := New(emptyRoot, dbB)
for i, trie := range []*Trie{emptyA, emptyB} {
- if req := NewTrieSync(trie.Hash(), ethdb.NewMemDatabase(), nil).Missing(1); len(req) != 0 {
+ if req := NewSync(trie.Hash(), ethdb.NewMemDatabase(), nil).Missing(1); len(req) != 0 {
t.Errorf("test %d: content requested for empty trie: %v", i, req)
}
}
@@ -102,17 +102,17 @@ func TestEmptyTrieSync(t *testing.T) {
// Tests that given a root hash, a trie can sync iteratively on a single thread,
// requesting retrieval tasks and returning all of them in one go.
-func TestIterativeTrieSyncIndividual(t *testing.T) { testIterativeTrieSync(t, 1) }
-func TestIterativeTrieSyncBatched(t *testing.T) { testIterativeTrieSync(t, 100) }
+func TestIterativeSyncIndividual(t *testing.T) { testIterativeSync(t, 1) }
+func TestIterativeSyncBatched(t *testing.T) { testIterativeSync(t, 100) }
-func testIterativeTrieSync(t *testing.T, batch int) {
+func testIterativeSync(t *testing.T, batch int) {
// Create a random trie to copy
srcDb, srcTrie, srcData := makeTestTrie()
// Create a destination trie and sync with the scheduler
diskdb := ethdb.NewMemDatabase()
triedb := NewDatabase(diskdb)
- sched := NewTrieSync(srcTrie.Hash(), diskdb, nil)
+ sched := NewSync(srcTrie.Hash(), diskdb, nil)
queue := append([]common.Hash{}, sched.Missing(batch)...)
for len(queue) > 0 {
@@ -138,14 +138,14 @@ func testIterativeTrieSync(t *testing.T, batch int) {
// Tests that the trie scheduler can correctly reconstruct the state even if only
// partial results are returned, and the others sent only later.
-func TestIterativeDelayedTrieSync(t *testing.T) {
+func TestIterativeDelayedSync(t *testing.T) {
// Create a random trie to copy
srcDb, srcTrie, srcData := makeTestTrie()
// Create a destination trie and sync with the scheduler
diskdb := ethdb.NewMemDatabase()
triedb := NewDatabase(diskdb)
- sched := NewTrieSync(srcTrie.Hash(), diskdb, nil)
+ sched := NewSync(srcTrie.Hash(), diskdb, nil)
queue := append([]common.Hash{}, sched.Missing(10000)...)
for len(queue) > 0 {
@@ -173,17 +173,17 @@ func TestIterativeDelayedTrieSync(t *testing.T) {
// Tests that given a root hash, a trie can sync iteratively on a single thread,
// requesting retrieval tasks and returning all of them in one go, however in a
// random order.
-func TestIterativeRandomTrieSyncIndividual(t *testing.T) { testIterativeRandomTrieSync(t, 1) }
-func TestIterativeRandomTrieSyncBatched(t *testing.T) { testIterativeRandomTrieSync(t, 100) }
+func TestIterativeRandomSyncIndividual(t *testing.T) { testIterativeRandomSync(t, 1) }
+func TestIterativeRandomSyncBatched(t *testing.T) { testIterativeRandomSync(t, 100) }
-func testIterativeRandomTrieSync(t *testing.T, batch int) {
+func testIterativeRandomSync(t *testing.T, batch int) {
// Create a random trie to copy
srcDb, srcTrie, srcData := makeTestTrie()
// Create a destination trie and sync with the scheduler
diskdb := ethdb.NewMemDatabase()
triedb := NewDatabase(diskdb)
- sched := NewTrieSync(srcTrie.Hash(), diskdb, nil)
+ sched := NewSync(srcTrie.Hash(), diskdb, nil)
queue := make(map[common.Hash]struct{})
for _, hash := range sched.Missing(batch) {
@@ -217,14 +217,14 @@ func testIterativeRandomTrieSync(t *testing.T, batch int) {
// Tests that the trie scheduler can correctly reconstruct the state even if only
// partial results are returned (Even those randomly), others sent only later.
-func TestIterativeRandomDelayedTrieSync(t *testing.T) {
+func TestIterativeRandomDelayedSync(t *testing.T) {
// Create a random trie to copy
srcDb, srcTrie, srcData := makeTestTrie()
// Create a destination trie and sync with the scheduler
diskdb := ethdb.NewMemDatabase()
triedb := NewDatabase(diskdb)
- sched := NewTrieSync(srcTrie.Hash(), diskdb, nil)
+ sched := NewSync(srcTrie.Hash(), diskdb, nil)
queue := make(map[common.Hash]struct{})
for _, hash := range sched.Missing(10000) {
@@ -264,14 +264,14 @@ func TestIterativeRandomDelayedTrieSync(t *testing.T) {
// Tests that a trie sync will not request nodes multiple times, even if they
// have such references.
-func TestDuplicateAvoidanceTrieSync(t *testing.T) {
+func TestDuplicateAvoidanceSync(t *testing.T) {
// Create a random trie to copy
srcDb, srcTrie, srcData := makeTestTrie()
// Create a destination trie and sync with the scheduler
diskdb := ethdb.NewMemDatabase()
triedb := NewDatabase(diskdb)
- sched := NewTrieSync(srcTrie.Hash(), diskdb, nil)
+ sched := NewSync(srcTrie.Hash(), diskdb, nil)
queue := append([]common.Hash{}, sched.Missing(0)...)
requested := make(map[common.Hash]struct{})
@@ -304,14 +304,14 @@ func TestDuplicateAvoidanceTrieSync(t *testing.T) {
// Tests that at any point in time during a sync, only complete sub-tries are in
// the database.
-func TestIncompleteTrieSync(t *testing.T) {
+func TestIncompleteSync(t *testing.T) {
// Create a random trie to copy
srcDb, srcTrie, _ := makeTestTrie()
// Create a destination trie and sync with the scheduler
diskdb := ethdb.NewMemDatabase()
triedb := NewDatabase(diskdb)
- sched := NewTrieSync(srcTrie.Hash(), diskdb, nil)
+ sched := NewSync(srcTrie.Hash(), diskdb, nil)
added := []common.Hash{}
queue := append([]common.Hash{}, sched.Missing(1)...)