|
|
@@ -39,7 +39,7 @@ import (
|
|
|
func init() {
|
|
|
fullMaxForkAncestry = 10000
|
|
|
lightMaxForkAncestry = 10000
|
|
|
- blockCacheItems = 1024
|
|
|
+ blockCacheMaxItems = 1024
|
|
|
fsHeaderContCheck = 500 * time.Millisecond
|
|
|
}
|
|
|
|
|
|
@@ -544,7 +544,7 @@ func testCanonicalSynchronisation(t *testing.T, protocol int, mode SyncMode) {
|
|
|
defer tester.terminate()
|
|
|
|
|
|
// Create a small enough block chain to download
|
|
|
- chain := testChainBase.shorten(blockCacheItems - 15)
|
|
|
+ chain := testChainBase.shorten(blockCacheMaxItems - 15)
|
|
|
tester.newPeer("peer", protocol, chain)
|
|
|
|
|
|
// Synchronise with the peer and make sure all relevant data was retrieved
|
|
|
@@ -607,8 +607,8 @@ func testThrottling(t *testing.T, protocol int, mode SyncMode) {
|
|
|
}
|
|
|
tester.lock.Unlock()
|
|
|
|
|
|
- if cached == blockCacheItems ||
|
|
|
- cached == blockCacheItems-reorgProtHeaderDelay ||
|
|
|
+ if cached == blockCacheMaxItems ||
|
|
|
+ cached == blockCacheMaxItems-reorgProtHeaderDelay ||
|
|
|
retrieved+cached+frozen == targetBlocks+1 ||
|
|
|
retrieved+cached+frozen == targetBlocks+1-reorgProtHeaderDelay {
|
|
|
break
|
|
|
@@ -619,8 +619,8 @@ func testThrottling(t *testing.T, protocol int, mode SyncMode) {
|
|
|
tester.lock.RLock()
|
|
|
retrieved = len(tester.ownBlocks)
|
|
|
tester.lock.RUnlock()
|
|
|
- if cached != blockCacheItems && cached != blockCacheItems-reorgProtHeaderDelay && retrieved+cached+frozen != targetBlocks+1 && retrieved+cached+frozen != targetBlocks+1-reorgProtHeaderDelay {
|
|
|
- t.Fatalf("block count mismatch: have %v, want %v (owned %v, blocked %v, target %v)", cached, blockCacheItems, retrieved, frozen, targetBlocks+1)
|
|
|
+ if cached != blockCacheMaxItems && cached != blockCacheMaxItems-reorgProtHeaderDelay && retrieved+cached+frozen != targetBlocks+1 && retrieved+cached+frozen != targetBlocks+1-reorgProtHeaderDelay {
|
|
|
+ t.Fatalf("block count mismatch: have %v, want %v (owned %v, blocked %v, target %v)", cached, blockCacheMaxItems, retrieved, frozen, targetBlocks+1)
|
|
|
}
|
|
|
|
|
|
// Permit the blocked blocks to import
|
|
|
@@ -873,7 +873,7 @@ func testMultiProtoSync(t *testing.T, protocol int, mode SyncMode) {
|
|
|
defer tester.terminate()
|
|
|
|
|
|
// Create a small enough block chain to download
|
|
|
- chain := testChainBase.shorten(blockCacheItems - 15)
|
|
|
+ chain := testChainBase.shorten(blockCacheMaxItems - 15)
|
|
|
|
|
|
// Create peers of every type
|
|
|
tester.newPeer("peer 63", 63, chain)
|
|
|
@@ -965,7 +965,7 @@ func testMissingHeaderAttack(t *testing.T, protocol int, mode SyncMode) {
|
|
|
tester := newTester()
|
|
|
defer tester.terminate()
|
|
|
|
|
|
- chain := testChainBase.shorten(blockCacheItems - 15)
|
|
|
+ chain := testChainBase.shorten(blockCacheMaxItems - 15)
|
|
|
brokenChain := chain.shorten(chain.len())
|
|
|
delete(brokenChain.headerm, brokenChain.chain[brokenChain.len()/2])
|
|
|
tester.newPeer("attack", protocol, brokenChain)
|
|
|
@@ -997,7 +997,7 @@ func testShiftedHeaderAttack(t *testing.T, protocol int, mode SyncMode) {
|
|
|
tester := newTester()
|
|
|
defer tester.terminate()
|
|
|
|
|
|
- chain := testChainBase.shorten(blockCacheItems - 15)
|
|
|
+ chain := testChainBase.shorten(blockCacheMaxItems - 15)
|
|
|
|
|
|
// Attempt a full sync with an attacker feeding shifted headers
|
|
|
brokenChain := chain.shorten(chain.len())
|
|
|
@@ -1202,7 +1202,7 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
|
|
|
|
|
|
tester := newTester()
|
|
|
defer tester.terminate()
|
|
|
- chain := testChainBase.shorten(blockCacheItems - 15)
|
|
|
+ chain := testChainBase.shorten(blockCacheMaxItems - 15)
|
|
|
|
|
|
// Set a sync init hook to catch progress changes
|
|
|
starting := make(chan struct{})
|
|
|
@@ -1362,7 +1362,7 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
|
|
|
|
|
|
tester := newTester()
|
|
|
defer tester.terminate()
|
|
|
- chain := testChainBase.shorten(blockCacheItems - 15)
|
|
|
+ chain := testChainBase.shorten(blockCacheMaxItems - 15)
|
|
|
|
|
|
// Set a sync init hook to catch progress changes
|
|
|
starting := make(chan struct{})
|
|
|
@@ -1435,7 +1435,7 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
|
|
|
|
|
|
tester := newTester()
|
|
|
defer tester.terminate()
|
|
|
- chain := testChainBase.shorten(blockCacheItems - 15)
|
|
|
+ chain := testChainBase.shorten(blockCacheMaxItems - 15)
|
|
|
|
|
|
// Set a sync init hook to catch progress changes
|
|
|
starting := make(chan struct{})
|