File tree Expand file tree Collapse file tree 3 files changed +28
-32
lines changed
tests/beacon/state_machines Expand file tree Collapse file tree 3 files changed +28
-32
lines changed Original file line number Diff line number Diff line change 1
1
import pytest
2
2
3
+ from eth .beacon .db .chain import BeaconChainDB
3
4
from eth .beacon .state_machines .configs import BeaconConfig
5
+ from eth .beacon .state_machines .forks .serenity import (
6
+ SerenityBeaconStateMachine ,
7
+ )
4
8
5
9
6
10
@pytest .fixture
@@ -24,3 +28,23 @@ def config(base_reward_quotient,
24
28
SLOT_DURATION = slot_duration ,
25
29
SQRT_E_DROP_TIME = sqrt_e_drop_time ,
26
30
)
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
Original file line number Diff line number Diff line change 3
3
from eth .constants import (
4
4
ZERO_HASH32 ,
5
5
)
6
- from eth .beacon .state_machines .forks .serenity import (
7
- SerenityBeaconStateMachine ,
8
- )
9
- from eth .beacon .db .chain import BeaconChainDB
10
6
11
7
from eth .beacon .helpers import (
12
8
get_block_committees_info ,
13
9
get_new_recent_block_hashes ,
14
10
)
15
11
16
12
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
-
37
13
@pytest .mark .parametrize (
38
14
(
39
15
'num_validators,'
Original file line number Diff line number Diff line change 1
1
from eth .constants import (
2
2
ZERO_HASH32 ,
3
3
)
4
+
4
5
from eth .beacon .state_machines .forks .serenity import (
5
6
SerenityBeaconStateMachine ,
6
7
)
7
- from eth .beacon .db .chain import BeaconChainDB
8
8
9
9
10
- def test_state_machine (base_db ,
10
+ def test_state_machine (initial_chaindb ,
11
11
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
18
14
19
15
block_1 = genesis_block .copy (
20
16
parent_hash = genesis_block .hash ,
You can’t perform that action at this time.
0 commit comments