2020-07-14 20:56:34 +00:00
|
|
|
import
|
2021-09-07 14:00:01 +00:00
|
|
|
testutils/fuzzing,
|
2022-10-10 10:13:20 +00:00
|
|
|
../../../eth/p2p/discoveryv5/messages_encoding
|
2020-07-14 20:56:34 +00:00
|
|
|
|
|
|
|
test:
|
2024-06-27 14:18:21 +00:00
|
|
|
block testBlock:
|
2020-07-14 20:56:34 +00:00
|
|
|
let decoded = decodeMessage(payload)
|
|
|
|
|
2021-12-20 12:14:50 +00:00
|
|
|
if decoded.isOk():
|
2020-07-14 20:56:34 +00:00
|
|
|
let message = decoded.get()
|
|
|
|
var encoded: seq[byte]
|
|
|
|
case message.kind
|
2024-06-27 14:18:21 +00:00
|
|
|
of unused: break testBlock
|
2020-07-14 20:56:34 +00:00
|
|
|
of ping: encoded = encodeMessage(message.ping, message.reqId)
|
|
|
|
of pong: encoded = encodeMessage(message.pong, message.reqId)
|
2022-07-21 08:58:17 +00:00
|
|
|
of findNode: encoded = encodeMessage(message.findNode, message.reqId)
|
2020-07-14 20:56:34 +00:00
|
|
|
of nodes: encoded = encodeMessage(message.nodes, message.reqId)
|
2022-07-21 08:58:17 +00:00
|
|
|
of talkReq: encoded = encodeMessage(message.talkReq, message.reqId)
|
|
|
|
of talkResp: encoded = encodeMessage(message.talkResp, message.reqId)
|
|
|
|
of regTopic, ticket, regConfirmation, topicQuery:
|
2024-06-27 14:18:21 +00:00
|
|
|
break testBlock
|
2020-07-14 20:56:34 +00:00
|
|
|
|
|
|
|
# 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")
|