0

I'm trying to setup a test, where multiple transactions interacting with a contract are mined in the same block (from different accounts). However, the default behavior is to mine a block at each transaction (hence blocks keep incrementing). Anyway to disable this, or force the different transactions from the different accounts to get mined simulatenously in the same block on the forked chain?

Thanks

2 Answers 2

0

Well in ganache you can specify:

-b, --miner.blockTime           Sets the blockTime in seconds for 
                                automatic mining. A blockTime of 0
                                enables "instamine mode", where new 
                                executable transactions will be
                                mined instantly.

Brownie supports passing this flag to ganache development network, see here.

block_time: The time waited between mining blocks. Defaults to instant mining.

2
  • Thank you, yeah i looked at both of these , unfortunately they are not working for some reason... Maybe because it's hardhat, although hardhat have their own disable auto-mining feature, i'll try to debug it, maybe brownie when it connects to hardhats kills the specification Oct 9, 2022 at 5:05
  • if someone uses brownie, turns out the answer is pretty simple and pretty englightining, web3.provider.make_request(method, args) and look up the docs on how to disable instant, for the case of hardhat it's here hardhat.org/hardhat-network/docs/explanation/… Oct 9, 2022 at 8:02
0

Maybe there might be another solution, but, I would create another tester contract who makes multiple interactions with the contract to be tested.

Then call the tester contract to make multiple calls with desired parameters in same block.

1
  • Yeah unfortunately I need different accounts to call the contract, since each caller affects the contract differently Oct 8, 2022 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.