nwaku/tests/incentivization/test_rpc_codec.nim
Sergei Tikhomirov 65530264d5
feat(incentivization): add codec for eligibility proof and status (#2419)
* incentivization: add codec for eligibility proofs

* add codec for eligibility proof and eligibility status

* address minor comments

* make status code mandatory in eligibility status
2024-03-26 18:25:42 +01:00

33 lines
858 B
Nim

import
std/options,
std/strscans,
testutils/unittests,
chronicles,
chronos,
libp2p/crypto/crypto
import
../../../waku/incentivization/rpc,
../../../waku/incentivization/rpc_codec
suite "Waku Incentivization Eligibility Codec":
asyncTest "encode eligibility proof":
var byteSequence: seq[byte] = @[1, 2, 3, 4, 5, 6, 7, 8]
let epRpc = EligibilityProof(proofOfPayment: some(byteSequence))
let encoded = encode(epRpc)
let decoded = EligibilityProof.decode(encoded.buffer).get()
check:
epRpc == decoded
asyncTest "encode eligibility status":
let esRpc = EligibilityStatus(
statusCode: uint32(200),
statusDesc: some("OK")
)
let encoded = encode(esRpc)
let decoded = EligibilityStatus.decode(encoded.buffer).get()
check:
esRpc == decoded