Dmitriy Ryajov bd594c9aaf
Create memory-leak detecting test suite (#226)
* adding tracker for streamstore

* adding tracker tests

* Sets up tracker helper functions and closes streams in testnode.nim

* Deploying checksuite for memory leak tracker checking.

* Successfully deploys checksuite and asyncchecksuite.

* Fix leak in testpor.nim

* Fixes leaked storestream in testnetwork.nim

* Fixes integration tests

* Cleanup

* cleanup comment by Mark

---------

Co-authored-by: benbierens <thatbenbierens@gmail.com>
2023-06-22 12:01:21 -06:00

35 lines
958 B
Nim

import std/unittest
import pkg/codex/stores
import ../../examples
import ../../helpers
checksuite "engine payments":
let address = EthAddress.example
let amount = 42.u256
var wallet: WalletRef
var peer: BlockExcPeerCtx
setup:
wallet = WalletRef.example
peer = BlockExcPeerCtx.example
peer.account = Account(address: address).some
test "pays for received blocks":
let payment = !wallet.pay(peer, amount)
let balances = payment.state.outcome.balances(Asset)
let destination = address.toDestination
check !balances[destination] == amount
test "no payment when no account is set":
peer.account = Account.none
check wallet.pay(peer, amount).isFailure
test "uses same channel for consecutive payments":
let payment1, payment2 = wallet.pay(peer, amount)
let channel1 = payment1.?state.?channel.?getChannelId
let channel2 = payment2.?state.?channel.?getChannelId
check channel1 == channel2