2021-03-23 08:04:51 +00:00
|
|
|
{.used.}
|
|
|
|
|
2020-11-13 06:02:17 +00:00
|
|
|
import
|
2022-11-04 09:52:08 +00:00
|
|
|
std/tables,
|
2022-11-21 08:36:41 +00:00
|
|
|
stew/shims/net as stewNet,
|
2021-03-26 09:52:04 +00:00
|
|
|
testutils/unittests,
|
2022-11-21 08:36:41 +00:00
|
|
|
chronos,
|
|
|
|
chronicles,
|
2020-11-21 05:31:48 +00:00
|
|
|
libp2p/switch,
|
|
|
|
libp2p/protobuf/minprotobuf,
|
2022-11-08 15:10:23 +00:00
|
|
|
libp2p/stream/bufferstream,
|
|
|
|
libp2p/stream/connection,
|
|
|
|
libp2p/crypto/crypto,
|
|
|
|
libp2p/crypto/secp,
|
2022-09-20 09:39:52 +00:00
|
|
|
eth/keys
|
|
|
|
import
|
2022-11-08 15:10:23 +00:00
|
|
|
../../waku/v2/node/waku_node,
|
2020-11-23 02:27:45 +00:00
|
|
|
../../waku/v2/protocol/waku_swap/waku_swap,
|
2021-10-06 12:29:08 +00:00
|
|
|
../../waku/v2/utils/peers,
|
2022-11-21 08:36:41 +00:00
|
|
|
../test_helpers,
|
2022-10-21 13:01:39 +00:00
|
|
|
./utils,
|
|
|
|
./testlib/common
|
2022-09-21 16:27:40 +00:00
|
|
|
|
2020-11-13 06:02:17 +00:00
|
|
|
|
|
|
|
procSuite "Waku SWAP Accounting":
|
|
|
|
test "Handshake Encode/Decode":
|
|
|
|
let
|
|
|
|
beneficiary = @[byte 0, 1, 2]
|
|
|
|
handshake = Handshake(beneficiary: beneficiary)
|
|
|
|
pb = handshake.encode()
|
|
|
|
|
|
|
|
let decodedHandshake = Handshake.init(pb.buffer)
|
|
|
|
|
|
|
|
check:
|
|
|
|
decodedHandshake.isErr == false
|
|
|
|
decodedHandshake.get().beneficiary == beneficiary
|
|
|
|
|
|
|
|
test "Cheque Encode/Decode":
|
|
|
|
let
|
|
|
|
amount = 1'u32
|
|
|
|
date = 9000'u32
|
|
|
|
beneficiary = @[byte 0, 1, 2]
|
|
|
|
cheque = Cheque(beneficiary: beneficiary, amount: amount, date: date)
|
|
|
|
pb = cheque.encode()
|
|
|
|
|
|
|
|
let decodedCheque = Cheque.init(pb.buffer)
|
|
|
|
|
|
|
|
check:
|
|
|
|
decodedCheque.isErr == false
|
|
|
|
decodedCheque.get() == cheque
|