The existing functional test framework uses the addnode RPC to spin up manual connections between bitcoind nodes. This limits our ability to add integration tests for our networking code, which often executes different code paths for different connection types.
This PR enables creating outbound & block-relay-only P2P connections in the functional tests. This allows us to increase our p2p test coverage, since we can now verify expectations around these connection types.
This builds out the prototype proposed by ajtowns in #14210. 🙌🏽
An overview of this branch:
- introduces a new test-only RPC function addconnectionwhich initiates opening anoutboundorblock-relay-onlyconnection. (conceptually similar toaddnodebut for different connection types & restricted to regtest)
- adds test_frameworksupport so a mininode can open anoutbound/block-relay-onlyconnection to aP2PInterface/P2PConnection.
- updates p2p_blocksonlytests to create ablock-relay-onlyconnection & verify expectations around transaction relay.
- introduces p2p_add_connectionstest that checks the behaviors of the newly introducedadd_outbound_p2p_connectiontest framework function.
With these changes, there are many more behaviors that we can add integration tests for. The blocksonly updates is just one example.
Huge props to ajtowns for conceiving the approach & providing me feedback as I’ve built out this branch. Also thank you to jnewbery for lots of thoughtful input along the way.