@@ -111,8 +111,10 @@ def test_blockchain_fixtures(fixture_data, fixture):
111111 # 2 - loop over blocks:
112112 # - apply transactions
113113 # - mine block
114- # 4 - profit!!
114+ # 3 - diff resulting state with expected state
115+ # 4 - check that all previous blocks were valid
115116
117+ mined_blocks = list ()
116118 for block_fixture in fixture ['blocks' ]:
117119 should_be_good_block = 'blockHeader' in block_fixture
118120
@@ -121,8 +123,12 @@ def test_blockchain_fixtures(fixture_data, fixture):
121123 continue
122124
123125 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 ))
126132 else :
127133 try :
128134 apply_fixture_block_to_chain (block_fixture , chain )
@@ -133,6 +139,10 @@ def test_blockchain_fixtures(fixture_data, fixture):
133139 raise AssertionError ("Block should have caused a validation error" )
134140
135141 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'
137145
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