2019-10-16 09:56:24 +00:00
|
|
|
import
|
2020-06-12 14:19:58 +00:00
|
|
|
testutils/fuzzing, chronos,
|
|
|
|
eth/p2p, eth/p2p/rlpx, eth/p2p/private/p2p_types,
|
2019-10-16 09:56:24 +00:00
|
|
|
eth/p2p/rlpx_protocols/[whisper_protocol, eth_protocol],
|
2020-06-12 14:19:58 +00:00
|
|
|
../p2p/p2p_test_helper
|
2019-10-16 09:56:24 +00:00
|
|
|
|
|
|
|
var
|
|
|
|
node1: EthereumNode
|
|
|
|
node2: EthereumNode
|
|
|
|
peer: Peer
|
|
|
|
|
2020-07-07 08:56:26 +00:00
|
|
|
let rng = newRng()
|
2019-10-16 09:56:24 +00:00
|
|
|
# This is not a good example of a fuzzing test and it would be much better
|
|
|
|
# to mock more to get rid of anything sockets, async, etc.
|
|
|
|
# However, it can and has provided reasonably quick results anyhow.
|
|
|
|
init:
|
2020-07-07 08:56:26 +00:00
|
|
|
node1 = setupTestNode(rng, eth, Whisper)
|
|
|
|
node2 = setupTestNode(rng, eth, Whisper)
|
2019-10-16 09:56:24 +00:00
|
|
|
|
|
|
|
node2.startListening()
|
2020-04-06 16:24:15 +00:00
|
|
|
peer = waitFor node1.rlpxConnect(newNode(node2.toENode()))
|
2019-10-16 09:56:24 +00:00
|
|
|
|
|
|
|
test:
|
|
|
|
aflLoop: # This appears to have unstable results with afl-clang-fast, probably
|
|
|
|
# because of undeterministic behaviour due to usage of network/async.
|
|
|
|
try:
|
|
|
|
var (msgId, msgData) = recvMsgMock(payload)
|
|
|
|
waitFor peer.invokeThunk(msgId.int, msgData)
|
|
|
|
except CatchableError as e:
|
|
|
|
debug "Test caused CatchableError", exception=e.name, trace=e.repr, msg=e.msg
|