2019-10-16 09:56:24 +00:00
|
|
|
import
|
2022-06-20 16:10:50 +00:00
|
|
|
testutils/fuzzing, chronos,
|
2021-09-07 14:00:01 +00:00
|
|
|
../../../eth/p2p, ../../../eth/p2p/rlpx, ../../../eth/p2p/private/p2p_types,
|
2022-10-11 03:02:16 +00:00
|
|
|
../../p2p/eth_protocol,
|
2021-09-07 14:00:01 +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:
|
2022-06-20 16:10:50 +00:00
|
|
|
node1 = setupTestNode(rng, eth)
|
|
|
|
node2 = setupTestNode(rng, eth)
|
2019-10-16 09:56:24 +00:00
|
|
|
|
|
|
|
node2.startListening()
|
2023-03-16 15:45:12 +00:00
|
|
|
let res = waitFor node1.rlpxConnect(newNode(node2.toENode()))
|
|
|
|
if res.isErr():
|
|
|
|
quit 1
|
|
|
|
else:
|
|
|
|
peer = res.get()
|
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)
|
2024-08-30 17:27:09 +00:00
|
|
|
waitFor peer.invokeThunk(msgId, msgData)
|
2019-10-16 09:56:24 +00:00
|
|
|
except CatchableError as e:
|
|
|
|
debug "Test caused CatchableError", exception=e.name, trace=e.repr, msg=e.msg
|