@@ -4645,38 +4645,37 @@ def test_eth_call_old_contract_state(
4645
4645
block_hash = current_block ["hash" ]
4646
4646
4647
4647
default_call_result = math_contract .functions .counter ().call ()
4648
- pre_state_change_latest = math_contract .functions .counter ().call (
4648
+ latest_call_result = math_contract .functions .counter ().call (
4649
4649
block_identifier = "latest"
4650
4650
)
4651
4651
4652
- # increment counter and wait 1 second to "mine" txn
4652
+ # increment counter and get tx receipt
4653
4653
tx_hash = math_contract .functions .incrementCounter ().transact (
4654
4654
{"from" : keyfile_account_address }
4655
4655
)
4656
- w3 .eth .wait_for_transaction_receipt (tx_hash )
4657
- # assert block number increased
4658
- assert w3 .eth .get_block ("latest" )["number" ] == block_num + 1
4656
+ tx_receipt = w3 .eth .wait_for_transaction_receipt (tx_hash )
4659
4657
4658
+ # get new state value
4659
+ post_state_block_num_call_result = math_contract .functions .counter ().call (
4660
+ block_identifier = tx_receipt ["blockNumber" ]
4661
+ )
4662
+
4663
+ # call old state values with different block identifiers
4660
4664
block_hash_call_result = math_contract .functions .counter ().call (
4661
4665
block_identifier = block_hash
4662
4666
)
4663
- block_num_call_result = math_contract .functions .counter ().call (
4667
+ pre_state_block_num_call_result = math_contract .functions .counter ().call (
4664
4668
block_identifier = block_num
4665
4669
)
4666
4670
4667
- # assert old state values
4671
+ # assert old state values before incrementing counter
4672
+ assert pre_state_block_num_call_result == post_state_block_num_call_result - 1
4668
4673
assert (
4669
- block_hash_call_result
4670
- == block_num_call_result
4674
+ pre_state_block_num_call_result
4675
+ == block_hash_call_result
4671
4676
== default_call_result
4672
- == pre_state_change_latest
4673
- )
4674
-
4675
- # assert new state value
4676
- post_state_change_latest = math_contract .functions .counter ().call (
4677
- block_identifier = "latest"
4677
+ == latest_call_result
4678
4678
)
4679
- assert post_state_change_latest == pre_state_change_latest + 1
4680
4679
4681
4680
def test_eth_uninstall_filter (self , w3 : "Web3" ) -> None :
4682
4681
filter = w3 .eth .filter ({})
0 commit comments