2021-02-22 15:32:48 +01:00
|
|
|
import std/unittest
|
|
|
|
|
import pkg/nitro/channel
|
|
|
|
|
import pkg/nitro/abi
|
|
|
|
|
import pkg/nimcrypto
|
|
|
|
|
import ./examples
|
|
|
|
|
|
|
|
|
|
suite "channel":
|
|
|
|
|
|
|
|
|
|
let channel = Channel.example
|
|
|
|
|
|
|
|
|
|
test "calculates channel id":
|
|
|
|
|
var writer: AbiWriter
|
2021-02-23 11:34:09 +01:00
|
|
|
writer.startTuple()
|
2021-02-22 15:32:48 +01:00
|
|
|
writer.write(channel.chainId)
|
|
|
|
|
writer.write(channel.participants)
|
|
|
|
|
writer.write(channel.nonce)
|
2021-02-23 11:34:09 +01:00
|
|
|
writer.finishTuple()
|
2021-02-22 15:32:48 +01:00
|
|
|
let encoded = writer.finish()
|
|
|
|
|
let hashed = keccak256.digest(encoded).data
|
|
|
|
|
check getChannelId(channel) == hashed
|
|
|
|
|
|