mirror of
https://github.com/status-im/nim-eth.git
synced 2025-01-21 20:10:49 +00:00
2c236f6495
Currently only setting `--styleCheck:hint` as there are some dependency fixes required and the compiler seems to trip over the findnode MessageKind, findnode Message field and the findNode proc. Also over protocol.Protocol usage.
30 lines
1.1 KiB
Nim
30 lines
1.1 KiB
Nim
import
|
|
testutils/fuzzing,
|
|
../../../eth/rlp, ../../../eth/p2p/discoveryv5/[encoding, messages]
|
|
|
|
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 talkreq: encoded = encodeMessage(message.talkreq, message.reqId)
|
|
of talkresp: encoded = encodeMessage(message.talkresp, 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")
|