@@ -111,8 +111,10 @@ def test_blockchain_fixtures(fixture_data, fixture):
111
111
# 2 - loop over blocks:
112
112
# - apply transactions
113
113
# - mine block
114
- # 4 - profit!!
114
+ # 3 - diff resulting state with expected state
115
+ # 4 - check that all previous blocks were valid
115
116
117
+ mined_blocks = list ()
116
118
for block_fixture in fixture ['blocks' ]:
117
119
should_be_good_block = 'blockHeader' in block_fixture
118
120
@@ -121,8 +123,12 @@ def test_blockchain_fixtures(fixture_data, fixture):
121
123
continue
122
124
123
125
if should_be_good_block :
124
- (block , mined_block , block_rlp ) = apply_fixture_block_to_chain (block_fixture , chain )
125
- assert_mined_block_unchanged (block , mined_block )
126
+ (block , mined_block , block_rlp ) = apply_fixture_block_to_chain (
127
+ block_fixture ,
128
+ chain ,
129
+ perform_validation = False # we manually validate below
130
+ )
131
+ mined_blocks .append ((block , mined_block ))
126
132
else :
127
133
try :
128
134
apply_fixture_block_to_chain (block_fixture , chain )
@@ -133,6 +139,10 @@ def test_blockchain_fixtures(fixture_data, fixture):
133
139
raise AssertionError ("Block should have caused a validation error" )
134
140
135
141
latest_block_hash = chain .get_canonical_block_by_number (chain .get_block ().number - 1 ).hash
136
- assert latest_block_hash == fixture ['lastblockhash' ]
142
+ if latest_block_hash != fixture ['lastblockhash' ]:
143
+ verify_account_db (fixture ['postState' ], chain .get_vm ().state .account_db )
144
+ assert False , 'the state must be different if the hashes are'
137
145
138
- verify_account_db (fixture ['postState' ], chain .get_vm ().state .account_db )
146
+ for block , mined_block in mined_blocks :
147
+ assert_mined_block_unchanged (block , mined_block )
148
+ chain .validate_block (block )
0 commit comments