@@ -4663,35 +4663,30 @@ def test_eth_call_old_contract_state(
4663
4663
math_contract : "Contract" ,
4664
4664
keyfile_account_address : ChecksumAddress ,
4665
4665
) -> None :
4666
- start_block = w3 .eth .get_block ("latest" )
4667
- block_num = start_block ["number" ]
4668
- block_hash = start_block ["hash" ]
4666
+ latest_block = w3 .eth .get_block ("latest" )
4667
+ block_num = latest_block ["number" ]
4668
+ block_hash = latest_block ["hash" ]
4669
4669
4670
- math_contract .functions .incrementCounter ().transact (
4671
- { "from" : keyfile_account_address }
4670
+ latest_call_result = math_contract .functions .counter ().call (
4671
+ block_identifier = "latest"
4672
4672
)
4673
-
4674
- # This isn't an incredibly convincing test since we can't mine, and
4675
- # the default resolved block is latest, So if block_identifier was ignored
4676
- # we would get the same result. For now, we mostly depend on core tests.
4677
- # Ideas to improve this test:
4678
- # - Enable on-demand mining in more clients
4679
- # - Increment the math contract in all of the fixtures, and check the
4680
- # value in an old block
4681
4673
block_hash_call_result = math_contract .functions .counter ().call (
4682
4674
block_identifier = block_hash
4683
4675
)
4684
4676
block_num_call_result = math_contract .functions .counter ().call (
4685
4677
block_identifier = block_num
4686
4678
)
4687
- latest_call_result = math_contract .functions .counter ().call (
4688
- block_identifier = "latest"
4689
- )
4690
4679
default_call_result = math_contract .functions .counter ().call ()
4680
+
4681
+ # send and wait 1 second to mine
4682
+ math_contract .functions .incrementCounter ().transact (
4683
+ {"from" : keyfile_account_address }
4684
+ )
4685
+ time .sleep (1 )
4686
+
4691
4687
pending_call_result = math_contract .functions .counter ().call (
4692
4688
block_identifier = "pending"
4693
4689
)
4694
-
4695
4690
assert block_hash_call_result == 0
4696
4691
assert block_num_call_result == 0
4697
4692
assert latest_call_result == 0
0 commit comments