0

I have wrote this very basic test scenario with brownie:

import pytest

def test_set_get_18(tcontrat1,accounts):
    tcontrat1.set(18, {'from': accounts[0],'gas_limit':100})
    assert tcontrat1.get() == 18

As you can see, i set a gas limit.

The transaction will fail, this is normal. I want to check in my test it will fail.

Here is what i've tried:

import pytest
import brownie 

def test_set_get_18(tcontrat1,accounts):
    with brownie.reverts():
      tcontrat1.set(18, {'from': accounts[0],'gas_limit':100})

It does not work, the test scenario fails with the message:

ValueError: base fee exceeds gas limit

I have also tried this:

def test_set_get_18(tcontrat1,accounts):
    with brownie.reverts("base fee exceeds gas limit"):
      tcontrat1.set(18, {'from': accounts[0],'gas_limit':100})

The error is not handled or catched by brownie. How should i do ? I want to test that this transaction should fail because of gas limit.

Thanks for your help.

Your Answer

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

Browse other questions tagged or ask your own question.