aboutsummaryrefslogtreecommitdiff
path: root/test/functional/feature_addrman.py
AgeCommit message (Collapse)Author
2024-03-11Merge bitcoin/bitcoin#29007: test: create deterministic addrman in the ↵Ava Chow
functional tests 2cc8ca19f4185490f30a49516c890b2289fbab71 [test] Use deterministic addrman in addrman info tests (stratospher) a8978661093500df8d8dcf2a9c90837afacd0aab [test] Restart a node with empty addrman (stratospher) 71c19915c0c716d6f8a539dd92b8ad41e8c447ee [test] Use deterministic addrman in addpeeraddress test (stratospher) 7b868e6b678502e86571976d696c0e3cb72c0884 Revert "test: avoid non-determinism in asmap-addrman test" (stratospher) 69e091f3e1f65b12cf1804e7d39651f55a01827a [init] Create deterministic addrman in tests using -test=addrman (stratospher) be25ac3092b7755e26e1ec6c33a27cd0e3dd9eac [init] Remove -addrmantest command line arg (stratospher) 802e6e128bba5ffa6d4ec53ff45acccb7cb28f21 [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 2cc8ca19f4185490f30a49516c890b2289fbab71 achow101: ACK 2cc8ca19f4185490f30a49516c890b2289fbab71 0xB10C: ACK 2cc8ca19f4185490f30a49516c890b2289fbab71 mzumsande: Code Review ACK 2cc8ca19f4185490f30a49516c890b2289fbab71 Tree-SHA512: 8acd9bdfe7de1eb44d22373bf13533d8ecf602df966fdd5b8b78afcd8cc35a286c95d2712f67a89473a0d68dded7d38f5599f6e4bf95a6589475444545bfb189
2024-01-23[test] Move MAGIC_BYTES to messages.pystratospher
This avoids circular dependency happening when importing MAGIC_BYTES. Before, p2p.py <--import for EncryptedP2PState-- v2_p2p.py | ^ | | └---------import for MAGIC_BYTES----------┘ Now, MAGIC_BYTES are kept separately in messages.py Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2024-01-08[test] Restart a node with empty addrmanstratospher
Currently in tests where we are interested in contents of addrman, addresses which were added to the node's addrman in previous tests leak into the current test. example: addresses added in addpeeraddress test leak into getaddrmaninfo and getrawaddrman tests. It is cleaner to design the tests to be modular and without such leaks so that we don't need to deal with context from previous tests
2023-10-02Merge bitcoin/bitcoin#28176: tests: add coverage to feature_addrman.pyfanquake
380130d9d70f8f8d395949a51f43806f6e600efa test: add coverage to feature_addrman.py (kevkevin) Pull request description: I added two new tests that will cover the nNew and nTried tests which add coverage to the if block by checking values larger than our range since we only check for negative values now adding coverage to these lines https://github.com/bitcoin/bitcoin/blob/master/src/addrman.cpp#L273 https://github.com/bitcoin/bitcoin/blob/master/src/addrman.cpp#L280 our test seem to only cover the `nTried < 0` and `nNew < 0` scenarios ACKs for top commit: ismaelsadeeq: ACK 380130d9d70f8f8d395949a51f43806f6e600efa, code looks good to me 🍃 . 0xB10C: Re-ACK 380130d9d70f8f8d395949a51f43806f6e600efa Tree-SHA512: a063bd9ca4d2d536a27c8c22a28fb13759a96f19cd8ba6cb8879cf7f65046d4ff6e8f70df17feaffd0d0d08ef914cb18a11258d313a4841c811a7e7ae4df6d5b
2023-10-01test: add coverage to feature_addrman.pykevkevin
I added two new tests that will cover the nNew and nTried tests which add coverage to the if block by checking values larger than our range since we only check for negative values now Co-authored-by: ismaelsadeeq <ask4ismailsadiq@gmail.com>
2023-07-26Merge bitcoin/bitcoin#27529: test: fix `feature_addrman.py` on big-endian ↵fanquake
systems 53c990ad3406ee945305af84af98d2f020e5f316 test: fix `feature_addrman.py` on big-endian systems (Sebastian Falbesoner) Pull request description: The test `feature_addrman.py` currently serializes the addrdb without specifying endianness for `int`s, so the machine's native byte order is used (see https://docs.python.org/3/library/struct.html#byte-order-size-and-alignment) and the generated `peers.dat` would be invalid on big-endian systems (our internal (de)serializers always use little-endian, see `ser_{read,write}data32`). Fix this by explicitly specifying little-endian serialization via the `<` character in `struct.pack(...)`. This is not detected by CI as we unfortunately don't run functional tests on big-endian systems there (I think we definitely should!). ACKs for top commit: MarcoFalke: lgtm ACK 53c990ad3406ee945305af84af98d2f020e5f316 🔚 Tree-SHA512: 513af6f1f785a713e7a8ef3a57fcd3fe2520a7d537f63a9c8e1f4bdea4c2f605fd4c35001623d6b13458883dbc256f24943684ab8f224055c22bf8d8eeee5fe2
2023-06-21scripted-diff: Use wallets_path and chain_path where possibleMarcoFalke
Instead of passing the datadir and chain name to os.path.join, just use the existing properties, which are the same. -BEGIN VERIFY SCRIPT- sed -i --regexp-extended 's|\.datadir, self\.chain, .wallets.|.wallets_path|g' $(git grep -l '\.datadir, self\.chain,') sed -i --regexp-extended 's|\.datadir, self\.chain,|.chain_path,|g' $(git grep -l '\.datadir, self\.chain,') -END VERIFY SCRIPT-
2023-04-25test: fix `feature_addrman.py` on big-endian systemsSebastian Falbesoner
The test `feature_addrman.py` currently serializes the addrdb without specifying endianness for `int`s, so the machine's native byte order is used (see https://docs.python.org/3/library/struct.html#byte-order-size-and-alignment) and the generated `peers.dat` would be invalid on big-endian systems. Fix this by explicitly specifying little-endian serialization via the `<` character in `struct.pack(...)`.
2022-12-24scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: - 2021: f47dda2c58b5d8d623e0e7ff4e74bc352dfa83d7 - 2020: fa0074e2d82928016a43ca408717154a1c70a4db - 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2022-06-29streams: Add AutoFile without ser-type and ser-versionMacroFake
The moved parts can be reviewed with "--color-moved=dimmed-zebra". The one-char changes can be reviewed with "--word-diff-regex=.".
2022-02-25addrman: Log too low compat valueMarcoFalke
Also remove uint8_t{} casts from values that are already of the same type.
2022-02-25p2p: Avoid InitError when downgrading peers.datjunderw
fixes #24188 When downgrading, a peers.dat with a future version that has a minimum required version larger than the downgraded version would cause an InitError. This commit changes this behavior to overwrite the existing peers.dat with a new empty one, while creating a backup in peers.dat.bak.
2021-10-25Introduce new V4 format addrmanPieter Wuille
92617b7a758c0425330fba4b886296730567927c effectively changed the on-disk format in an incompatible way: old deserializers cannot deal with multiple entries for the same IP. Introduce a V4_MULTIPORT format, and increment the compatibility base, so that old versions correctly recognize it as an incompatible future version.
2021-09-28scripted-diff: Rename CAddrMan to AddrManAmiti Uttarwar
-BEGIN VERIFY SCRIPT- git grep -l CAddrMan src/ test/ | xargs sed -i 's/CAddrMan/AddrMan/g' -END VERIFY SCRIPT-
2021-09-27test: Add missing re.escape() to feature_addrman testMarcoFalke
2021-09-21addrman: Replace assert with throw on corrupt dataMarcoFalke
Assert should only be used for program internal logic errors, not to sanitize external user input.
2021-09-20test: Add addrman deserialization error testsMarcoFalke
2021-09-09Raise InitError when peers.dat is invalid or corruptedMarcoFalke
2021-09-05addrman: Fix format string in deserialize errorMarcoFalke
Also add a regression test.