Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
etan-status committed Mar 16, 2024
1 parent 6742f0e commit e616a47
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/test_contracts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ suite "Contracts":
receipt = await web3.deployContract(MetaCoinCode)
cc = receipt.contractAddress.get

let deployedAtBlock = distinctBase(receipt.blockNumber)
echo "Deployed MetaCoin contract: ", cc, " at block ", deployedAtBlock
let deployedAtBlock = receipt.blockNumber
echo "Deployed MetaCoin contract: ", cc, " at block ",
distinctBase(deployedAtBlock)

let ns = web3.contractSender(MetaCoin, cc)

Expand All @@ -225,7 +226,8 @@ suite "Contracts":
fromAddr, toAddr: Address, value: UInt256)
{.raises: [], gcsafe.}:
try:
echo "onTransfer: ", fromAddr, " transferred ", value.toHex, " to ", toAddr
echo "onTransfer: ", fromAddr, " transferred ", value.toHex,
" to ", toAddr
inc notificationsReceived
assert(fromAddr == web3.defaultAccount)
assert((notificationsReceived == 1 and value == 50.u256) or
Expand All @@ -238,12 +240,15 @@ suite "Contracts":

let balNow = await ns.getBalance(web3.defaultAccount).call()
echo "getbalance (now): ", balNow.toHex
let balNew = await ns.getBalance(web3.defaultAccount).call(blockNumber = deployedAtBlock)
let balNew = await ns.getBalance(web3.defaultAccount).call(
blockNumber = deployedAtBlock)
echo "getbalance (after creation): ", balNew.toHex

# Let's try to get the balance at a point in time where the contract was not deployed yet:
# Let's try to get the balance at a point in time where the contract
# was not deployed yet:
try:
let balFirst = await ns.getBalance(web3.defaultAccount).call(blockNumber = 1'u64)
let balFirst = await ns.getBalance(web3.defaultAccount).call(
blockNumber = 1.BlockNumber)
echo "getbalance (first block): ", balFirst.toHex
except CatchableError as err:
echo "getbalance (first block): ", err.msg
Expand Down

0 comments on commit e616a47

Please sign in to comment.