mirror of
https://github.com/status-im/nim-codex.git
synced 2025-01-22 08:39:14 +00:00
2fb39ca4a3
* use PeerInfo in event handlers * use CidV1 and raw multicodec as default * add block stream abstraction * raises defect * adding dataset abstraction * move blockstream into own dir * reorg files and fix tests * rename dataset to blockset * wip * wip * adding basic test for treehash algo * run blockset tests along with with the rest * remove obsolete contents * fix chunker tests * rename bitswap and move to stores * rename bitwsap to blockexc and move to stores * moare project structure reorg
34 lines
933 B
Nim
34 lines
933 B
Nim
import std/unittest
|
|
|
|
import pkg/dagger/stores
|
|
import ../../examples
|
|
|
|
suite "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
|