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

39 lines
1.1 KiB
Nim

import pkg/asynctest
import pkg/chronos
import pkg/stew/byteutils
import ../../examples
import ../../helpers
import pkg/codex/stores
checksuite "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
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