mirror of https://github.com/status-im/nim-eth.git
28 lines
937 B
Nim
28 lines
937 B
Nim
import
|
|
testutils/fuzzing, stew/byteutils,
|
|
eth/rlp, eth/p2p/discoveryv5/[encoding, types]
|
|
|
|
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)
|
|
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")
|