Page MenuHomePhabricator

util: extract {Read,Write}BinaryFile() to its own files
ClosedPublic

Authored by PiRK on Feb 8 2022, 14:20.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC4557b8ebb275: util: extract {Read,Write}BinaryFile() to its own files
Summary

Extract ReadBinaryFile() and WriteBinaryFile() from torcontrol.cpp to its own readwritefile.{h,cpp} files, so that it can be reused from other modules.

This is a backport of core#20685 [1/20]
https://github.com/bitcoin/bitcoin/pull/20685/commits/4cba2fdafa483cbdb70f581174138ec253c80d48

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Feb 8 2022, 14:20

Tail of the build log:

[322/512] Building CXX object src/CMakeFiles/util.dir/util/url.cpp.o
[323/512] Building CXX object src/CMakeFiles/util.dir/util/asmap.cpp.o
[324/512] Building CXX object src/CMakeFiles/util.dir/util/strencodings.cpp.o
[325/512] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/arith_uint256.cpp.o
[326/512] Linking C static library src/secp256k1/libsecp256k1.a
[327/512] Linking C executable src/secp256k1/ecmult-bench
[328/512] Linking C executable src/secp256k1/internal-bench
[329/512] Linking C executable src/secp256k1/sign-bench
[330/512] Linking C executable src/secp256k1/verify-bench
[331/512] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/uint256.cpp.o
[332/512] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/hash.cpp.o
[333/512] Linking C executable src/secp256k1/recover-bench
[334/512] Building CXX object src/CMakeFiles/util.dir/util/sock.cpp.o
[335/512] Building CXX object src/CMakeFiles/util.dir/util/error.cpp.o
[336/512] Building CXX object src/CMakeFiles/util.dir/util/settings.cpp.o
[337/512] Building CXX object src/CMakeFiles/bitcoin-tx.dir/bitcoin-tx.cpp.o
[338/512] Building CXX object src/test/CMakeFiles/testutil.dir/util/str.cpp.o
[339/512] Building CXX object src/CMakeFiles/util.dir/util/message.cpp.o
[340/512] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/util/strencodings.cpp.o
[341/512] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/primitives/transaction.cpp.o
[342/512] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/consensus/tx_check.cpp.o
[343/512] Building CXX object src/test/CMakeFiles/testutil.dir/util/logging.cpp.o
[344/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/context.cpp.o
[345/512] Building CXX object src/test/CMakeFiles/testutil.dir/util/blockfilter.cpp.o
[346/512] Building CXX object src/CMakeFiles/util.dir/util/time.cpp.o
[347/512] Building CXX object src/test/CMakeFiles/testutil.dir/util/transaction_utils.cpp.o
[348/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/coinselection.cpp.o
[349/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/coincontrol.cpp.o
[350/512] Building CXX object src/CMakeFiles/util.dir/util/system.cpp.o
[351/512] Building CXX object src/test/CMakeFiles/testutil.dir/util/net.cpp.o
[352/512] Building CXX object src/test/CMakeFiles/testutil.dir/util/mining.cpp.o
[353/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/bdb.cpp.o
[354/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/db.cpp.o
[355/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/crypter.cpp.o
[356/512] Building CXX object src/test/CMakeFiles/testutil.dir/util/wallet.cpp.o
[357/512] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqabstractnotifier.cpp.o
[358/512] Building CXX object src/test/CMakeFiles/testutil.dir/util/setup_common.cpp.o
[359/512] Building CXX object src/wallet/CMakeFiles/wallet-tool.dir/wallettool.cpp.o
[360/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/sqlite.cpp.o
[361/512] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqnotificationinterface.cpp.o
[362/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/fees.cpp.o
[363/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletutil.cpp.o
[364/512] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqutil.cpp.o
[365/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/load.cpp.o
[366/512] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/dns.cpp.o
[367/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/__/interfaces/wallet.cpp.o
[368/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/salvage.cpp.o
[369/512] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqrpc.cpp.o
[370/512] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqpublishnotifier.cpp.o
[371/512] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/db.cpp.o
[372/512] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/options.cpp.o
[373/512] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/bitcoin.cpp.o
[374/512] Building CXX object src/seeder/CMakeFiles/bitcoin-seeder.dir/main.cpp.o
[375/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/scriptpubkeyman.cpp.o
[376/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletdb.cpp.o
[377/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcdump.cpp.o
[378/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o
[379/512] Building CXX object src/wallet/CMakeFiles/wallet.dir/wallet.cpp.o
ninja: build stopped: cannot make progress due to previous errors.
Build build-clang-tidy failed with exit code 1

Failed tests logs:

====== Bitcoin ABC functional tests: abc_p2p_getavaaddr.py ======

------- Stdout: -------
2022-02-08T14:30:38.559000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20220208_142459/abc_p2p_getavaaddr_191
2022-02-08T14:30:41.492000Z TestFramework.p2p (WARNING): Connection lost to 127.0.0.1:22354 due to [Errno 104] Connection reset by peer
2022-02-08T14:30:43.465000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 132, in main
    self.run_test()
  File "/work/test/functional/abc_p2p_getavaaddr.py", line 198, in run_test
    self.getavaaddr_interval_test()
  File "/work/test/functional/abc_p2p_getavaaddr.py", line 117, in getavaaddr_interval_test
    requester.send_message(msg_getavaaddr())
  File "/usr/lib/python3.7/contextlib.py", line 119, in __exit__
    next(self.gen)
  File "/work/test/functional/test_framework/test_node.py", line 523, in assert_debug_log
    str(expected_msgs), print_log))
  File "/work/test/functional/test_framework/test_node.py", line 211, in _raise_assertion_error
    raise AssertionError(self._node_msg(msg))
AssertionError: [node 0] Expected messages "['Ignoring repeated getavaaddr from peer']" does not partially match log:

 - 


2022-02-08T14:30:43.519000Z TestFramework (INFO): Stopping nodes
------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/test_framework/authproxy.py", line 116, in _request
    self.__conn.request(method, path, postdata, headers)
  File "/usr/lib/python3.7/http/client.py", line 1260, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1306, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1255, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1069, in _send_output
    self.send(chunk)
  File "/usr/lib/python3.7/http/client.py", line 991, in send
    self.sock.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/work/test/functional/abc_p2p_getavaaddr.py", line 207, in <module>
    AvaAddrTest().main()
  File "/work/test/functional/test_framework/test_framework.py", line 152, in main
    exit_code = self.shutdown()
  File "/work/test/functional/test_framework/test_framework.py", line 280, in shutdown
    self.stop_nodes()
  File "/work/test/functional/test_framework/test_framework.py", line 514, in stop_nodes
    node.stop_node(wait=wait, wait_until_stopped=False)
  File "/work/test/functional/test_framework/test_node.py", line 426, in stop_node
    self.stop(wait=wait)
  File "/work/test/functional/test_framework/coverage.py", line 47, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/work/test/functional/test_framework/authproxy.py", line 161, in __call__
    'POST', self.__url.path, postdata.encode('utf-8'))
  File "/work/test/functional/test_framework/authproxy.py", line 122, in _request
    self.__conn.request(method, path, postdata, headers)
  File "/usr/lib/python3.7/http/client.py", line 1260, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1306, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1255, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1030, in _send_output
    self.send(msg)
  File "/usr/lib/python3.7/http/client.py", line 970, in send
    self.connect()
  File "/usr/lib/python3.7/http/client.py", line 942, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.7/socket.py", line 727, in create_connection
    raise err
  File "/usr/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

Each failure log is accessible here:
Bitcoin ABC functional tests: abc_p2p_getavaaddr.py

Fabien requested changes to this revision.Feb 8 2022, 19:29
Fabien added a subscriber: Fabien.

back on your queue

This revision now requires changes to proceed.Feb 8 2022, 19:29

add missing braces (I previously fixed this in the wrong revision D11013)

This revision is now accepted and ready to land.Feb 9 2022, 11:36