You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, wondering how we could test whether the other accounts pass as recentWinner when setting our STATIC_RNG to 778.
Right now we use 777 as the random value which with 3 players equals to index 0 therefore our standard account.
I also want to test if another index can be the winner or only our standard account.
Right now it is unclear if the test is indeed doing what we want and not only passing the standard account if selected as winner, right?
I tried below but but that throws a TypeError: 'Account' object is not subscriptable so I might just not know how to get the other added players index:
I also tried to use lottery.players to get a players address but that does not work.
The full code of that test:
deftest_can_pick_winner_correctly():
# ARRANGEifnetwork.show_active() notinLOCAL_BLOCKCHAIN_ENVIRONMENTS:
pytest.skip()
lottery=deploy_lottery()
account=get_account()
# ACTlottery.startLottery({"from": account})
lottery.enterLottery({"from": account, "value": lottery.getEntranceFee()})
lottery.enterLottery(
{"from": get_account(index=1), "value": lottery.getEntranceFee()}
)
lottery.enterLottery(
{"from": get_account(index=2), "value": lottery.getEntranceFee()}
)
fund_with_link(lottery)
starting_balance_of_account=account.balance()
balance_of_lottery=lottery.balance()
transaction=lottery.end({"from": account})
request_id=transaction.events["RequestedRandomness"]["requestId"]
STATIC_RNG=777get_contract("vrf_coordinator").callBackWithRandomness(
request_id, STATIC_RNG, lottery.address, {"from": account}
)
print(lottery.players) # just a test to see how to use it to get a player# ASSERTassertlottery.recentWinner() ==accountassertlottery.balance() ==0assertaccount.balance() ==starting_balance_of_account+balance_of_lottery
The text was updated successfully, but these errors were encountered:
(Around the 08:10:00 mark in the tutorial video.)
Hi, wondering how we could test whether the other accounts pass as recentWinner when setting our STATIC_RNG to 778.
Right now we use 777 as the random value which with 3 players equals to index 0 therefore our standard account.
I also want to test if another index can be the winner or only our standard account.
Right now it is unclear if the test is indeed doing what we want and not only passing the standard account if selected as winner, right?
I tried below but but that throws a
TypeError: 'Account' object is not subscriptable
so I might just not know how to get the other added players index:I also tried to use
lottery.players
to get a players address but that does not work.The full code of that test:
The text was updated successfully, but these errors were encountered: