mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-15 17:35:45 +00:00
chore: run nph linter manually
This commit is contained in:
parent
d7f2a33414
commit
363d56c980
@ -1,3 +1 @@
|
||||
import
|
||||
./test_rpc_codec,
|
||||
./test_poc
|
||||
import ./test_rpc_codec, ./test_poc
|
||||
|
@ -26,7 +26,6 @@ const TxHashSimpleTransfer* =
|
||||
const EthClient = "https://sepolia.infura.io/v3/470c2e9a16f24057aee6660081729fb9"
|
||||
|
||||
suite "Waku Incentivization PoC Eligibility Proofs":
|
||||
|
||||
## Tests for service incentivization PoC.
|
||||
## In a client-server interaction, a client submits an eligibility proof to the server.
|
||||
## The server provides the service if and only if the proof is valid.
|
||||
|
@ -1,23 +1,12 @@
|
||||
import
|
||||
std/options,
|
||||
testutils/unittests,
|
||||
chronos,
|
||||
libp2p/crypto/crypto,
|
||||
web3
|
||||
|
||||
import
|
||||
waku/incentivization/[
|
||||
rpc,
|
||||
rpc_codec,
|
||||
common
|
||||
]
|
||||
import std/options, testutils/unittests, chronos, libp2p/crypto/crypto, web3
|
||||
|
||||
import waku/incentivization/[rpc, rpc_codec, common]
|
||||
|
||||
suite "Waku Incentivization Eligibility Codec":
|
||||
|
||||
asyncTest "encode eligibility proof from txid":
|
||||
let txHash = TxHash.fromHex(
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000000")
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||
)
|
||||
let txHashAsBytes = @(txHash.bytes())
|
||||
let eligibilityProof = EligibilityProof(proofOfPayment: some(txHashAsBytes))
|
||||
let encoded = encode(eligibilityProof)
|
||||
@ -31,5 +20,3 @@ suite "Waku Incentivization Eligibility Codec":
|
||||
let decoded = EligibilityStatus.decode(encoded.buffer).get()
|
||||
check:
|
||||
eligibilityStatus == decoded
|
||||
|
||||
|
||||
|
@ -2,20 +2,15 @@ import std/options, chronos
|
||||
|
||||
import waku/incentivization/[rpc, txid_proof]
|
||||
|
||||
proc new*(
|
||||
T: type EligibilityStatus,
|
||||
isEligible: bool
|
||||
): T =
|
||||
proc new*(T: type EligibilityStatus, isEligible: bool): T =
|
||||
if isEligible:
|
||||
EligibilityStatus(
|
||||
statusCode: uint32(200),
|
||||
statusDesc: some("OK"))
|
||||
EligibilityStatus(statusCode: uint32(200), statusDesc: some("OK"))
|
||||
else:
|
||||
EligibilityStatus(
|
||||
statusCode: uint32(402),
|
||||
statusDesc: some("Payment Required"))
|
||||
EligibilityStatus(statusCode: uint32(402), statusDesc: some("Payment Required"))
|
||||
|
||||
proc isEligible*(eligibilityProof: EligibilityProof, ethClient: string): Future[bool] {.async.} =
|
||||
proc isEligible*(
|
||||
eligibilityProof: EligibilityProof, ethClient: string
|
||||
): Future[bool] {.async.} =
|
||||
## We consider a tx eligible,
|
||||
## in the context of service incentivization PoC,
|
||||
## if it is confirmed and pays the expected amount to the server's address.
|
||||
|
@ -25,7 +25,8 @@ proc checkTxIdIsEligible(txHash: TxHash, ethClient: string): Future[bool] {.asyn
|
||||
let hasExpectedValue = (txValue == 200500000000005063.u256)
|
||||
# check that the to address is "as expected" (hard-coded for now)
|
||||
let toAddress = toAddressOption.get()
|
||||
let hasExpectedToAddress = (toAddress == Address.fromHex("0x5e809a85aa182a9921edd10a4163745bb3e36284"))
|
||||
let hasExpectedToAddress =
|
||||
(toAddress == Address.fromHex("0x5e809a85aa182a9921edd10a4163745bb3e36284"))
|
||||
defer:
|
||||
await web3.close()
|
||||
return hasExpectedValue and hasExpectedToAddress
|
||||
|
Loading…
x
Reference in New Issue
Block a user