Skip to content

Commit

Permalink
[test] Use deterministic addrman in addpeeraddress test
Browse files Browse the repository at this point in the history
this test inserts 1 address into the new table and 1 address into
the tried table so that no collisions can happen in either table
if a second address is added. this setup does not need to be
maintained anymore since we can use a deterministic addrman and
safely add many addresses in both tables without collisions. Remove
comment explaining why previous setup needed to be maintained.
  • Loading branch information
stratospher committed Jan 8, 2024
1 parent 7b868e6 commit 71c1991
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions test/functional/rpc_net.py
Expand Up @@ -299,16 +299,8 @@ def test_getnodeaddresses(self):
assert_raises_rpc_error(-8, "Network not recognized: Foo", self.nodes[0].getnodeaddresses, 1, "Foo")

def test_addpeeraddress(self):
"""RPC addpeeraddress sets the source address equal to the destination address.
If an address with the same /16 as an existing new entry is passed, it will be
placed in the same new bucket and have a 1/64 chance of the bucket positions
colliding (depending on the value of nKey in the addrman), in which case the
new address won't be added. The probability of collision can be reduced to
1/2^16 = 1/65536 by using an address from a different /16. We avoid this here
by first testing adding a tried table entry before testing adding a new table one.
"""
self.log.info("Test addpeeraddress")
self.restart_node(1, ["-checkaddrman=1"])
self.restart_node(1, ["-checkaddrman=1", "-test=addrman"])
node = self.nodes[1]

self.log.debug("Test that addpeerinfo is a hidden RPC")
Expand Down

0 comments on commit 71c1991

Please sign in to comment.