mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-16 07:56:16 +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
38 lines
1.0 KiB
Nim
38 lines
1.0 KiB
Nim
import pkg/asynctest
|
|
import pkg/chronos
|
|
import pkg/stew/byteutils
|
|
import ../../examples
|
|
import pkg/dagger/stores
|
|
|
|
suite "account protobuf messages":
|
|
|
|
let account = Account(address: EthAddress.example)
|
|
let message = AccountMessage.init(account)
|
|
|
|
test "encodes recipient of payments":
|
|
check message.address == @(account.address.toArray)
|
|
|
|
test "decodes recipient of payments":
|
|
check Account.init(message).?address == account.address.some
|
|
|
|
test "fails to decode when address has incorrect number of bytes":
|
|
var incorrect = message
|
|
incorrect.address.del(0)
|
|
check Account.init(incorrect).isNone
|
|
|
|
suite "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
|