fix tests

This commit is contained in:
wanwiset25 2024-06-28 14:23:47 +04:00
parent 829ca9f198
commit 4be4f2eeb1
13 changed files with 278 additions and 227 deletions

View file

@ -1774,10 +1774,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
return 0, events, coalescedLogs, nil return 0, events, coalescedLogs, nil
} }
func (bc *BlockChain) InsertBlock(block *types.Block) (int, error) { func (bc *BlockChain) InsertBlock(block *types.Block) error {
events, logs, err := bc.insertBlock(block) events, logs, err := bc.insertBlock(block)
bc.PostChainEvents(events, logs) bc.PostChainEvents(events, logs)
return 0, err return err
} }
func (bc *BlockChain) PrepareBlock(block *types.Block) (err error) { func (bc *BlockChain) PrepareBlock(block *types.Block) (err error) {

View file

@ -51,6 +51,7 @@ import (
"github.com/XinFinOrg/XDPoSChain/miner" "github.com/XinFinOrg/XDPoSChain/miner"
"github.com/XinFinOrg/XDPoSChain/node" "github.com/XinFinOrg/XDPoSChain/node"
"github.com/XinFinOrg/XDPoSChain/p2p" "github.com/XinFinOrg/XDPoSChain/p2p"
"github.com/XinFinOrg/XDPoSChain/p2p/enr"
"github.com/XinFinOrg/XDPoSChain/params" "github.com/XinFinOrg/XDPoSChain/params"
"github.com/XinFinOrg/XDPoSChain/rlp" "github.com/XinFinOrg/XDPoSChain/rlp"
"github.com/XinFinOrg/XDPoSChain/rpc" "github.com/XinFinOrg/XDPoSChain/rpc"

View file

@ -674,9 +674,12 @@ func TestCanonicalSynchronisation63Full(t *testing.T) { testCanonicalSynchronisa
func TestCanonicalSynchronisation63Fast(t *testing.T) { testCanonicalSynchronisation(t, 63, FastSync) } func TestCanonicalSynchronisation63Fast(t *testing.T) { testCanonicalSynchronisation(t, 63, FastSync) }
func TestCanonicalSynchronisation64Full(t *testing.T) { testCanonicalSynchronisation(t, 64, FullSync) } func TestCanonicalSynchronisation64Full(t *testing.T) { testCanonicalSynchronisation(t, 64, FullSync) }
func TestCanonicalSynchronisation64Fast(t *testing.T) { testCanonicalSynchronisation(t, 64, FastSync) } func TestCanonicalSynchronisation64Fast(t *testing.T) { testCanonicalSynchronisation(t, 64, FastSync) }
func TestCanonicalSynchronisation64Light(t *testing.T) { func TestCanonicalSynchronisation64Light(t *testing.T) {testCanonicalSynchronisation(t, 64, LightSync)}
testCanonicalSynchronisation(t, 64, LightSync) func TestCanonicalSynchronisation100Full(t *testing.T) { testCanonicalSynchronisation(t, 100, FullSync) }
} func TestCanonicalSynchronisation100Fast(t *testing.T) { testCanonicalSynchronisation(t, 100, FastSync) }
func TestCanonicalSynchronisation101Full(t *testing.T) { testCanonicalSynchronisation(t, 101, FullSync) }
func TestCanonicalSynchronisation101Fast(t *testing.T) { testCanonicalSynchronisation(t, 101, FastSync) }
func TestCanonicalSynchronisation101Light(t *testing.T) {testCanonicalSynchronisation(t, 101, LightSync)}
func testCanonicalSynchronisation(t *testing.T, protocol int, mode SyncMode) { func testCanonicalSynchronisation(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -704,6 +707,10 @@ func TestThrottling63Full(t *testing.T) { testThrottling(t, 63, FullSync) }
func TestThrottling63Fast(t *testing.T) { testThrottling(t, 63, FastSync) } func TestThrottling63Fast(t *testing.T) { testThrottling(t, 63, FastSync) }
func TestThrottling64Full(t *testing.T) { testThrottling(t, 64, FullSync) } func TestThrottling64Full(t *testing.T) { testThrottling(t, 64, FullSync) }
func TestThrottling64Fast(t *testing.T) { testThrottling(t, 64, FastSync) } func TestThrottling64Fast(t *testing.T) { testThrottling(t, 64, FastSync) }
func TestThrottling100Full(t *testing.T) { testThrottling(t, 100, FullSync) }
func TestThrottling100Fast(t *testing.T) { testThrottling(t, 100, FastSync) }
func TestThrottling101Full(t *testing.T) { testThrottling(t, 101, FullSync) }
func TestThrottling101Fast(t *testing.T) { testThrottling(t, 101, FastSync) }
func testThrottling(t *testing.T, protocol int, mode SyncMode) { func testThrottling(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -791,6 +798,11 @@ func TestForkedSync63Fast(t *testing.T) { testForkedSync(t, 63, FastSync) }
func TestForkedSync64Full(t *testing.T) { testForkedSync(t, 64, FullSync) } func TestForkedSync64Full(t *testing.T) { testForkedSync(t, 64, FullSync) }
func TestForkedSync64Fast(t *testing.T) { testForkedSync(t, 64, FastSync) } func TestForkedSync64Fast(t *testing.T) { testForkedSync(t, 64, FastSync) }
func TestForkedSync64Light(t *testing.T) { testForkedSync(t, 64, LightSync) } func TestForkedSync64Light(t *testing.T) { testForkedSync(t, 64, LightSync) }
func TestForkedSync100Full(t *testing.T) { testForkedSync(t, 100, FullSync) }
func TestForkedSync100Fast(t *testing.T) { testForkedSync(t, 100, FastSync) }
func TestForkedSync101Full(t *testing.T) { testForkedSync(t, 101, FullSync) }
func TestForkedSync101Fast(t *testing.T) { testForkedSync(t, 101, FastSync) }
func TestForkedSync101Light(t *testing.T) { testForkedSync(t, 101, LightSync) }
func testForkedSync(t *testing.T, protocol int, mode SyncMode) { func testForkedSync(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -826,6 +838,11 @@ func TestHeavyForkedSync63Fast(t *testing.T) { testHeavyForkedSync(t, 63, FastS
func TestHeavyForkedSync64Full(t *testing.T) { testHeavyForkedSync(t, 64, FullSync) } func TestHeavyForkedSync64Full(t *testing.T) { testHeavyForkedSync(t, 64, FullSync) }
func TestHeavyForkedSync64Fast(t *testing.T) { testHeavyForkedSync(t, 64, FastSync) } func TestHeavyForkedSync64Fast(t *testing.T) { testHeavyForkedSync(t, 64, FastSync) }
func TestHeavyForkedSync64Light(t *testing.T) { testHeavyForkedSync(t, 64, LightSync) } func TestHeavyForkedSync64Light(t *testing.T) { testHeavyForkedSync(t, 64, LightSync) }
func TestHeavyForkedSync100Full(t *testing.T) { testHeavyForkedSync(t, 100, FullSync) }
func TestHeavyForkedSync100Fast(t *testing.T) { testHeavyForkedSync(t, 100, FastSync) }
func TestHeavyForkedSync101Full(t *testing.T) { testHeavyForkedSync(t, 101, FullSync) }
func TestHeavyForkedSync101Fast(t *testing.T) { testHeavyForkedSync(t, 101, FastSync) }
func TestHeavyForkedSync101Light(t *testing.T) { testHeavyForkedSync(t, 101, LightSync) }
func testHeavyForkedSync(t *testing.T, protocol int, mode SyncMode) { func testHeavyForkedSync(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -862,6 +879,11 @@ func TestBoundedForkedSync63Fast(t *testing.T) { testBoundedForkedSync(t, 63, F
func TestBoundedForkedSync64Full(t *testing.T) { testBoundedForkedSync(t, 64, FullSync) } func TestBoundedForkedSync64Full(t *testing.T) { testBoundedForkedSync(t, 64, FullSync) }
func TestBoundedForkedSync64Fast(t *testing.T) { testBoundedForkedSync(t, 64, FastSync) } func TestBoundedForkedSync64Fast(t *testing.T) { testBoundedForkedSync(t, 64, FastSync) }
func TestBoundedForkedSync64Light(t *testing.T) { testBoundedForkedSync(t, 64, LightSync) } func TestBoundedForkedSync64Light(t *testing.T) { testBoundedForkedSync(t, 64, LightSync) }
func TestBoundedForkedSync100Full(t *testing.T) { testBoundedForkedSync(t, 100, FullSync) }
func TestBoundedForkedSync100Fast(t *testing.T) { testBoundedForkedSync(t, 100, FastSync) }
func TestBoundedForkedSync101Full(t *testing.T) { testBoundedForkedSync(t, 101, FullSync) }
func TestBoundedForkedSync101Fast(t *testing.T) { testBoundedForkedSync(t, 101, FastSync) }
func TestBoundedForkedSync101Light(t *testing.T) { testBoundedForkedSync(t, 101, LightSync) }
func testBoundedForkedSync(t *testing.T, protocol int, mode SyncMode) { func testBoundedForkedSync(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -900,6 +922,9 @@ func TestBoundedHeavyForkedSync64Light(t *testing.T) { testBoundedHeavyForkedSyn
func TestBoundedHeavyForkedSync100Full(t *testing.T) { testBoundedHeavyForkedSync(t, 100, FullSync) } func TestBoundedHeavyForkedSync100Full(t *testing.T) { testBoundedHeavyForkedSync(t, 100, FullSync) }
func TestBoundedHeavyForkedSync100Fast(t *testing.T) { testBoundedHeavyForkedSync(t, 100, FastSync) } func TestBoundedHeavyForkedSync100Fast(t *testing.T) { testBoundedHeavyForkedSync(t, 100, FastSync) }
func TestBoundedHeavyForkedSync100Light(t *testing.T) { testBoundedHeavyForkedSync(t, 100, LightSync) } func TestBoundedHeavyForkedSync100Light(t *testing.T) { testBoundedHeavyForkedSync(t, 100, LightSync) }
func TestBoundedHeavyForkedSync101Full(t *testing.T) { testBoundedHeavyForkedSync(t, 101, FullSync) }
func TestBoundedHeavyForkedSync101Fast(t *testing.T) { testBoundedHeavyForkedSync(t, 101, FastSync) }
func TestBoundedHeavyForkedSync101Light(t *testing.T) { testBoundedHeavyForkedSync(t, 101, LightSync) }
func testBoundedHeavyForkedSync(t *testing.T, protocol int, mode SyncMode) { func testBoundedHeavyForkedSync(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -973,6 +998,9 @@ func TestCancel64Light(t *testing.T) { testCancel(t, 64, LightSync) }
func TestCancel100Full(t *testing.T) { testCancel(t, 100, FullSync) } func TestCancel100Full(t *testing.T) { testCancel(t, 100, FullSync) }
func TestCancel100Fast(t *testing.T) { testCancel(t, 100, FastSync) } func TestCancel100Fast(t *testing.T) { testCancel(t, 100, FastSync) }
func TestCancel100Light(t *testing.T) { testCancel(t, 100, LightSync) } func TestCancel100Light(t *testing.T) { testCancel(t, 100, LightSync) }
func TestCancel101Full(t *testing.T) { testCancel(t, 101, FullSync) }
func TestCancel101Fast(t *testing.T) { testCancel(t, 101, FastSync) }
func TestCancel101Light(t *testing.T) { testCancel(t, 101, LightSync) }
func testCancel(t *testing.T, protocol int, mode SyncMode) { func testCancel(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1017,6 +1045,9 @@ func TestMultiSynchronisation64Light(t *testing.T) { testMultiSynchronisation(t,
func TestMultiSynchronisation100Full(t *testing.T) { testMultiSynchronisation(t, 100, FullSync) } func TestMultiSynchronisation100Full(t *testing.T) { testMultiSynchronisation(t, 100, FullSync) }
func TestMultiSynchronisation100Fast(t *testing.T) { testMultiSynchronisation(t, 100, FastSync) } func TestMultiSynchronisation100Fast(t *testing.T) { testMultiSynchronisation(t, 100, FastSync) }
func TestMultiSynchronisation100Light(t *testing.T) { testMultiSynchronisation(t, 100, LightSync) } func TestMultiSynchronisation100Light(t *testing.T) { testMultiSynchronisation(t, 100, LightSync) }
func TestMultiSynchronisation101Full(t *testing.T) { testMultiSynchronisation(t, 101, FullSync) }
func TestMultiSynchronisation101Fast(t *testing.T) { testMultiSynchronisation(t, 101, FastSync) }
func TestMultiSynchronisation101Light(t *testing.T) { testMultiSynchronisation(t, 101, LightSync) }
func testMultiSynchronisation(t *testing.T, protocol int, mode SyncMode) { func testMultiSynchronisation(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1050,6 +1081,9 @@ func TestMultiProtoSynchronisation64Light(t *testing.T) { testMultiProtoSync(t,
func TestMultiProtoSynchronisation100Full(t *testing.T) { testMultiProtoSync(t, 100, FullSync) } func TestMultiProtoSynchronisation100Full(t *testing.T) { testMultiProtoSync(t, 100, FullSync) }
func TestMultiProtoSynchronisation100Fast(t *testing.T) { testMultiProtoSync(t, 100, FastSync) } func TestMultiProtoSynchronisation100Fast(t *testing.T) { testMultiProtoSync(t, 100, FastSync) }
func TestMultiProtoSynchronisation100Light(t *testing.T) { testMultiProtoSync(t, 100, LightSync) } func TestMultiProtoSynchronisation100Light(t *testing.T) { testMultiProtoSync(t, 100, LightSync) }
func TestMultiProtoSynchronisation101Full(t *testing.T) { testMultiProtoSync(t, 101, FullSync) }
func TestMultiProtoSynchronisation101Fast(t *testing.T) { testMultiProtoSync(t, 101, FastSync) }
func TestMultiProtoSynchronisation101Light(t *testing.T) { testMultiProtoSync(t, 101, LightSync) }
func testMultiProtoSync(t *testing.T, protocol int, mode SyncMode) { func testMultiProtoSync(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1066,6 +1100,7 @@ func testMultiProtoSync(t *testing.T, protocol int, mode SyncMode) {
tester.newPeer("peer 63", 63, hashes, headers, blocks, receipts) tester.newPeer("peer 63", 63, hashes, headers, blocks, receipts)
tester.newPeer("peer 64", 64, hashes, headers, blocks, receipts) tester.newPeer("peer 64", 64, hashes, headers, blocks, receipts)
tester.newPeer("peer 100", 100, hashes, headers, blocks, receipts) tester.newPeer("peer 100", 100, hashes, headers, blocks, receipts)
tester.newPeer("peer 101", 101, hashes, headers, blocks, receipts)
// Synchronise with the requested peer and make sure all blocks were retrieved // Synchronise with the requested peer and make sure all blocks were retrieved
if err := tester.sync(fmt.Sprintf("peer %d", protocol), nil, mode); err != nil { if err := tester.sync(fmt.Sprintf("peer %d", protocol), nil, mode); err != nil {
@ -1074,7 +1109,7 @@ func testMultiProtoSync(t *testing.T, protocol int, mode SyncMode) {
assertOwnChain(t, tester, targetBlocks+1) assertOwnChain(t, tester, targetBlocks+1)
// Check that no peers have been dropped off // Check that no peers have been dropped off
for _, version := range []int{62, 63, 64, 100} { for _, version := range []int{62, 63, 64, 100, 101} {
peer := fmt.Sprintf("peer %d", version) peer := fmt.Sprintf("peer %d", version)
if _, ok := tester.peerHashes[peer]; !ok { if _, ok := tester.peerHashes[peer]; !ok {
t.Errorf("%s dropped", peer) t.Errorf("%s dropped", peer)
@ -1093,6 +1128,9 @@ func TestEmptyShortCircuit64Light(t *testing.T) { testEmptyShortCircuit(t, 64, L
func TestEmptyShortCircuit100Full(t *testing.T) { testEmptyShortCircuit(t, 100, FullSync) } func TestEmptyShortCircuit100Full(t *testing.T) { testEmptyShortCircuit(t, 100, FullSync) }
func TestEmptyShortCircuit100Fast(t *testing.T) { testEmptyShortCircuit(t, 100, FastSync) } func TestEmptyShortCircuit100Fast(t *testing.T) { testEmptyShortCircuit(t, 100, FastSync) }
func TestEmptyShortCircuit100Light(t *testing.T) { testEmptyShortCircuit(t, 100, LightSync) } func TestEmptyShortCircuit100Light(t *testing.T) { testEmptyShortCircuit(t, 100, LightSync) }
func TestEmptyShortCircuit101Full(t *testing.T) { testEmptyShortCircuit(t, 101, FullSync) }
func TestEmptyShortCircuit101Fast(t *testing.T) { testEmptyShortCircuit(t, 101, FastSync) }
func TestEmptyShortCircuit101Light(t *testing.T) { testEmptyShortCircuit(t, 101, LightSync) }
func testEmptyShortCircuit(t *testing.T, protocol int, mode SyncMode) { func testEmptyShortCircuit(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1151,6 +1189,9 @@ func TestMissingHeaderAttack64Light(t *testing.T) { testMissingHeaderAttack(t, 6
func TestMissingHeaderAttack100Full(t *testing.T) { testMissingHeaderAttack(t, 100, FullSync) } func TestMissingHeaderAttack100Full(t *testing.T) { testMissingHeaderAttack(t, 100, FullSync) }
func TestMissingHeaderAttack100Fast(t *testing.T) { testMissingHeaderAttack(t, 100, FastSync) } func TestMissingHeaderAttack100Fast(t *testing.T) { testMissingHeaderAttack(t, 100, FastSync) }
func TestMissingHeaderAttack100Light(t *testing.T) { testMissingHeaderAttack(t, 100, LightSync) } func TestMissingHeaderAttack100Light(t *testing.T) { testMissingHeaderAttack(t, 100, LightSync) }
func TestMissingHeaderAttack101Full(t *testing.T) { testMissingHeaderAttack(t, 101, FullSync) }
func TestMissingHeaderAttack101Fast(t *testing.T) { testMissingHeaderAttack(t, 101, FastSync) }
func TestMissingHeaderAttack101Light(t *testing.T) { testMissingHeaderAttack(t, 101, LightSync) }
func testMissingHeaderAttack(t *testing.T, protocol int, mode SyncMode) { func testMissingHeaderAttack(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1189,6 +1230,9 @@ func TestShiftedHeaderAttack64Light(t *testing.T) { testShiftedHeaderAttack(t, 6
func TestShiftedHeaderAttack100Full(t *testing.T) { testShiftedHeaderAttack(t, 100, FullSync) } func TestShiftedHeaderAttack100Full(t *testing.T) { testShiftedHeaderAttack(t, 100, FullSync) }
func TestShiftedHeaderAttack100Fast(t *testing.T) { testShiftedHeaderAttack(t, 100, FastSync) } func TestShiftedHeaderAttack100Fast(t *testing.T) { testShiftedHeaderAttack(t, 100, FastSync) }
func TestShiftedHeaderAttack100Light(t *testing.T) { testShiftedHeaderAttack(t, 100, LightSync) } func TestShiftedHeaderAttack100Light(t *testing.T) { testShiftedHeaderAttack(t, 100, LightSync) }
func TestShiftedHeaderAttack101Full(t *testing.T) { testShiftedHeaderAttack(t, 101, FullSync) }
func TestShiftedHeaderAttack101Fast(t *testing.T) { testShiftedHeaderAttack(t, 101, FastSync) }
func TestShiftedHeaderAttack101Light(t *testing.T) { testShiftedHeaderAttack(t, 101, LightSync) }
func testShiftedHeaderAttack(t *testing.T, protocol int, mode SyncMode) { func testShiftedHeaderAttack(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1225,6 +1269,8 @@ func TestInvalidHeaderRollback64Fast(t *testing.T) { testInvalidHeaderRollback(
func TestInvalidHeaderRollback64Light(t *testing.T) { testInvalidHeaderRollback(t, 64, LightSync) } func TestInvalidHeaderRollback64Light(t *testing.T) { testInvalidHeaderRollback(t, 64, LightSync) }
func TestInvalidHeaderRollback100Fast(t *testing.T) { testInvalidHeaderRollback(t, 100, FastSync) } func TestInvalidHeaderRollback100Fast(t *testing.T) { testInvalidHeaderRollback(t, 100, FastSync) }
func TestInvalidHeaderRollback100Light(t *testing.T) { testInvalidHeaderRollback(t, 100, LightSync) } func TestInvalidHeaderRollback100Light(t *testing.T) { testInvalidHeaderRollback(t, 100, LightSync) }
func TestInvalidHeaderRollback101Fast(t *testing.T) { testInvalidHeaderRollback(t, 101, FastSync) }
func TestInvalidHeaderRollback101Light(t *testing.T) { testInvalidHeaderRollback(t, 101, LightSync) }
func testInvalidHeaderRollback(t *testing.T, protocol int, mode SyncMode) { func testInvalidHeaderRollback(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1320,6 +1366,9 @@ func TestHighTDStarvationAttack64Light(t *testing.T) { testHighTDStarvationAttac
func TestHighTDStarvationAttack100Full(t *testing.T) { testHighTDStarvationAttack(t, 100, FullSync) } func TestHighTDStarvationAttack100Full(t *testing.T) { testHighTDStarvationAttack(t, 100, FullSync) }
func TestHighTDStarvationAttack100Fast(t *testing.T) { testHighTDStarvationAttack(t, 100, FastSync) } func TestHighTDStarvationAttack100Fast(t *testing.T) { testHighTDStarvationAttack(t, 100, FastSync) }
func TestHighTDStarvationAttack100Light(t *testing.T) { testHighTDStarvationAttack(t, 100, LightSync) } func TestHighTDStarvationAttack100Light(t *testing.T) { testHighTDStarvationAttack(t, 100, LightSync) }
func TestHighTDStarvationAttack101Full(t *testing.T) { testHighTDStarvationAttack(t, 101, FullSync) }
func TestHighTDStarvationAttack101Fast(t *testing.T) { testHighTDStarvationAttack(t, 101, FastSync) }
func TestHighTDStarvationAttack101Light(t *testing.T) { testHighTDStarvationAttack(t, 101, LightSync) }
func testHighTDStarvationAttack(t *testing.T, protocol int, mode SyncMode) { func testHighTDStarvationAttack(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1340,6 +1389,7 @@ func TestBlockHeaderAttackerDropping62(t *testing.T) { testBlockHeaderAttackerDr
func TestBlockHeaderAttackerDropping63(t *testing.T) { testBlockHeaderAttackerDropping(t, 63) } func TestBlockHeaderAttackerDropping63(t *testing.T) { testBlockHeaderAttackerDropping(t, 63) }
func TestBlockHeaderAttackerDropping64(t *testing.T) { testBlockHeaderAttackerDropping(t, 64) } func TestBlockHeaderAttackerDropping64(t *testing.T) { testBlockHeaderAttackerDropping(t, 64) }
func TestBlockHeaderAttackerDropping100(t *testing.T) { testBlockHeaderAttackerDropping(t, 100) } func TestBlockHeaderAttackerDropping100(t *testing.T) { testBlockHeaderAttackerDropping(t, 100) }
func TestBlockHeaderAttackerDropping101(t *testing.T) { testBlockHeaderAttackerDropping(t, 101) }
func testBlockHeaderAttackerDropping(t *testing.T, protocol int) { func testBlockHeaderAttackerDropping(t *testing.T, protocol int) {
t.Parallel() t.Parallel()
@ -1404,6 +1454,9 @@ func TestSyncProgress64Light(t *testing.T) { testSyncProgress(t, 64, LightSync)
func TestSyncProgress100Full(t *testing.T) { testSyncProgress(t, 100, FullSync) } func TestSyncProgress100Full(t *testing.T) { testSyncProgress(t, 100, FullSync) }
func TestSyncProgress100Fast(t *testing.T) { testSyncProgress(t, 100, FastSync) } func TestSyncProgress100Fast(t *testing.T) { testSyncProgress(t, 100, FastSync) }
func TestSyncProgress100Light(t *testing.T) { testSyncProgress(t, 100, LightSync) } func TestSyncProgress100Light(t *testing.T) { testSyncProgress(t, 100, LightSync) }
func TestSyncProgress101Full(t *testing.T) { testSyncProgress(t, 101, FullSync) }
func TestSyncProgress101Fast(t *testing.T) { testSyncProgress(t, 101, FastSync) }
func TestSyncProgress101Light(t *testing.T) { testSyncProgress(t, 101, LightSync) }
func testSyncProgress(t *testing.T, protocol int, mode SyncMode) { func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1480,6 +1533,9 @@ func TestForkedSyncProgress64Light(t *testing.T) { testForkedSyncProgress(t, 64,
func TestForkedSyncProgress100Full(t *testing.T) { testForkedSyncProgress(t, 100, FullSync) } func TestForkedSyncProgress100Full(t *testing.T) { testForkedSyncProgress(t, 100, FullSync) }
func TestForkedSyncProgress100Fast(t *testing.T) { testForkedSyncProgress(t, 100, FastSync) } func TestForkedSyncProgress100Fast(t *testing.T) { testForkedSyncProgress(t, 100, FastSync) }
func TestForkedSyncProgress100Light(t *testing.T) { testForkedSyncProgress(t, 100, LightSync) } func TestForkedSyncProgress100Light(t *testing.T) { testForkedSyncProgress(t, 100, LightSync) }
func TestForkedSyncProgress101Full(t *testing.T) { testForkedSyncProgress(t, 101, FullSync) }
func TestForkedSyncProgress101Fast(t *testing.T) { testForkedSyncProgress(t, 101, FastSync) }
func TestForkedSyncProgress101Light(t *testing.T) { testForkedSyncProgress(t, 101, LightSync) }
func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) { func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1559,6 +1615,9 @@ func TestFailedSyncProgress64Light(t *testing.T) { testFailedSyncProgress(t, 64,
func TestFailedSyncProgress100Full(t *testing.T) { testFailedSyncProgress(t, 100, FullSync) } func TestFailedSyncProgress100Full(t *testing.T) { testFailedSyncProgress(t, 100, FullSync) }
func TestFailedSyncProgress100Fast(t *testing.T) { testFailedSyncProgress(t, 100, FastSync) } func TestFailedSyncProgress100Fast(t *testing.T) { testFailedSyncProgress(t, 100, FastSync) }
func TestFailedSyncProgress100Light(t *testing.T) { testFailedSyncProgress(t, 100, LightSync) } func TestFailedSyncProgress100Light(t *testing.T) { testFailedSyncProgress(t, 100, LightSync) }
func TestFailedSyncProgress101Full(t *testing.T) { testFailedSyncProgress(t, 101, FullSync) }
func TestFailedSyncProgress101Fast(t *testing.T) { testFailedSyncProgress(t, 101, FastSync) }
func TestFailedSyncProgress101Light(t *testing.T) { testFailedSyncProgress(t, 101, LightSync) }
func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) { func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1639,6 +1698,9 @@ func TestFakedSyncProgress64Light(t *testing.T) { testFakedSyncProgress(t, 64, L
func TestFakedSyncProgress100Full(t *testing.T) { testFakedSyncProgress(t, 100, FullSync) } func TestFakedSyncProgress100Full(t *testing.T) { testFakedSyncProgress(t, 100, FullSync) }
func TestFakedSyncProgress100Fast(t *testing.T) { testFakedSyncProgress(t, 100, FastSync) } func TestFakedSyncProgress100Fast(t *testing.T) { testFakedSyncProgress(t, 100, FastSync) }
func TestFakedSyncProgress100Light(t *testing.T) { testFakedSyncProgress(t, 100, LightSync) } func TestFakedSyncProgress100Light(t *testing.T) { testFakedSyncProgress(t, 100, LightSync) }
func TestFakedSyncProgress101Full(t *testing.T) { testFakedSyncProgress(t, 101, FullSync) }
func TestFakedSyncProgress101Fast(t *testing.T) { testFakedSyncProgress(t, 101, FastSync) }
func TestFakedSyncProgress101Light(t *testing.T) { testFakedSyncProgress(t, 101, LightSync) }
func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) { func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
t.Parallel() t.Parallel()
@ -1729,6 +1791,9 @@ func TestDeliverHeadersHang(t *testing.T) {
{100, FullSync}, {100, FullSync},
{100, FastSync}, {100, FastSync},
{100, LightSync}, {100, LightSync},
{101, FullSync},
{101, FastSync},
{101, LightSync},
} }
for _, tc := range testCases { for _, tc := range testCases {
t.Run(fmt.Sprintf("protocol %d mode %v", tc.protocol, tc.syncMode), func(t *testing.T) { t.Run(fmt.Sprintf("protocol %d mode %v", tc.protocol, tc.syncMode), func(t *testing.T) {

View file

@ -94,7 +94,7 @@ type chainHeightFn func() uint64
type chainInsertFn func(types.Blocks) (int, error) type chainInsertFn func(types.Blocks) (int, error)
// blockInsertFn is a callback type to insert a batch of blocks into the local chain. // blockInsertFn is a callback type to insert a batch of blocks into the local chain.
type blockInsertFn func(types.Block) (int, error) type blockInsertFn func(types.Block) (error)
type blockPrepareFn func(block *types.Block) error type blockPrepareFn func(block *types.Block) error
@ -777,7 +777,7 @@ func (f *BlockFetcher) insert(peer string, block *types.Block) {
return return
} }
// Run the actual import and log any issues // Run the actual import and log any issues
if _, err := f.insertBlock(*block); err != nil { if err := f.insertBlock(*block); err != nil {
log.Warn("Propagated block import failed", "peer", peer, "number", block.Number(), "hash", hash, "err", err) log.Warn("Propagated block import failed", "peer", peer, "number", block.Number(), "hash", hash, "err", err)
return return
} }

View file

@ -93,7 +93,7 @@ func newTester() *fetcherTester {
blocks: map[common.Hash]*types.Block{genesis.Hash(): genesis}, blocks: map[common.Hash]*types.Block{genesis.Hash(): genesis},
drops: make(map[string]bool), drops: make(map[string]bool),
} }
tester.fetcher = NewBlockFetcher(tester.getBlock, tester.verifyHeader, tester.handleProposedBlock, tester.broadcastBlock, tester.chainHeight, tester.insertChain, tester.prepareBlock, tester.dropPeer) tester.fetcher = NewBlockFetcher(tester.getBlock, tester.verifyHeader, tester.handleProposedBlock, tester.broadcastBlock, tester.chainHeight, tester.insertBlock, tester.prepareBlock, tester.dropPeer)
tester.fetcher.Start() tester.fetcher.Start()
return tester return tester
@ -150,7 +150,7 @@ func (f *fetcherTester) insertChain(blocks types.Blocks) (int, error) {
} }
// insertBlock injects a new blocks into the simulated chain. // insertBlock injects a new blocks into the simulated chain.
func (f *fetcherTester) insertBlock(block *types.Block) error { func (f *fetcherTester) insertBlock(block types.Block) error {
f.lock.Lock() f.lock.Lock()
defer f.lock.Unlock() defer f.lock.Unlock()
@ -164,7 +164,7 @@ func (f *fetcherTester) insertBlock(block *types.Block) error {
} }
// Otherwise build our current chain // Otherwise build our current chain
f.hashes = append(f.hashes, block.Hash()) f.hashes = append(f.hashes, block.Hash())
f.blocks[block.Hash()] = block f.blocks[block.Hash()] = &block
return nil return nil
} }
@ -315,6 +315,7 @@ func TestSequentialAnnouncements62(t *testing.T) { testSequentialAnnouncements(t
func TestSequentialAnnouncements63(t *testing.T) { testSequentialAnnouncements(t, 63) } func TestSequentialAnnouncements63(t *testing.T) { testSequentialAnnouncements(t, 63) }
func TestSequentialAnnouncements64(t *testing.T) { testSequentialAnnouncements(t, 64) } func TestSequentialAnnouncements64(t *testing.T) { testSequentialAnnouncements(t, 64) }
func TestSequentialAnnouncements100(t *testing.T) { testSequentialAnnouncements(t, 100) } func TestSequentialAnnouncements100(t *testing.T) { testSequentialAnnouncements(t, 100) }
func TestSequentialAnnouncements101(t *testing.T) { testSequentialAnnouncements(t, 101) }
func testSequentialAnnouncements(t *testing.T, protocol int) { func testSequentialAnnouncements(t *testing.T, protocol int) {
// Create a chain of blocks to import // Create a chain of blocks to import
@ -351,6 +352,7 @@ func TestConcurrentAnnouncements62(t *testing.T) { testConcurrentAnnouncements(t
func TestConcurrentAnnouncements63(t *testing.T) { testConcurrentAnnouncements(t, 63) } func TestConcurrentAnnouncements63(t *testing.T) { testConcurrentAnnouncements(t, 63) }
func TestConcurrentAnnouncements64(t *testing.T) { testConcurrentAnnouncements(t, 64) } func TestConcurrentAnnouncements64(t *testing.T) { testConcurrentAnnouncements(t, 64) }
func TestConcurrentAnnouncements100(t *testing.T) { testConcurrentAnnouncements(t, 100) } func TestConcurrentAnnouncements100(t *testing.T) { testConcurrentAnnouncements(t, 100) }
func TestConcurrentAnnouncements101(t *testing.T) { testConcurrentAnnouncements(t, 101) }
func testConcurrentAnnouncements(t *testing.T, protocol int) { func testConcurrentAnnouncements(t *testing.T, protocol int) {
// Create a chain of blocks to import // Create a chain of blocks to import
@ -400,6 +402,7 @@ func TestOverlappingAnnouncements62(t *testing.T) { testOverlappingAnnouncements
func TestOverlappingAnnouncements63(t *testing.T) { testOverlappingAnnouncements(t, 63) } func TestOverlappingAnnouncements63(t *testing.T) { testOverlappingAnnouncements(t, 63) }
func TestOverlappingAnnouncements64(t *testing.T) { testOverlappingAnnouncements(t, 64) } func TestOverlappingAnnouncements64(t *testing.T) { testOverlappingAnnouncements(t, 64) }
func TestOverlappingAnnouncements100(t *testing.T) { testOverlappingAnnouncements(t, 100) } func TestOverlappingAnnouncements100(t *testing.T) { testOverlappingAnnouncements(t, 100) }
func TestOverlappingAnnouncements101(t *testing.T) { testOverlappingAnnouncements(t, 101) }
func testOverlappingAnnouncements(t *testing.T, protocol int) { func testOverlappingAnnouncements(t *testing.T, protocol int) {
// Create a chain of blocks to import // Create a chain of blocks to import
@ -438,6 +441,7 @@ func TestPendingDeduplication62(t *testing.T) { testPendingDeduplication(t, 62)
func TestPendingDeduplication63(t *testing.T) { testPendingDeduplication(t, 63) } func TestPendingDeduplication63(t *testing.T) { testPendingDeduplication(t, 63) }
func TestPendingDeduplication64(t *testing.T) { testPendingDeduplication(t, 64) } func TestPendingDeduplication64(t *testing.T) { testPendingDeduplication(t, 64) }
func TestPendingDeduplication100(t *testing.T) { testPendingDeduplication(t, 100) } func TestPendingDeduplication100(t *testing.T) { testPendingDeduplication(t, 100) }
func TestPendingDeduplication101(t *testing.T) { testPendingDeduplication(t, 101) }
func testPendingDeduplication(t *testing.T, protocol int) { func testPendingDeduplication(t *testing.T, protocol int) {
// Create a hash and corresponding block // Create a hash and corresponding block
@ -482,6 +486,7 @@ func TestRandomArrivalImport62(t *testing.T) { testRandomArrivalImport(t, 62) }
func TestRandomArrivalImport63(t *testing.T) { testRandomArrivalImport(t, 63) } func TestRandomArrivalImport63(t *testing.T) { testRandomArrivalImport(t, 63) }
func TestRandomArrivalImport64(t *testing.T) { testRandomArrivalImport(t, 64) } func TestRandomArrivalImport64(t *testing.T) { testRandomArrivalImport(t, 64) }
func TestRandomArrivalImport100(t *testing.T) { testRandomArrivalImport(t, 100) } func TestRandomArrivalImport100(t *testing.T) { testRandomArrivalImport(t, 100) }
func TestRandomArrivalImport101(t *testing.T) { testRandomArrivalImport(t, 101) }
func testRandomArrivalImport(t *testing.T, protocol int) { func testRandomArrivalImport(t *testing.T, protocol int) {
// Create a chain of blocks to import, and choose one to delay // Create a chain of blocks to import, and choose one to delay
@ -517,6 +522,7 @@ func TestQueueGapFill62(t *testing.T) { testQueueGapFill(t, 62) }
func TestQueueGapFill63(t *testing.T) { testQueueGapFill(t, 63) } func TestQueueGapFill63(t *testing.T) { testQueueGapFill(t, 63) }
func TestQueueGapFill64(t *testing.T) { testQueueGapFill(t, 64) } func TestQueueGapFill64(t *testing.T) { testQueueGapFill(t, 64) }
func TestQueueGapFill100(t *testing.T) { testQueueGapFill(t, 100) } func TestQueueGapFill100(t *testing.T) { testQueueGapFill(t, 100) }
func TestQueueGapFill101(t *testing.T) { testQueueGapFill(t, 101) }
func testQueueGapFill(t *testing.T, protocol int) { func testQueueGapFill(t *testing.T, protocol int) {
// Create a chain of blocks to import, and choose one to not announce at all // Create a chain of blocks to import, and choose one to not announce at all
@ -552,6 +558,7 @@ func TestImportDeduplication62(t *testing.T) { testImportDeduplication(t, 62) }
func TestImportDeduplication63(t *testing.T) { testImportDeduplication(t, 63) } func TestImportDeduplication63(t *testing.T) { testImportDeduplication(t, 63) }
func TestImportDeduplication64(t *testing.T) { testImportDeduplication(t, 64) } func TestImportDeduplication64(t *testing.T) { testImportDeduplication(t, 64) }
func TestImportDeduplication100(t *testing.T) { testImportDeduplication(t, 100) } func TestImportDeduplication100(t *testing.T) { testImportDeduplication(t, 100) }
func TestImportDeduplication101(t *testing.T) { testImportDeduplication(t, 101) }
func testImportDeduplication(t *testing.T, protocol int) { func testImportDeduplication(t *testing.T, protocol int) {
// Create two blocks to import (one for duplication, the other for stalling) // Create two blocks to import (one for duplication, the other for stalling)
@ -563,9 +570,9 @@ func testImportDeduplication(t *testing.T, protocol int) {
bodyFetcher := tester.makeBodyFetcher("valid", blocks, 0) bodyFetcher := tester.makeBodyFetcher("valid", blocks, 0)
counter := uint32(0) counter := uint32(0)
tester.fetcher.insertChain = func(blocks types.Blocks) (int, error) { tester.fetcher.insertBlock = func(block types.Block) error {
atomic.AddUint32(&counter, uint32(1)) atomic.AddUint32(&counter, uint32(1))
return tester.insertChain(blocks) return tester.insertBlock(block)
} }
// Instrument the fetching and imported events // Instrument the fetching and imported events
fetching := make(chan []common.Hash) fetching := make(chan []common.Hash)
@ -631,6 +638,7 @@ func TestDistantAnnouncementDiscarding62(t *testing.T) { testDistantAnnouncement
func TestDistantAnnouncementDiscarding63(t *testing.T) { testDistantAnnouncementDiscarding(t, 63) } func TestDistantAnnouncementDiscarding63(t *testing.T) { testDistantAnnouncementDiscarding(t, 63) }
func TestDistantAnnouncementDiscarding64(t *testing.T) { testDistantAnnouncementDiscarding(t, 64) } func TestDistantAnnouncementDiscarding64(t *testing.T) { testDistantAnnouncementDiscarding(t, 64) }
func TestDistantAnnouncementDiscarding100(t *testing.T) { testDistantAnnouncementDiscarding(t, 100) } func TestDistantAnnouncementDiscarding100(t *testing.T) { testDistantAnnouncementDiscarding(t, 100) }
func TestDistantAnnouncementDiscarding101(t *testing.T) { testDistantAnnouncementDiscarding(t, 101) }
func testDistantAnnouncementDiscarding(t *testing.T, protocol int) { func testDistantAnnouncementDiscarding(t *testing.T, protocol int) {
// Create a long chain to import and define the discard boundaries // Create a long chain to import and define the discard boundaries
@ -675,6 +683,7 @@ func TestInvalidNumberAnnouncement62(t *testing.T) { testInvalidNumberAnnounceme
func TestInvalidNumberAnnouncement63(t *testing.T) { testInvalidNumberAnnouncement(t, 63) } func TestInvalidNumberAnnouncement63(t *testing.T) { testInvalidNumberAnnouncement(t, 63) }
func TestInvalidNumberAnnouncement64(t *testing.T) { testInvalidNumberAnnouncement(t, 64) } func TestInvalidNumberAnnouncement64(t *testing.T) { testInvalidNumberAnnouncement(t, 64) }
func TestInvalidNumberAnnouncement100(t *testing.T) { testInvalidNumberAnnouncement(t, 100) } func TestInvalidNumberAnnouncement100(t *testing.T) { testInvalidNumberAnnouncement(t, 100) }
func TestInvalidNumberAnnouncement101(t *testing.T) { testInvalidNumberAnnouncement(t, 101) }
func testInvalidNumberAnnouncement(t *testing.T, protocol int) { func testInvalidNumberAnnouncement(t *testing.T, protocol int) {
// Create a single block to import and check numbers against // Create a single block to import and check numbers against
@ -723,7 +732,8 @@ func testInvalidNumberAnnouncement(t *testing.T, protocol int) {
func TestEmptyBlockShortCircuit62(t *testing.T) { testEmptyBlockShortCircuit(t, 62) } func TestEmptyBlockShortCircuit62(t *testing.T) { testEmptyBlockShortCircuit(t, 62) }
func TestEmptyBlockShortCircuit63(t *testing.T) { testEmptyBlockShortCircuit(t, 63) } func TestEmptyBlockShortCircuit63(t *testing.T) { testEmptyBlockShortCircuit(t, 63) }
func TestEmptyBlockShortCircuit64(t *testing.T) { testEmptyBlockShortCircuit(t, 64) } func TestEmptyBlockShortCircuit64(t *testing.T) { testEmptyBlockShortCircuit(t, 64) }
func TestEmptyBlockShortCircuit100(t *testing.T) { testEmptyBlockShortCircuit(t, 64) } func TestEmptyBlockShortCircuit100(t *testing.T) { testEmptyBlockShortCircuit(t, 100) }
func TestEmptyBlockShortCircuit101(t *testing.T) { testEmptyBlockShortCircuit(t, 101) }
func testEmptyBlockShortCircuit(t *testing.T, protocol int) { func testEmptyBlockShortCircuit(t *testing.T, protocol int) {
// Create a chain of blocks to import // Create a chain of blocks to import
@ -769,6 +779,7 @@ func TestHashMemoryExhaustionAttack62(t *testing.T) { testHashMemoryExhaustionAt
func TestHashMemoryExhaustionAttack63(t *testing.T) { testHashMemoryExhaustionAttack(t, 63) } func TestHashMemoryExhaustionAttack63(t *testing.T) { testHashMemoryExhaustionAttack(t, 63) }
func TestHashMemoryExhaustionAttack64(t *testing.T) { testHashMemoryExhaustionAttack(t, 64) } func TestHashMemoryExhaustionAttack64(t *testing.T) { testHashMemoryExhaustionAttack(t, 64) }
func TestHashMemoryExhaustionAttack100(t *testing.T) { testHashMemoryExhaustionAttack(t, 100) } func TestHashMemoryExhaustionAttack100(t *testing.T) { testHashMemoryExhaustionAttack(t, 100) }
func TestHashMemoryExhaustionAttack101(t *testing.T) { testHashMemoryExhaustionAttack(t, 101) }
func testHashMemoryExhaustionAttack(t *testing.T, protocol int) { func testHashMemoryExhaustionAttack(t *testing.T, protocol int) {
// Create a tester with instrumented import hooks // Create a tester with instrumented import hooks

View file

@ -246,7 +246,7 @@ func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, ne
return blockchain.CurrentBlock().NumberU64() return blockchain.CurrentBlock().NumberU64()
} }
inserter := func(block types.Block) (int, error) { inserter := func(block types.Block) (error) {
// If sync hasn't reached the checkpoint yet, deny importing weird blocks. // If sync hasn't reached the checkpoint yet, deny importing weird blocks.
// //
// Ideally we would also compare the head block's timestamp and similarly reject // Ideally we would also compare the head block's timestamp and similarly reject
@ -255,7 +255,7 @@ func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, ne
// which would prevent full nodes from accepting it. // which would prevent full nodes from accepting it.
if manager.blockchain.CurrentBlock().NumberU64() < manager.checkpointNumber { if manager.blockchain.CurrentBlock().NumberU64() < manager.checkpointNumber {
log.Warn("Unsynced yet, discarded propagated block", "number", block.Number(), "hash", block.Hash()) log.Warn("Unsynced yet, discarded propagated block", "number", block.Number(), "hash", block.Hash())
return 0, nil return nil
} }
// If fast sync is running, deny importing weird blocks. This is a problematic // If fast sync is running, deny importing weird blocks. This is a problematic
// clause when starting up a new network, because fast-syncing miners might not // clause when starting up a new network, because fast-syncing miners might not
@ -264,14 +264,14 @@ func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, ne
// or not. This should be fixed if we figure out a solution. // or not. This should be fixed if we figure out a solution.
if atomic.LoadUint32(&manager.fastSync) == 1 { if atomic.LoadUint32(&manager.fastSync) == 1 {
log.Warn("Fast syncing, discarded propagated block", "number", block.Number(), "hash", block.Hash()) log.Warn("Fast syncing, discarded propagated block", "number", block.Number(), "hash", block.Hash())
return 0, nil return nil
} }
n, err := manager.blockchain.InsertBlock(&block) err := manager.blockchain.InsertBlock(&block)
// n, err := manager.blockchain.InsertChain(blocks) // n, err := manager.blockchain.InsertChain(blocks) //TODO: only use InsertChain like go-eth
if err == nil { if err == nil {
atomic.StoreUint32(&manager.acceptTxs, 1) // Mark initial sync done on any fetcher import atomic.StoreUint32(&manager.acceptTxs, 1) // Mark initial sync done on any fetcher import
} }
return n, err return err
} }
prepare := func(block *types.Block) error { prepare := func(block *types.Block) error {
@ -699,7 +699,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
} }
} }
case supportsEth63(p.version) && msg.Code == GetNodeDataMsg: case isEth63OrHigher(p.version) && msg.Code == GetNodeDataMsg:
// Decode the retrieval message // Decode the retrieval message
msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size)) msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size))
if _, err := msgStream.List(); err != nil { if _, err := msgStream.List(); err != nil {
@ -726,7 +726,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
} }
return p.SendNodeData(data) return p.SendNodeData(data)
case supportsEth63(p.version) && msg.Code == NodeDataMsg: case isEth63OrHigher(p.version) && msg.Code == NodeDataMsg:
// A batch of node state data arrived to one of our previous requests // A batch of node state data arrived to one of our previous requests
var data [][]byte var data [][]byte
if err := msg.Decode(&data); err != nil { if err := msg.Decode(&data); err != nil {
@ -737,7 +737,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
log.Debug("Failed to deliver node state data", "err", err) log.Debug("Failed to deliver node state data", "err", err)
} }
case supportsEth63(p.version) && msg.Code == GetReceiptsMsg: case isEth63OrHigher(p.version) && msg.Code == GetReceiptsMsg:
// Decode the retrieval message // Decode the retrieval message
msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size)) msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size))
if _, err := msgStream.List(); err != nil { if _, err := msgStream.List(); err != nil {
@ -773,7 +773,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
} }
return p.SendReceiptsRLP(receipts) return p.SendReceiptsRLP(receipts)
case supportsEth63(p.version) && msg.Code == ReceiptsMsg: case isEth63OrHigher(p.version) && msg.Code == ReceiptsMsg:
// A batch of receipts arrived to one of our previous requests // A batch of receipts arrived to one of our previous requests
var receipts [][]*types.Receipt var receipts [][]*types.Receipt
if err := msg.Decode(&receipts); err != nil { if err := msg.Decode(&receipts); err != nil {
@ -847,7 +847,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
} }
} }
case msg.Code == NewPooledTransactionHashesMsg && supportsEth65(p.version): case msg.Code == NewPooledTransactionHashesMsg && isEth65OrHigher(p.version):
// New transaction announcement arrived, make sure we have // New transaction announcement arrived, make sure we have
// a valid and fresh chain to handle them // a valid and fresh chain to handle them
if atomic.LoadUint32(&pm.acceptTxs) == 0 { if atomic.LoadUint32(&pm.acceptTxs) == 0 {
@ -863,7 +863,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
} }
pm.txFetcher.Notify(p.id, hashes) pm.txFetcher.Notify(p.id, hashes)
case msg.Code == GetPooledTransactionsMsg && supportsEth65(p.version): case msg.Code == GetPooledTransactionsMsg && isEth65OrHigher(p.version):
// Decode the retrieval message // Decode the retrieval message
msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size)) msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size))
if _, err := msgStream.List(); err != nil { if _, err := msgStream.List(); err != nil {
@ -899,7 +899,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
} }
return p.SendPooledTransactionsRLP(hashes, txs) return p.SendPooledTransactionsRLP(hashes, txs)
case msg.Code == TransactionMsg || (msg.Code == PooledTransactionsMsg && supportsEth65(p.version)): case msg.Code == TransactionMsg || (msg.Code == PooledTransactionsMsg && isEth65OrHigher(p.version)):
// Transactions arrived, make sure we have a valid and fresh chain to handle them // Transactions arrived, make sure we have a valid and fresh chain to handle them
if atomic.LoadUint32(&pm.acceptTxs) == 0 { if atomic.LoadUint32(&pm.acceptTxs) == 0 {
break break

View file

@ -43,6 +43,7 @@ import (
func TestGetBlockHeaders63(t *testing.T) { testGetBlockHeaders(t, 63) } func TestGetBlockHeaders63(t *testing.T) { testGetBlockHeaders(t, 63) }
func TestGetBlockHeaders64(t *testing.T) { testGetBlockHeaders(t, 64) } func TestGetBlockHeaders64(t *testing.T) { testGetBlockHeaders(t, 64) }
func TestGetBlockHeaders100(t *testing.T) { testGetBlockHeaders(t, 100) } func TestGetBlockHeaders100(t *testing.T) { testGetBlockHeaders(t, 100) }
func TestGetBlockHeaders101(t *testing.T) { testGetBlockHeaders(t, 101) }
func testGetBlockHeaders(t *testing.T, protocol int) { func testGetBlockHeaders(t *testing.T, protocol int) {
pm, _ := newTestProtocolManagerMust(t, downloader.FullSync, downloader.MaxHashFetch+15, nil, nil) pm, _ := newTestProtocolManagerMust(t, downloader.FullSync, downloader.MaxHashFetch+15, nil, nil)
@ -203,6 +204,7 @@ func testGetBlockHeaders(t *testing.T, protocol int) {
func TestGetBlockBodies63(t *testing.T) { testGetBlockBodies(t, 63) } func TestGetBlockBodies63(t *testing.T) { testGetBlockBodies(t, 63) }
func TestGetBlockBodies64(t *testing.T) { testGetBlockBodies(t, 64) } func TestGetBlockBodies64(t *testing.T) { testGetBlockBodies(t, 64) }
func TestGetBlockBodies100(t *testing.T) { testGetBlockBodies(t, 100) } func TestGetBlockBodies100(t *testing.T) { testGetBlockBodies(t, 100) }
func TestGetBlockBodies101(t *testing.T) { testGetBlockBodies(t, 101) }
func testGetBlockBodies(t *testing.T, protocol int) { func testGetBlockBodies(t *testing.T, protocol int) {
pm, _ := newTestProtocolManagerMust(t, downloader.FullSync, downloader.MaxBlockFetch+15, nil, nil) pm, _ := newTestProtocolManagerMust(t, downloader.FullSync, downloader.MaxBlockFetch+15, nil, nil)
@ -276,6 +278,7 @@ func testGetBlockBodies(t *testing.T, protocol int) {
func TestGetNodeData63(t *testing.T) { testGetNodeData(t, 63) } func TestGetNodeData63(t *testing.T) { testGetNodeData(t, 63) }
func TestGetNodeData64(t *testing.T) { testGetNodeData(t, 64) } func TestGetNodeData64(t *testing.T) { testGetNodeData(t, 64) }
func TestGetNodeData100(t *testing.T) { testGetNodeData(t, 100) } func TestGetNodeData100(t *testing.T) { testGetNodeData(t, 100) }
func TestGetNodeData101(t *testing.T) { testGetNodeData(t, 101) }
func testGetNodeData(t *testing.T, protocol int) { func testGetNodeData(t *testing.T, protocol int) {
// Define three accounts to simulate transactions with // Define three accounts to simulate transactions with
@ -372,6 +375,7 @@ func testGetNodeData(t *testing.T, protocol int) {
func TestGetReceipt63(t *testing.T) { testGetReceipt(t, 63) } func TestGetReceipt63(t *testing.T) { testGetReceipt(t, 63) }
func TestGetReceipt64(t *testing.T) { testGetReceipt(t, 64) } func TestGetReceipt64(t *testing.T) { testGetReceipt(t, 64) }
func TestGetReceipt100(t *testing.T) { testGetReceipt(t, 100) } func TestGetReceipt100(t *testing.T) { testGetReceipt(t, 100) }
func TestGetReceipt101(t *testing.T) { testGetReceipt(t, 101) }
func testGetReceipt(t *testing.T, protocol int) { func testGetReceipt(t *testing.T, protocol int) {
// Define three accounts to simulate transactions with // Define three accounts to simulate transactions with
@ -557,7 +561,7 @@ func testBroadcastBlock(t *testing.T, totalPeers, broadcastExpected int) {
if err != nil { if err != nil {
t.Fatalf("failed to create new blockchain: %v", err) t.Fatalf("failed to create new blockchain: %v", err)
} }
pm, err := NewProtocolManager(config, downloader.FullSync, DefaultConfig.NetworkId, evmux, &testTxPool{pool: make(map[common.Hash]*types.Transaction)}, pow, blockchain, db) pm, err := NewProtocolManager(config, downloader.FullSync, ethconfig.Defaults.NetworkId, evmux, &testTxPool{pool: make(map[common.Hash]*types.Transaction)}, pow, blockchain, db)
if err != nil { if err != nil {
t.Fatalf("failed to start test protocol manager: %v", err) t.Fatalf("failed to start test protocol manager: %v", err)
} }
@ -625,7 +629,7 @@ func TestBroadcastMalformedBlock(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("failed to create new blockchain: %v", err) t.Fatalf("failed to create new blockchain: %v", err)
} }
pm, err := NewProtocolManager(config, downloader.FullSync, DefaultConfig.NetworkId, new(event.TypeMux), new(testTxPool), engine, blockchain, db) pm, err := NewProtocolManager(config, downloader.FullSync, ethconfig.Defaults.NetworkId, new(event.TypeMux), new(testTxPool), engine, blockchain, db)
if err != nil { if err != nil {
t.Fatalf("failed to start test protocol manager: %v", err) t.Fatalf("failed to start test protocol manager: %v", err)
} }

View file

@ -71,7 +71,7 @@ func newTestProtocolManager(mode downloader.SyncMode, blocks int, generator func
} }
// pm, err := NewProtocolManager(gspec.Config, mode, DefaultConfig.NetworkId, evmux, &testTxPool{added: newtx}, engine, blockchain, db) // pm, err := NewProtocolManager(gspec.Config, mode, DefaultConfig.NetworkId, evmux, &testTxPool{added: newtx}, engine, blockchain, db)
pm, err := NewProtocolManager(gspec.Config, mode, DefaultConfig.NetworkId, evmux, &testTxPool{added: newtx, pool: make(map[common.Hash]*types.Transaction)}, engine, blockchain, db) pm, err := NewProtocolManager(gspec.Config, mode, ethconfig.Defaults.NetworkId, evmux, &testTxPool{added: newtx, pool: make(map[common.Hash]*types.Transaction)}, engine, blockchain, db)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -207,26 +207,18 @@ func newTestPeer(name string, version int, pm *ProtocolManager, shake bool) (*te
func (p *testPeer) handshake(t *testing.T, td *big.Int, head common.Hash, genesis common.Hash, forkID forkid.ID, forkFilter forkid.Filter) { func (p *testPeer) handshake(t *testing.T, td *big.Int, head common.Hash, genesis common.Hash, forkID forkid.ID, forkFilter forkid.Filter) {
var msg interface{} var msg interface{}
switch { switch {
case p.version == xdpos2: case isEth63(p.version):
msg = &statusData63{ msg = &statusData63{
ProtocolVersion: uint32(p.version), ProtocolVersion: uint32(p.version),
NetworkId: DefaultConfig.NetworkId, NetworkId: ethconfig.Defaults.NetworkId,
TD: td, TD: td,
CurrentBlock: head, CurrentBlock: head,
GenesisBlock: genesis, GenesisBlock: genesis,
} }
case p.version == eth63: case isEth64OrHigher(p.version):
msg = &statusData63{
ProtocolVersion: uint32(p.version),
NetworkId: DefaultConfig.NetworkId,
TD: td,
CurrentBlock: head,
GenesisBlock: genesis,
}
case p.version >= eth64:
msg = &statusData{ msg = &statusData{
ProtocolVersion: uint32(p.version), ProtocolVersion: uint32(p.version),
NetworkID: DefaultConfig.NetworkId, NetworkID: ethconfig.Defaults.NetworkId,
TD: td, TD: td,
Head: head, Head: head,
Genesis: genesis, Genesis: genesis,
@ -236,6 +228,7 @@ func (p *testPeer) handshake(t *testing.T, td *big.Int, head common.Hash, genesi
panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version)) panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version))
} }
if err := p2p.ExpectMsg(p.app, StatusMsg, msg); err != nil { if err := p2p.ExpectMsg(p.app, StatusMsg, msg); err != nil {
fmt.Println("p2p expect msg err", err)
t.Fatalf("status recv: %v", err) t.Fatalf("status recv: %v", err)
} }
if err := p2p.Send(p.app, StatusMsg, msg); err != nil { if err := p2p.Send(p.app, StatusMsg, msg); err != nil {

View file

@ -783,25 +783,7 @@ func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis
) )
go func() { go func() {
switch { switch {
case supportsEth65(p.version): case isEth63(p.version):
errc <- p2p.Send(p.rw, StatusMsg, &statusData{
ProtocolVersion: uint32(p.version),
NetworkID: network,
TD: td,
Head: head,
Genesis: genesis,
ForkID: forkID,
})
case supportsEth64(p.version):
errc <- p2p.Send(p.rw, StatusMsg, &statusData{
ProtocolVersion: uint32(p.version),
NetworkID: network,
TD: td,
Head: head,
Genesis: genesis,
ForkID: forkID,
})
case supportsEth63(p.version):
errc <- p2p.Send(p.rw, StatusMsg, &statusData63{ errc <- p2p.Send(p.rw, StatusMsg, &statusData63{
ProtocolVersion: uint32(p.version), ProtocolVersion: uint32(p.version),
NetworkId: network, NetworkId: network,
@ -809,16 +791,25 @@ func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis
CurrentBlock: head, CurrentBlock: head,
GenesisBlock: genesis, GenesisBlock: genesis,
}) })
case isEth64OrHigher(p.version):
errc <- p2p.Send(p.rw, StatusMsg, &statusData{
ProtocolVersion: uint32(p.version),
NetworkID: network,
TD: td,
Head: head,
Genesis: genesis,
ForkID: forkID,
})
default: default:
panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version)) panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version))
} }
}() }()
go func() { go func() {
switch { switch {
case supportsEth64(p.version): case isEth63(p.version):
errc <- p.readStatus(network, &status, genesis, forkFilter)
case supportsEth63(p.version):
errc <- p.readStatusLegacy(network, &status63, genesis) errc <- p.readStatusLegacy(network, &status63, genesis)
case isEth64OrHigher(p.version):
errc <- p.readStatus(network, &status, genesis, forkFilter)
default: default:
panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version)) panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version))
} }
@ -836,10 +827,10 @@ func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis
} }
} }
switch { switch {
case supportsEth64(p.version): case isEth63(p.version):
p.td, p.head = status.TD, status.Head
case supportsEth63(p.version):
p.td, p.head = status63.TD, status63.CurrentBlock p.td, p.head = status63.TD, status63.CurrentBlock
case isEth64OrHigher(p.version):
p.td, p.head = status.TD, status.Head
default: default:
panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version)) panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version))
} }

View file

@ -38,44 +38,26 @@ const (
xdpos22 = 101 //xdpos2.2 = eth65 xdpos22 = 101 //xdpos2.2 = eth65
) )
// XDC needs the below functions because direct number equality doesn't work (eg. version >= 63)
// we should try to match protocols 1 to 1 from now on, bump xdpos along with any new eth (eg. eth66 = xdpos23 only)
// try to follow the exact comparison from go-ethereum as much as possible (eg. version >= 63 <> isEth63OrHigher(version))
func isEth63(version int) bool { func isEth63(version int) bool {
switch { switch {
case version < 63: case version == 63:
return false return true
case version >= 63: case version == 100:
return true return true
default: default:
return false return false
} }
} }
func supportsEth64(version int) bool {
switch {
case version < 64:
return false
case version < 100:
return true
case version == 100:
return false
case version > 100:
return true
default:
return false
}
}
func isEth64(version int) bool { func isEth64(version int) bool {
switch { switch {
case version < 65: case version == 64:
return false
case version < 100:
return true return true
default: default:
return false return false
} }
} }
func isEth65(version int) bool { func isEth65(version int) bool {
switch { switch {
case version == 65: case version == 65:

View file

@ -33,6 +33,7 @@ import (
"github.com/XinFinOrg/XDPoSChain/core/vm" "github.com/XinFinOrg/XDPoSChain/core/vm"
"github.com/XinFinOrg/XDPoSChain/crypto" "github.com/XinFinOrg/XDPoSChain/crypto"
"github.com/XinFinOrg/XDPoSChain/eth/downloader" "github.com/XinFinOrg/XDPoSChain/eth/downloader"
"github.com/XinFinOrg/XDPoSChain/eth/ethconfig"
"github.com/XinFinOrg/XDPoSChain/event" "github.com/XinFinOrg/XDPoSChain/event"
"github.com/XinFinOrg/XDPoSChain/p2p" "github.com/XinFinOrg/XDPoSChain/p2p"
"github.com/XinFinOrg/XDPoSChain/p2p/enode" "github.com/XinFinOrg/XDPoSChain/p2p/enode"
@ -66,15 +67,15 @@ func TestStatusMsgErrors63(t *testing.T) {
wantError: errResp(ErrNoStatusMsg, "first msg has code 2 (!= 0)"), wantError: errResp(ErrNoStatusMsg, "first msg has code 2 (!= 0)"),
}, },
{ {
code: StatusMsg, data: statusData63{10, DefaultConfig.NetworkId, td, head.Hash(), genesis.Hash()}, code: StatusMsg, data: statusData63{10, ethconfig.Defaults.NetworkId, td, head.Hash(), genesis.Hash()},
wantError: errResp(ErrProtocolVersionMismatch, "10 (!= %d)", 63), wantError: errResp(ErrProtocolVersionMismatch, "10 (!= %d)", 63),
}, },
{ {
code: StatusMsg, data: statusData63{63, 999, td, head.Hash(), genesis.Hash()}, code: StatusMsg, data: statusData63{63, 999, td, head.Hash(), genesis.Hash()},
wantError: errResp(ErrNetworkIDMismatch, "999 (!= %d)", DefaultConfig.NetworkId), wantError: errResp(ErrNetworkIDMismatch, "999 (!= %d)", ethconfig.Defaults.NetworkId),
}, },
{ {
code: StatusMsg, data: statusData63{63, DefaultConfig.NetworkId, td, head.Hash(), common.Hash{3}}, code: StatusMsg, data: statusData63{63, ethconfig.Defaults.NetworkId, td, head.Hash(), common.Hash{3}},
wantError: errResp(ErrGenesisMismatch, "0300000000000000 (!= %x)", genesis.Hash().Bytes()[:8]), wantError: errResp(ErrGenesisMismatch, "0300000000000000 (!= %x)", genesis.Hash().Bytes()[:8]),
}, },
} }
@ -118,19 +119,19 @@ func TestStatusMsgErrors64(t *testing.T) {
wantError: errResp(ErrNoStatusMsg, "first msg has code 2 (!= 0)"), wantError: errResp(ErrNoStatusMsg, "first msg has code 2 (!= 0)"),
}, },
{ {
code: StatusMsg, data: statusData{10, DefaultConfig.NetworkId, td, head.Hash(), genesis.Hash(), forkID}, code: StatusMsg, data: statusData{10, ethconfig.Defaults.NetworkId, td, head.Hash(), genesis.Hash(), forkID},
wantError: errResp(ErrProtocolVersionMismatch, "10 (!= %d)", 64), wantError: errResp(ErrProtocolVersionMismatch, "10 (!= %d)", 64),
}, },
{ {
code: StatusMsg, data: statusData{64, 999, td, head.Hash(), genesis.Hash(), forkID}, code: StatusMsg, data: statusData{64, 999, td, head.Hash(), genesis.Hash(), forkID},
wantError: errResp(ErrNetworkIDMismatch, "999 (!= %d)", DefaultConfig.NetworkId), wantError: errResp(ErrNetworkIDMismatch, "999 (!= %d)", ethconfig.Defaults.NetworkId),
}, },
{ {
code: StatusMsg, data: statusData{64, DefaultConfig.NetworkId, td, head.Hash(), common.Hash{3}, forkID}, code: StatusMsg, data: statusData{64, ethconfig.Defaults.NetworkId, td, head.Hash(), common.Hash{3}, forkID},
wantError: errResp(ErrGenesisMismatch, "0300000000000000000000000000000000000000000000000000000000000000 (!= %x)", genesis.Hash()), wantError: errResp(ErrGenesisMismatch, "0300000000000000000000000000000000000000000000000000000000000000 (!= %x)", genesis.Hash()),
}, },
{ {
code: StatusMsg, data: statusData{64, DefaultConfig.NetworkId, td, head.Hash(), genesis.Hash(), forkid.ID{Hash: [4]byte{0x00, 0x01, 0x02, 0x03}}}, code: StatusMsg, data: statusData{64, ethconfig.Defaults.NetworkId, td, head.Hash(), genesis.Hash(), forkid.ID{Hash: [4]byte{0x00, 0x01, 0x02, 0x03}}},
wantError: errResp(ErrForkIDRejected, forkid.ErrLocalIncompatibleOrStale.Error()), wantError: errResp(ErrForkIDRejected, forkid.ErrLocalIncompatibleOrStale.Error()),
}, },
} }
@ -255,6 +256,7 @@ func TestRecvTransactions63(t *testing.T) { testRecvTransactions(t, 63) }
func TestRecvTransactions64(t *testing.T) { testRecvTransactions(t, 64) } func TestRecvTransactions64(t *testing.T) { testRecvTransactions(t, 64) }
func TestRecvTransactions65(t *testing.T) { testRecvTransactions(t, 65) } func TestRecvTransactions65(t *testing.T) { testRecvTransactions(t, 65) }
func TestRecvTransactions100(t *testing.T) { testRecvTransactions(t, 100) } func TestRecvTransactions100(t *testing.T) { testRecvTransactions(t, 100) }
func TestRecvTransactions101(t *testing.T) { testRecvTransactions(t, 101) }
func testRecvTransactions(t *testing.T, protocol int) { func testRecvTransactions(t *testing.T, protocol int) {
txAdded := make(chan []*types.Transaction) txAdded := make(chan []*types.Transaction)
@ -285,6 +287,7 @@ func TestSendTransactions63(t *testing.T) { testSendTransactions(t, 63) }
func TestSendTransactions64(t *testing.T) { testSendTransactions(t, 64) } func TestSendTransactions64(t *testing.T) { testSendTransactions(t, 64) }
func TestSendTransactions65(t *testing.T) { testSendTransactions(t, 65) } func TestSendTransactions65(t *testing.T) { testSendTransactions(t, 65) }
func TestSendTransactions100(t *testing.T) { testSendTransactions(t, 100) } func TestSendTransactions100(t *testing.T) { testSendTransactions(t, 100) }
func TestSendTransactions101(t *testing.T) { testSendTransactions(t, 101) }
func testSendTransactions(t *testing.T, protocol int) { func testSendTransactions(t *testing.T, protocol int) {
pm, _ := newTestProtocolManagerMust(t, downloader.FullSync, 0, nil, nil) pm, _ := newTestProtocolManagerMust(t, downloader.FullSync, 0, nil, nil)

View file

@ -61,7 +61,7 @@ func (pm *ProtocolManager) syncTransactions(p *peer) {
// The eth/65 protocol introduces proper transaction announcements, so instead // The eth/65 protocol introduces proper transaction announcements, so instead
// of dripping transactions across multiple peers, just send the entire list as // of dripping transactions across multiple peers, just send the entire list as
// an announcement and let the remote side decide what they need (likely nothing). // an announcement and let the remote side decide what they need (likely nothing).
if supportsEth65(p.version) { if isEth65OrHigher(p.version) {
hashes := make([]common.Hash, len(txs)) hashes := make([]common.Hash, len(txs))
for i, tx := range txs { for i, tx := range txs {
hashes[i] = tx.Hash() hashes[i] = tx.Hash()
@ -89,7 +89,7 @@ func (pm *ProtocolManager) txsyncLoop64() {
) )
// send starts a sending a pack of transactions from the sync. // send starts a sending a pack of transactions from the sync.
send := func(s *txsync) { send := func(s *txsync) {
if supportsEth65(s.p.version) { if isEth65OrHigher(s.p.version) {
panic("initial transaction syncer running on eth/65+") panic("initial transaction syncer running on eth/65+")
} }
// Fill pack with transactions up to the target size. // Fill pack with transactions up to the target size.

View file

@ -30,6 +30,7 @@ func TestFastSyncDisabling63(t *testing.T) { testFastSyncDisabling(t, 63) }
func TestFastSyncDisabling64(t *testing.T) { testFastSyncDisabling(t, 64) } func TestFastSyncDisabling64(t *testing.T) { testFastSyncDisabling(t, 64) }
func TestFastSyncDisabling65(t *testing.T) { testFastSyncDisabling(t, 65) } func TestFastSyncDisabling65(t *testing.T) { testFastSyncDisabling(t, 65) }
func TestFastSyncDisabling100(t *testing.T) { testFastSyncDisabling(t, 100) } func TestFastSyncDisabling100(t *testing.T) { testFastSyncDisabling(t, 100) }
func TestFastSyncDisabling101(t *testing.T) { testFastSyncDisabling(t, 101) }
// Tests that fast sync gets disabled as soon as a real block is successfully // Tests that fast sync gets disabled as soon as a real block is successfully
// imported into the blockchain. // imported into the blockchain.