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