2019-10-02 09:55:49 +00:00
|
|
|
import
|
2021-09-07 14:00:01 +00:00
|
|
|
std/[options, sequtils],
|
|
|
|
chronicles, testutils/fuzzing,
|
|
|
|
../../../eth/p2p/rlpx_protocols/whisper_protocol as whisper,
|
|
|
|
../../../eth/keys
|
2019-10-02 09:55:49 +00:00
|
|
|
|
|
|
|
test:
|
|
|
|
let
|
2021-09-07 14:00:01 +00:00
|
|
|
rng = newRng()
|
2019-10-02 09:55:49 +00:00
|
|
|
data = @payload.distribute(2)
|
|
|
|
whisperPayload = Payload(payload: data[0], padding: some(data[1]))
|
2021-09-07 14:00:01 +00:00
|
|
|
encoded = whisper.encode(rng[], whisperPayload)
|
2019-10-02 09:55:49 +00:00
|
|
|
|
|
|
|
decoded = whisper.decode(encoded.get())
|
|
|
|
|
|
|
|
doAssert data[0] == decoded.get().payload
|
|
|
|
if data[1].len > 0:
|
|
|
|
doAssert data[1] == decoded.get().padding.get()
|
|
|
|
else:
|
|
|
|
doAssert decoded.get().padding.isNone()
|