Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #692 from carver/test-chain-update
Browse files Browse the repository at this point in the history
Update sync tests to latest VM, where possible
  • Loading branch information
carver authored Jun 7, 2019
2 parents 37be36c + 5c63f12 commit b2f5af1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
14 changes: 12 additions & 2 deletions tests/core/integration_test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
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
from eth.vm.forks.petersburg import PetersburgVM

from trinity.constants import TO_NETWORKING_BROADCAST_CONFIG
from trinity.db.base import BaseAsyncDB
Expand Down Expand Up @@ -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
Expand All @@ -155,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),
)
Expand Down
3 changes: 2 additions & 1 deletion tests/core/p2p-proto/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions tests/core/p2p-proto/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
FakeAsyncAtomicDB,
FakeAsyncChainDB,
FakeAsyncHeaderDB,
LatestTestChain,
load_fixture_db,
load_mining_chain,
run_peer_pool_event_server,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b2f5af1

Please sign in to comment.