From 5444fa50b93dbcbd6a08c75da3eccc32490fb2b2 Mon Sep 17 00:00:00 2001 From: Matheus Degiovani Date: Tue, 10 Aug 2021 16:50:45 -0300 Subject: [PATCH] rpctest: Add P2PAddress() function. This allows returning the P2P address of the given harness node, which is needed when trying to test third party services that connect via the P2P network via rpctest (e.g. SPV wallets). --- rpctest/rpc_harness.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rpctest/rpc_harness.go b/rpctest/rpc_harness.go index 51017e5a..10036884 100644 --- a/rpctest/rpc_harness.go +++ b/rpctest/rpc_harness.go @@ -419,6 +419,16 @@ func (h *Harness) RPCConfig() rpcclient.ConnConfig { return h.node.config.rpcConnConfig() } +// P2PAddress returns the harness node's configured listening address for P2P +// connections. +// +// Note that to connect two different harnesses, it's preferable to use the +// ConnectNode() function, which handles cases like already connected peers and +// ensures the connection actually takes place. +func (h *Harness) P2PAddress() string { + return h.node.config.listen +} + // generateListeningAddresses returns two strings representing listening // addresses designated for the current rpc test. If there haven't been any // test instances created, the default ports are used. Otherwise, in order to