bitcoin/src/common
Ava Chow a945f09fa6
Merge bitcoin/bitcoin#29007: test: create deterministic addrman in the functional tests
2cc8ca19f4 [test] Use deterministic addrman in addrman info tests (stratospher)
a897866109 [test] Restart a node with empty addrman (stratospher)
71c19915c0 [test] Use deterministic addrman in addpeeraddress test (stratospher)
7b868e6b67 Revert "test: avoid non-determinism in asmap-addrman test" (stratospher)
69e091f3e1 [init] Create deterministic addrman in tests using -test=addrman (stratospher)
be25ac3092 [init] Remove -addrmantest command line arg (stratospher)
802e6e128b [init] Add new command line arg for use only in functional tests (stratospher)

Pull request description:

  An address is placed in a `[bucket,position]` in the addrman table (new table or tried table) using the `addpeeraddress` RPC. This `[bucket,position]` is calculated using `nKey`(and other metrics) for the addrman which is chosen randomly during every run.

  Supposing there are 2 addresses to be placed in an addrman table. During every test run, a different `[bucket,position]` would be calculated for each address.These calculated `[bucket,position]` could even be the same for the 2 addresses in some test runs and result in collisions in the addrman. We wouldn't be able to predict when the collisions are going to happen because we can't predict the `nKey` value which is chosen at random. This can cause flaky tests.

  Because of these non deterministic collisions, we are limited in what we can do to test addrman functionality. Currently in our tests don't add a second address to prevent these collisions from happening - we only keep 1 address in the new table and 1 address in the tried table. See https://github.com/bitcoin/bitcoin/pull/26988#discussion_r1091145647, https://github.com/bitcoin/bitcoin/pull/23084, [#22831(comment)](https://github.com/bitcoin/bitcoin/pull/22831/files#r708302639).

  This PR lets us create a deterministic addrman with fixed `nKey` so that we can know the `[bucket,position]` collisions beforehand, safely add more addresses in an addrman table and write more extensive tests.

ACKs for top commit:
  amitiuttarwar:
    ACK 2cc8ca19f4
  achow101:
    ACK 2cc8ca19f4
  0xB10C:
    ACK 2cc8ca19f4
  mzumsande:
    Code Review ACK 2cc8ca19f4

Tree-SHA512: 8acd9bdfe7de1eb44d22373bf13533d8ecf602df966fdd5b8b78afcd8cc35a286c95d2712f67a89473a0d68dded7d38f5599f6e4bf95a6589475444545bfb189
2024-03-11 10:29:31 -04:00
..
args.cpp [init] Create deterministic addrman in tests using -test=addrman 2024-01-08 21:54:56 +05:30
args.h [init] Add new command line arg for use only in functional tests 2024-01-08 21:54:55 +05:30
bloom.cpp Use Txid in COutpoint 2023-11-21 13:15:44 +00:00
bloom.h
config.cpp scripted-diff: move settings to common namespace 2023-05-30 17:26:51 +02:00
init.cpp Merge bitcoin/bitcoin#27302: init: Error if ignored bitcoin.conf file is found 2023-05-26 13:33:42 +01:00
init.h Deduplicate bitcoind and bitcoin-qt init code 2023-02-28 12:04:47 -05:00
interfaces.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
run_command.cpp refactor: remove in-code warning suppression 2023-06-29 14:41:33 +01:00
run_command.h refactor: move run_command from util to common 2022-10-04 21:21:05 +00:00
settings.cpp init: settings, do not load auto-generated warning msg 2024-01-23 21:01:32 -03:00
settings.h scripted-diff: move settings to common namespace 2023-05-30 17:26:51 +02:00
system.cpp scripted-diff: Fix bitcoin_config_h includes 2024-02-13 20:10:44 +00:00
system.h Merge bitcoin/bitcoin#28486: test, bench: Initialize and terminate use of Winsock properly 2023-11-29 17:14:34 +00:00
url.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
url.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00