Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save iamdefinitelyahuman/ea85770a940cc7422ce30c017ac7906b to your computer and use it in GitHub Desktop.

Select an option

Save iamdefinitelyahuman/ea85770a940cc7422ce30c017ac7906b to your computer and use it in GitHub Desktop.
from brownie import accounts
from brownie.test import given, strategy
@given(
receiver=strategy('address', exclude=accounts[0]),
amount=strategy('uint256', max_value=10**18),
)
def test_transfer_adjusts_receiver_balance(accounts, token, receiver, amount):
balance = token.balanceOf(receiver)
token.transfer(to, amount, {'from': accounts[0]})
assert token.balanceOf(receiver) == balance + amount
@julianmrodri

Copy link
Copy Markdown

Hi, if I try to run this I get the error below.

../tests/test_prop.py:43: in <module>
    receiver=strategy('address', exclude=accounts[0]),
E   IndexError: list index out of range

Is it possible that you cannot use accounts[0] in the context of a strategy? Seems it has no value, and the tests ASSIGNS accounts[0] as a valid value even in this example.

Am I missing something? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment