From 877ff82ef667112cc9ff4a9d04db6ad26b5d2e78 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Sun, 3 Mar 2024 06:29:51 +0100 Subject: [PATCH] Fix: overrides when simulating transaction --- ethers/contract.nim | 2 +- testmodule/testContracts.nim | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ethers/contract.nim b/ethers/contract.nim index daeecb3..eda4480 100644 --- a/ethers/contract.nim +++ b/ethers/contract.nim @@ -131,7 +131,7 @@ proc send(contract: Contract, let txResp = await signer.sendTransaction(populated) return txResp.some else: - await call(contract, function, parameters) + await call(contract, function, parameters, overrides) return TransactionResponse.none func getParameterTuple(procedure: NimNode): NimNode = diff --git a/testmodule/testContracts.nim b/testmodule/testContracts.nim index 2c85216..e5727a8 100644 --- a/testmodule/testContracts.nim +++ b/testmodule/testContracts.nim @@ -140,6 +140,19 @@ for url in ["ws://localhost:8545", "http://localhost:8545"]: check (await token.balanceOf(accounts[0], beforeMint)) == 0 check (await token.balanceOf(accounts[0], afterMint)) == 100 + test "can simulate transactions for different block heights": + let block1 = await provider.getBlockNumber() + let signer = provider.getSigner(accounts[0]) + discard await token.connect(signer).mint(accounts[0], 100.u256) + let block2 = await provider.getBlockNumber() + + let beforeMint = CallOverrides(blockTag: some BlockTag.init(block1)) + let afterMint = CallOverrides(blockTag: some BlockTag.init(block2)) + + expect ProviderError: + discard await token.transfer(accounts[1], 50.u256, beforeMint) + discard await token.transfer(accounts[1], 50.u256, afterMint) + test "receives events when subscribed": var transfers: seq[Transfer]