aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2021-03-04 14:31:49 +0100
committerVasil Dimov <vd@FreeBSD.org>2021-03-16 13:59:18 +0100
commit9947e44de0cbd79e99d883443a9ac441d8c69713 (patch)
tree8d60e4c979aa3fe1cf383e108a4b35b42df63614 /src/net.cpp
parent82d360b5a88d9057b6c09b61cd69e426c7a2412d (diff)
downloadbitcoin-9947e44de0cbd79e99d883443a9ac441d8c69713.tar.xz
i2p: use pointers to Sock to accommodate mocking
Change the types of `i2p::Connection::sock` and `i2p::sam::Session::m_control_sock` from `Sock` to `std::unique_ptr<Sock>`. Using pointers would allow us to sneak `FuzzedSock` instead of `Sock` and have the methods of the former called. After this change a test only needs to replace `CreateSock()` with a function that returns `FuzzedSock`.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 36065118d7..6ff51057b1 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -432,7 +432,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
i2p::Connection conn;
if (m_i2p_sam_session->Connect(addrConnect, conn, proxyConnectionFailed)) {
connected = true;
- sock = std::make_unique<Sock>(std::move(conn.sock));
+ sock = std::move(conn.sock);
addr_bind = CAddress{conn.me, NODE_NONE};
}
} else if (GetProxy(addrConnect.GetNetwork(), proxy)) {
@@ -2221,7 +2221,7 @@ void CConnman::ThreadI2PAcceptIncoming()
continue;
}
- CreateNodeFromAcceptedSocket(conn.sock.Release(), NetPermissionFlags::PF_NONE,
+ CreateNodeFromAcceptedSocket(conn.sock->Release(), NetPermissionFlags::PF_NONE,
CAddress{conn.me, NODE_NONE}, CAddress{conn.peer, NODE_NONE});
}
}