# Testing Client Protocol Interoperability This document shows some commands that can be used to test the individual protocol messages per network (Discovery v5 and Portal networks). Two ways are explained, the first by keeping a node running and interacting with it through the JSON-RPC service. The second by running cli applications that attempt to send 1 specific message and then shutdown. The first is more powerful and complete, the second might be easier to do some quick testing. ## Run Fluffy and test protocol messages launched via JSON-RPC API First build Fluffy as explained [here](../README.md#build-fluffy-client). Next run it with the JSON-RPC server enabled: ```bash ./build/fluffy --rpc --bootstrap-node:enr: ``` ### Testing Discovery v5 Layer Testing the Discovery v5 protocol messages: ```bash # Ping / Pong curl -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"discv5_ping","params":["enr:"]}' http://localhost:8545 | jq # FindNode / Nodes # Extra parameter is an array of requested logarithmic distances curl -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"discv5_findNode","params":["enr:", [254, 255, 256]]}' http://localhost:8545 | jq # TalkReq / TalkResp # Extra parameters are the protocol id and the request byte string, hex encoded. curl -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"discv5_talkReq","params":["enr:", "", ""]}' http://localhost:8545 | jq # Read out the discover v5 routing table contents curl -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"discv5_routingTableInfo","params":[]}' http://localhost:8545 | jq ``` ### Testing Portal Networks Layer Testing the Portal wire protocol messages: ```bash # Ping / Pong curl -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"portal_state_ping","params":["enr:"]}' http://localhost:8545 | jq # FindNode / Nodes # Extra parameter is an array of requested logarithmic distances curl -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"portal_state_findNodes","params":["enr:", [254, 255, 256]]}' http://localhost:8545 | jq # Read out the Portal state network routing table contents curl -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"portal_state_routingTableInfo","params":[]}' http://localhost:8545 | jq ``` > The `portal_state_` prefix can be replaced for testing other networks such as `portal_history_`. ## Test Discovery and Portal Wire protocol messages through cli tools ### Testing Discovery v5 Layer: dcli ```bash # Build dcli from nim-eth vendor module (cd vendor/nim-eth/; ../../env.sh nimble build_dcli) ``` With the `dcli` tool you can test the individual Discovery v5 protocol messages, e.g.: ```bash # Test Discovery Ping, should print the content of ping message ./vendor/nim-eth/eth/p2p/discoveryv5/dcli ping enr: # Test Discovery FindNode, should print the content of the returned ENRs # Default a distance of 256 is requested, change this with --distance argument ./vendor/nim-eth/eth/p2p/discoveryv5/dcli findnode enr: # Test Discovery TalkReq, should print the TalkResp content ./vendor/nim-eth/eth/p2p/discoveryv5/dcli talkreq enr: ``` > Each `dcli` run will default generate a new network key and thus a new node id and ENR. ### Testing Portal Networks Layer: portalcli ```bash # Build portalcli make fluffy-tools ``` With the `portalcli` tool you can test the individual Portal wire protocol messages, e.g.: ```bash # Test Portal wire Ping, should print the content of ping message ./build/portalcli ping enr: # Test Portal wire FindNode, should print the content of the returned ENRs # Default a distance of 256 is requested, change this with --distance argument ./build/portalcli findnodes enr: # Test Portal wire FindContent, should print the returned content ./build/portalcli findcontent enr: # Default the State network is tested, but you can provide another protocol id ./build/portalcli ping enr: --protocol-id:0x500B ``` > Each `portalcli` run will default generate a new network key and thus a new node id and ENR.