2020-07-14 20:56:34 +00:00
|
|
|
import
|
|
|
|
testutils/fuzzing, stew/byteutils,
|
2021-02-02 21:47:21 +00:00
|
|
|
eth/rlp, eth/p2p/discoveryv5/[encoding, messages]
|
2020-07-14 20:56:34 +00:00
|
|
|
|
|
|
|
test:
|
|
|
|
block:
|
|
|
|
let decoded = decodeMessage(payload)
|
|
|
|
|
|
|
|
if decoded.isOK():
|
|
|
|
let message = decoded.get()
|
|
|
|
var encoded: seq[byte]
|
|
|
|
case message.kind
|
|
|
|
of unused: break
|
|
|
|
of ping: encoded = encodeMessage(message.ping, message.reqId)
|
|
|
|
of pong: encoded = encodeMessage(message.pong, message.reqId)
|
|
|
|
of findNode: encoded = encodeMessage(message.findNode, message.reqId)
|
|
|
|
of nodes: encoded = encodeMessage(message.nodes, message.reqId)
|
2020-11-13 11:33:07 +00:00
|
|
|
of talkreq: encoded = encodeMessage(message.talkreq, message.reqId)
|
|
|
|
of talkresp: encoded = encodeMessage(message.talkresp, message.reqId)
|
2020-07-14 20:56:34 +00:00
|
|
|
of regtopic, ticket, regconfirmation, topicquery:
|
|
|
|
break
|
|
|
|
|
|
|
|
# This will hit assert because of issue:
|
|
|
|
# https://github.com/status-im/nim-eth/issues/255
|
|
|
|
# if encoded != payload:
|
|
|
|
# echo "payload: ", toHex(payload)
|
|
|
|
# echo "encoded: ", toHex(encoded)
|
|
|
|
|
|
|
|
# doAssert(false, "re-encoded result does not equal original payload")
|