Skip to content

Commit

Permalink
fix: more logging for set balance
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita P committed Dec 23, 2024
1 parent 961a7f0 commit 33375bd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ def set_balance_in_wei(address, balance):
account = accounts.at(address, force=True)
providers = ["evm_setAccountBalance", "hardhat_setBalance", "anvil_setBalance"]

log_string = ""

for provider in providers:
if account.balance() == balance:
break

try:
web3.provider.make_request(provider, [address, hex(balance)])
resp = web3.provider.make_request(provider, [address, hex(balance)])
except ValueError as e:
log_string += f"ERR1: {provider}: {e.args[0].get('message')}, RESP: {resp}"
if e.args[0].get("message") != f"Method {provider} is not supported":
raise e

assert account.balance() == balance, f"FSB: EXP: {balance} ACT: {account.balance()} ADDR: {address}"
assert account.balance() == balance, f"FSB: EXP: {balance} ACT: {account.balance()} ADDR: {address}, ERR: {log_string}"
return account


Expand Down

0 comments on commit 33375bd

Please sign in to comment.