From f3cb5cddab908dde646ca711653659bcae8adadf Mon Sep 17 00:00:00 2001 From: Jason Carver Date: Tue, 4 Jun 2019 13:30:58 -0700 Subject: [PATCH 1/3] Update sync tests to latest VM, where possible --- tests/core/integration_test_helpers.py | 10 ++++++++++ tests/core/p2p-proto/test_sync.py | 7 ++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/core/integration_test_helpers.py b/tests/core/integration_test_helpers.py index 7a1d29cd56..90d27dc068 100644 --- a/tests/core/integration_test_helpers.py +++ b/tests/core/integration_test_helpers.py @@ -27,6 +27,7 @@ ) from eth.db.header import HeaderDB from eth.vm.forks.byzantium import ByzantiumVM +from eth.vm.forks.petersburg import PetersburgVM from trinity.constants import TO_NETWORKING_BROADCAST_CONFIG from trinity.db.base import BaseAsyncDB @@ -130,6 +131,15 @@ class FakeAsyncChain(MiningChain): chaindb_class = FakeAsyncChainDB +class LatestTestChain(FakeAsyncChain): + """ + A test chain that uses the most recent mainnet VM from block 0. + That means the VM will explicitly change when a new network upgrade is locked in. + """ + vm_configuration = ((0, PetersburgVM),) + network_id = 999 + + class ByzantiumTestChain(FakeAsyncChain): vm_configuration = ((0, ByzantiumVM),) network_id = 999 diff --git a/tests/core/p2p-proto/test_sync.py b/tests/core/p2p-proto/test_sync.py index 188c838e35..87cda6167c 100644 --- a/tests/core/p2p-proto/test_sync.py +++ b/tests/core/p2p-proto/test_sync.py @@ -26,6 +26,7 @@ FakeAsyncAtomicDB, FakeAsyncChainDB, FakeAsyncHeaderDB, + LatestTestChain, load_fixture_db, load_mining_chain, run_peer_pool_event_server, @@ -58,7 +59,7 @@ async def test_fast_syncer(request, alice_headerdb=FakeAsyncHeaderDB(chaindb_fresh.db), bob_headerdb=FakeAsyncHeaderDB(chaindb_20.db)) client_peer_pool = MockPeerPoolWithConnectedPeers([client_peer]) - client = FastChainSyncer(ByzantiumTestChain(chaindb_fresh.db), chaindb_fresh, client_peer_pool) + client = FastChainSyncer(LatestTestChain(chaindb_fresh.db), chaindb_fresh, client_peer_pool) server_peer_pool = MockPeerPoolWithConnectedPeers([server_peer], event_bus=event_bus) async with run_peer_pool_event_server( @@ -94,7 +95,7 @@ async def test_skeleton_syncer(request, event_loop, event_bus, chaindb_fresh, ch alice_headerdb=FakeAsyncHeaderDB(chaindb_fresh.db), bob_headerdb=FakeAsyncHeaderDB(chaindb_1000.db)) client_peer_pool = MockPeerPoolWithConnectedPeers([client_peer]) - client = FastChainSyncer(ByzantiumTestChain(chaindb_fresh.db), chaindb_fresh, client_peer_pool) + client = FastChainSyncer(LatestTestChain(chaindb_fresh.db), chaindb_fresh, client_peer_pool) server_peer_pool = MockPeerPoolWithConnectedPeers([server_peer], event_bus=event_bus) async with run_peer_pool_event_server( @@ -279,7 +280,7 @@ async def test_light_syncer(request, alice_headerdb=FakeAsyncHeaderDB(chaindb_fresh.db), bob_headerdb=FakeAsyncHeaderDB(chaindb_20.db)) client = LightChainSyncer( - ByzantiumTestChain(chaindb_fresh.db), + LatestTestChain(chaindb_fresh.db), chaindb_fresh, MockPeerPoolWithConnectedPeers([client_peer])) server_peer_pool = MockPeerPoolWithConnectedPeers([server_peer], event_bus=event_bus) From 86264de18591793ac715e4c96021092ae27a7d75 Mon Sep 17 00:00:00 2001 From: Jason Carver Date: Wed, 5 Jun 2019 16:54:21 -0700 Subject: [PATCH 2/3] Update mining chain tool to petersburg --- tests/core/integration_test_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/core/integration_test_helpers.py b/tests/core/integration_test_helpers.py index 90d27dc068..dfb4f173b1 100644 --- a/tests/core/integration_test_helpers.py +++ b/tests/core/integration_test_helpers.py @@ -21,9 +21,9 @@ from eth.db.chain import ChainDB from eth.tools.builder.chain import ( build, - byzantium_at, enable_pow_mining, genesis, + latest_mainnet_at, ) from eth.db.header import HeaderDB from eth.vm.forks.byzantium import ByzantiumVM @@ -165,7 +165,7 @@ def load_mining_chain(db): return build( FakeAsyncChain, - byzantium_at(0), + latest_mainnet_at(0), enable_pow_mining(), genesis(db=db, params=GENESIS_PARAMS, state=GENESIS_STATE), ) From 5c63f123707fdd9a32f24b5c72ec0fdaf377fa2f Mon Sep 17 00:00:00 2001 From: Jason Carver Date: Wed, 5 Jun 2019 17:09:31 -0700 Subject: [PATCH 3/3] Give flaky test more time to execute --- tests/core/p2p-proto/test_server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/core/p2p-proto/test_server.py b/tests/core/p2p-proto/test_server.py index b3953c8d33..6ef7ef728e 100644 --- a/tests/core/p2p-proto/test_server.py +++ b/tests/core/p2p-proto/test_server.py @@ -182,7 +182,8 @@ async def test_peer_pool_answers_connect_commands(event_loop, event_bus, server) TO_NETWORKING_BROADCAST_CONFIG ) - await asyncio.sleep(0.1) + # This test was maybe 30% flaky at 0.1 sleep + await asyncio.sleep(0.2) assert len(server.peer_pool.connected_nodes) == 1