Skip to content

Commit 9885c68

Browse files
committed
Reorg the fixtures
1 parent 8a826b7 commit 9885c68

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
lines changed

tests/beacon/state_machines/conftest.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import pytest
22

3+
from eth.beacon.db.chain import BeaconChainDB
34
from eth.beacon.state_machines.configs import BeaconConfig
5+
from eth.beacon.state_machines.forks.serenity import (
6+
SerenityBeaconStateMachine,
7+
)
48

59

610
@pytest.fixture
@@ -24,3 +28,23 @@ def config(base_reward_quotient,
2428
SLOT_DURATION=slot_duration,
2529
SQRT_E_DROP_TIME=sqrt_e_drop_time,
2630
)
31+
32+
33+
@pytest.fixture
34+
def fixture_sm_class(config):
35+
return SerenityBeaconStateMachine.configure(
36+
__name__='SerenityBeaconStateMachineForTesting',
37+
config=config,
38+
)
39+
40+
41+
@pytest.fixture
42+
def initial_chaindb(base_db,
43+
genesis_block,
44+
genesis_crystallized_state,
45+
genesis_active_state):
46+
chaindb = BeaconChainDB(base_db)
47+
chaindb.persist_block(genesis_block)
48+
chaindb.persist_crystallized_state(genesis_crystallized_state)
49+
chaindb.persist_active_state(genesis_active_state, genesis_crystallized_state.hash)
50+
return chaindb

tests/beacon/state_machines/test_proposer.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,13 @@
33
from eth.constants import (
44
ZERO_HASH32,
55
)
6-
from eth.beacon.state_machines.forks.serenity import (
7-
SerenityBeaconStateMachine,
8-
)
9-
from eth.beacon.db.chain import BeaconChainDB
106

117
from eth.beacon.helpers import (
128
get_block_committees_info,
139
get_new_recent_block_hashes,
1410
)
1511

1612

17-
@pytest.fixture
18-
def fixture_sm_class(config):
19-
return SerenityBeaconStateMachine.configure(
20-
__name__='SerenityBeaconStateMachineForTesting',
21-
config=config,
22-
)
23-
24-
25-
@pytest.fixture
26-
def initial_chaindb(base_db,
27-
genesis_block,
28-
genesis_crystallized_state,
29-
genesis_active_state):
30-
chaindb = BeaconChainDB(base_db)
31-
chaindb.persist_block(genesis_block)
32-
chaindb.persist_crystallized_state(genesis_crystallized_state)
33-
chaindb.persist_active_state(genesis_active_state, genesis_crystallized_state.hash)
34-
return chaindb
35-
36-
3713
@pytest.mark.parametrize(
3814
(
3915
'num_validators,'

tests/beacon/state_machines/test_state_machines.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
from eth.constants import (
22
ZERO_HASH32,
33
)
4+
45
from eth.beacon.state_machines.forks.serenity import (
56
SerenityBeaconStateMachine,
67
)
7-
from eth.beacon.db.chain import BeaconChainDB
88

99

10-
def test_state_machine(base_db,
10+
def test_state_machine(initial_chaindb,
1111
genesis_block,
12-
genesis_crystallized_state,
13-
genesis_active_state):
14-
chaindb = BeaconChainDB(base_db)
15-
chaindb.persist_block(genesis_block)
16-
chaindb.persist_crystallized_state(genesis_crystallized_state)
17-
chaindb.persist_active_state(genesis_active_state, genesis_crystallized_state.hash)
12+
genesis_crystallized_state):
13+
chaindb = initial_chaindb
1814

1915
block_1 = genesis_block.copy(
2016
parent_hash=genesis_block.hash,

0 commit comments

Comments
 (0)