2024-03-26 18:25:42 +01:00
|
|
|
import
|
|
|
|
std/options,
|
|
|
|
testutils/unittests,
|
|
|
|
chronos,
|
2024-10-31 12:20:07 +01:00
|
|
|
libp2p/crypto/crypto,
|
|
|
|
web3
|
|
|
|
|
|
|
|
import
|
|
|
|
waku/incentivization/[
|
|
|
|
rpc,
|
|
|
|
rpc_codec,
|
|
|
|
common
|
|
|
|
]
|
2024-03-26 18:25:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
suite "Waku Incentivization Eligibility Codec":
|
2024-10-31 12:20:07 +01:00
|
|
|
|
|
|
|
asyncTest "encode eligibility proof from txid":
|
|
|
|
let txHash = TxHash.fromHex(
|
|
|
|
"0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
|
|
let txHashAsBytes = @(txHash.bytes())
|
|
|
|
let eligibilityProof = EligibilityProof(proofOfPayment: some(txHashAsBytes))
|
|
|
|
let encoded = encode(eligibilityProof)
|
2024-07-06 03:33:38 +05:30
|
|
|
let decoded = EligibilityProof.decode(encoded.buffer).get()
|
|
|
|
check:
|
2024-10-31 12:20:07 +01:00
|
|
|
eligibilityProof == decoded
|
|
|
|
|
2024-07-06 03:33:38 +05:30
|
|
|
asyncTest "encode eligibility status":
|
2024-12-11 14:47:13 +01:00
|
|
|
let eligibilityStatus = new(EligibilityStatus, true)
|
2024-10-31 12:20:07 +01:00
|
|
|
let encoded = encode(eligibilityStatus)
|
2024-07-06 03:33:38 +05:30
|
|
|
let decoded = EligibilityStatus.decode(encoded.buffer).get()
|
|
|
|
check:
|
2024-10-31 12:20:07 +01:00
|
|
|
eligibilityStatus == decoded
|
|
|
|
|
|
|
|
|