net: add connect() and getsockopt() wrappers to Sock
Extend the Sock class with wrappers to connect() and getsockopt().
This will make it possible to mock code which uses those.
https://github.com/bitcoin/bitcoin/pull/21387/commits/b5861100f85fef77b00f55dcdf01ffb4a2a112d8
net: change ConnectSocketDirectly() to take a Sock argument
Change ConnectSocketDirectly() to take a Sock argument instead of a
bare SOCKET. With this, use the Sock's (possibly mocked) methods
Connect(), Wait() and GetSockOpt() instead of calling the OS
functions directly.
https://github.com/bitcoin/bitcoin/pull/21387/commits/82d360b5a88d9057b6c09b61cd69e426c7a2412d
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.
https://github.com/bitcoin/bitcoin/pull/21387/commits/9947e44de0cbd79e99d883443a9ac441d8c69713
test: add I2P test for a runaway SAM proxy
Add a regression test for https://github.com/bitcoin/bitcoin/pull/21407.
The test creates a socket that, upon read, returns some data, but never
the expected terminator \n, injects that socket into the I2P code and
expects i2p::sam::Session::Connect() to fail, printing a specific
error message to the log.
https://github.com/bitcoin/bitcoin/pull/21387/commits/40316a37cb02cf8a9a8b2cbd4d7153ffa57e7ec5
This is a partial backport of core#21387, without the fuzzer changes.
Depends on D11037