@ -87,14 +87,14 @@ func checkTrieConsistency(db *Database, root common.Hash) error {
}
// Tests that an empty trie is not scheduled for syncing.
func TestEmptyTrie Sync ( 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 := NewTrie Sync ( 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 TestIterativeTrie SyncIndividual ( t * testing . T ) { testIterativeTri eSync ( t , 1 ) }
func TestIterativeTrie SyncBatched ( t * testing . T ) { testIterativeTri eSync ( t , 100 ) }
func TestIterativeSyncIndividual ( t * testing . T ) { testIterativeSync ( t , 1 ) }
func TestIterativeSyncBatched ( t * testing . T ) { testIterativeSync ( t , 100 ) }
func testIterativeTrie Sync ( 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 := NewTrie Sync ( 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 TestIterativeDelayedTrie Sync ( 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 := NewTrie Sync ( 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 TestIterativeRandomTrie SyncIndividual ( t * testing . T ) { testIterativeRandomTrie Sync ( t , 1 ) }
func TestIterativeRandomTrie SyncBatched ( t * testing . T ) { testIterativeRandomTrie Sync ( t , 100 ) }
func TestIterativeRandomSyncIndividual ( t * testing . T ) { testIterativeRandomSync ( t , 1 ) }
func TestIterativeRandomSyncBatched ( t * testing . T ) { testIterativeRandomSync ( t , 100 ) }
func testIterativeRandomTrie Sync ( 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 := NewTrie Sync ( 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 TestIterativeRandomDelayedTrie Sync ( 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 := NewTrie Sync ( 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 TestDuplicateAvoidanceTrie Sync ( 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 := NewTrie Sync ( 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 TestIncompleteTrie Sync ( 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 := NewTrie Sync ( srcTrie . Hash ( ) , diskdb , nil )
sched := NewSync ( srcTrie . Hash ( ) , diskdb , nil )
added := [ ] common . Hash { }
queue := append ( [ ] common . Hash { } , sched . Missing ( 1 ) ... )