0

I have create a brownie project with automated tests according to this documentation:

https://vyper.readthedocs.io/en/stable/testing-contracts-brownie.html#writing-a-basic-test

Here is an example:

def test_set(storage_contract, accounts):
    storage_contract.set(10, {'from': accounts[0]})
    ...

As you can see, this line sends a transaction (calling set function). What i want to do is to limit gas units for this transaction.

Is there a way to do that just for this transaction ?

Thanks

0

The last parameter is a dictionary with the transactions parameters, see the documentation for other fields you can include.

def test_set(storage_contract, accounts):
    storage_contract.set(10, {'from': accounts[0], 'gas_limit': 100000})
    ...
5
  • Thanks a lot and is there a way to say account[0] has only 1 ether in his balance ? – Bob5421 Jan 28 at 6:59
  • How can i handle "base fee exceeds gas limit" in automated tests with brownie ? – Bob5421 Jan 28 at 10:14
  • @Bob5421 For 1/ that parameters are transactions properties you cannot change an account balance from there. 2/ the error message says that the limit set is higher than the block limit in the client used (ganache, geth, infura, etc). If the block limit is 10M you cannot set limit to 20M. – Ismael Jan 28 at 20:52
  • For this error message, i want to catch this error message in my test scenario – Bob5421 Jan 28 at 21:32
  • @Bob5421 It is better to ask about the "base fee" error message in a new question. I don't know enough brownie to answer it. – Ismael Jan 29 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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