1
1
import asyncio
2
+ import logging
2
3
3
4
import pytest
4
5
import rlp
9
10
10
11
from eth_hash .auto import keccak
11
12
12
- from evm .chains .ropsten import ROPSTEN_NETWORK_ID , ROPSTEN_GENESIS_HEADER , ROPSTEN_VM_CONFIGURATION
13
+ from evm .chains .ropsten import (
14
+ RopstenChain ,
15
+ ROPSTEN_NETWORK_ID ,
16
+ ROPSTEN_GENESIS_HEADER ,
17
+ ROPSTEN_VM_CONFIGURATION ,
18
+ )
13
19
from evm .db .backends .memory import MemoryDB
14
20
15
21
from p2p import ecies
19
25
from p2p .peer import LESPeer , PeerPool
20
26
21
27
from integration_test_helpers import (
22
- FakeAsyncChainDB , FakeAsyncRopstenChain , FakeAsyncHeaderDB , connect_to_peers_loop )
28
+ FakeAsyncChainDB ,
29
+ FakeAsyncRopstenChain ,
30
+ FakeAsyncHeaderDB ,
31
+ connect_to_peers_loop ,
32
+ )
23
33
24
34
25
35
@pytest .mark .asyncio
26
- async def test_lightchain_integration (request , event_loop ):
36
+ async def test_lightchain_integration (request , event_loop , caplog ):
27
37
"""Test LightChainSyncer/LightPeerChain against a running geth instance.
28
38
29
39
In order to run this you need to pass the following to pytest:
30
40
31
- pytest --integration --enode=...
41
+ pytest --integration --capture=no -- enode=...
32
42
33
43
If you don't have any geth testnet data ready, it is very quick to generate some with:
34
44
@@ -43,14 +53,21 @@ async def test_lightchain_integration(request, event_loop):
43
53
if not pytest .config .getoption ("--integration" ):
44
54
pytest .skip ("Not asked to run integration tests" )
45
55
56
+ # will almost certainly want verbose logging in a failure
57
+ caplog .set_level (logging .DEBUG )
58
+
46
59
remote = Node .from_uri (pytest .config .getoption ("--enode" ))
47
60
base_db = MemoryDB ()
48
61
chaindb = FakeAsyncChainDB (base_db )
49
62
chaindb .persist_header (ROPSTEN_GENESIS_HEADER )
50
63
headerdb = FakeAsyncHeaderDB (base_db )
51
64
peer_pool = PeerPool (
52
- LESPeer , FakeAsyncHeaderDB (base_db ), ROPSTEN_NETWORK_ID , ecies .generate_privkey (),
53
- ROPSTEN_VM_CONFIGURATION )
65
+ LESPeer ,
66
+ FakeAsyncHeaderDB (base_db ),
67
+ ROPSTEN_NETWORK_ID ,
68
+ ecies .generate_privkey (),
69
+ ROPSTEN_VM_CONFIGURATION ,
70
+ )
54
71
chain = FakeAsyncRopstenChain (base_db )
55
72
syncer = LightChainSyncer (chain , chaindb , peer_pool )
56
73
syncer .min_peers_to_sync = 1
0 commit comments