|
|
@ -794,15 +794,8 @@ func TestMultiSyncManyUseless(t *testing.T) { |
|
|
|
verifyTrie(syncer.db, sourceAccountTrie.Hash(), t) |
|
|
|
verifyTrie(syncer.db, sourceAccountTrie.Hash(), t) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
// TestMultiSyncManyUseless contains one good peer, and many which doesn't return anything valuable at all
|
|
|
|
// TestMultiSyncManyUseless contains one good peer, and many which doesn't return anything valuable at all
|
|
|
|
func TestMultiSyncManyUselessWithLowTimeout(t *testing.T) { |
|
|
|
func TestMultiSyncManyUselessWithLowTimeout(t *testing.T) { |
|
|
|
// We're setting the timeout to very low, to increase the chance of the timeout
|
|
|
|
|
|
|
|
// being triggered. This was previously a cause of panic, when a response
|
|
|
|
|
|
|
|
// arrived simultaneously as a timeout was triggered.
|
|
|
|
|
|
|
|
defer func(old time.Duration) { requestTimeout = old }(requestTimeout) |
|
|
|
|
|
|
|
requestTimeout = time.Millisecond |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
once sync.Once |
|
|
|
once sync.Once |
|
|
|
cancel = make(chan struct{}) |
|
|
|
cancel = make(chan struct{}) |
|
|
@ -839,6 +832,11 @@ func TestMultiSyncManyUselessWithLowTimeout(t *testing.T) { |
|
|
|
mkSource("noStorage", true, false, true), |
|
|
|
mkSource("noStorage", true, false, true), |
|
|
|
mkSource("noTrie", true, true, false), |
|
|
|
mkSource("noTrie", true, true, false), |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
// We're setting the timeout to very low, to increase the chance of the timeout
|
|
|
|
|
|
|
|
// being triggered. This was previously a cause of panic, when a response
|
|
|
|
|
|
|
|
// arrived simultaneously as a timeout was triggered.
|
|
|
|
|
|
|
|
syncer.rates.OverrideTTLLimit = time.Millisecond |
|
|
|
|
|
|
|
|
|
|
|
done := checkStall(t, term) |
|
|
|
done := checkStall(t, term) |
|
|
|
if err := syncer.Sync(sourceAccountTrie.Hash(), cancel); err != nil { |
|
|
|
if err := syncer.Sync(sourceAccountTrie.Hash(), cancel); err != nil { |
|
|
|
t.Fatalf("sync failed: %v", err) |
|
|
|
t.Fatalf("sync failed: %v", err) |
|
|
@ -849,10 +847,6 @@ func TestMultiSyncManyUselessWithLowTimeout(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// TestMultiSyncManyUnresponsive contains one good peer, and many which doesn't respond at all
|
|
|
|
// TestMultiSyncManyUnresponsive contains one good peer, and many which doesn't respond at all
|
|
|
|
func TestMultiSyncManyUnresponsive(t *testing.T) { |
|
|
|
func TestMultiSyncManyUnresponsive(t *testing.T) { |
|
|
|
// We're setting the timeout to very low, to make the test run a bit faster
|
|
|
|
|
|
|
|
defer func(old time.Duration) { requestTimeout = old }(requestTimeout) |
|
|
|
|
|
|
|
requestTimeout = time.Millisecond |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
once sync.Once |
|
|
|
once sync.Once |
|
|
|
cancel = make(chan struct{}) |
|
|
|
cancel = make(chan struct{}) |
|
|
@ -889,13 +883,16 @@ func TestMultiSyncManyUnresponsive(t *testing.T) { |
|
|
|
mkSource("noStorage", true, false, true), |
|
|
|
mkSource("noStorage", true, false, true), |
|
|
|
mkSource("noTrie", true, true, false), |
|
|
|
mkSource("noTrie", true, true, false), |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
// We're setting the timeout to very low, to make the test run a bit faster
|
|
|
|
|
|
|
|
syncer.rates.OverrideTTLLimit = time.Millisecond |
|
|
|
|
|
|
|
|
|
|
|
done := checkStall(t, term) |
|
|
|
done := checkStall(t, term) |
|
|
|
if err := syncer.Sync(sourceAccountTrie.Hash(), cancel); err != nil { |
|
|
|
if err := syncer.Sync(sourceAccountTrie.Hash(), cancel); err != nil { |
|
|
|
t.Fatalf("sync failed: %v", err) |
|
|
|
t.Fatalf("sync failed: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
close(done) |
|
|
|
close(done) |
|
|
|
verifyTrie(syncer.db, sourceAccountTrie.Hash(), t) |
|
|
|
verifyTrie(syncer.db, sourceAccountTrie.Hash(), t) |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func checkStall(t *testing.T, term func()) chan struct{} { |
|
|
|
func checkStall(t *testing.T, term func()) chan struct{} { |
|
|
|
testDone := make(chan struct{}) |
|
|
|
testDone := make(chan struct{}) |
|
|
|