nim-codex/tests/codex/blockexchange/protobuf/testpayments.nim

41 lines
1.1 KiB
Nim
Raw Permalink Normal View History

2021-04-07 10:19:00 +00:00
import pkg/chronos
import pkg/stew/byteutils
import pkg/codex/stores
import ../../../asynctest
2021-04-07 10:19:00 +00:00
import ../../examples
import ../../helpers
2021-04-07 10:19:00 +00:00
checksuite "account protobuf messages":
2021-04-07 10:19:00 +00:00
let account = Account(address: EthAddress.example)
let message = AccountMessage.init(account)
2021-04-07 10:19:00 +00:00
test "encodes recipient of payments":
check message.address == @(account.address.toArray)
2021-04-07 10:19:00 +00:00
test "decodes recipient of payments":
check Account.init(message).?address == account.address.some
2021-04-07 10:19:00 +00:00
test "fails to decode when address has incorrect number of bytes":
var incorrect = message
incorrect.address.del(0)
check Account.init(incorrect).isNone
checksuite "channel update messages":
let state = SignedState.example
let update = StateChannelUpdate.init(state)
test "encodes a nitro signed state":
check update.update == state.toJson.toBytes
test "decodes a channel update":
check SignedState.init(update) == state.some
test "fails to decode incorrect channel update":
var incorrect = update
incorrect.update.del(0)
check SignedState.init(incorrect).isNone