Skip to content

Commit 89b84ea

Browse files
committed
test: check that addrman seeding is successful
The addpeeraddress calls can fail due to collisions. As we are using a deteministic addrman, they won't fail with the current bucket/position calculation. However, if the calculation is changed, they might collide and fail silently causing tests using `seed_addrman()` to fail. Assert that the addpeeraddress calls are successful.
1 parent c122318 commit 89b84ea

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test/functional/rpc_net.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,18 @@ def seed_addrman(node):
4545
""" Populate the addrman with addresses from different networks.
4646
Here 2 ipv4, 2 ipv6, 1 cjdns, 2 onion and 1 i2p addresses are added.
4747
"""
48-
node.addpeeraddress(address="1.2.3.4", tried=True, port=8333)
49-
node.addpeeraddress(address="2.0.0.0", port=8333)
50-
node.addpeeraddress(address="1233:3432:2434:2343:3234:2345:6546:4534", tried=True, port=8333)
51-
node.addpeeraddress(address="2803:0:1234:abcd::1", port=45324)
52-
node.addpeeraddress(address="fc00:1:2:3:4:5:6:7", port=8333)
53-
node.addpeeraddress(address="pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion", tried=True, port=8333)
54-
node.addpeeraddress(address="nrfj6inpyf73gpkyool35hcmne5zwfmse3jl3aw23vk7chdemalyaqad.onion", port=45324, tried=True)
55-
node.addpeeraddress(address="c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p", port=8333)
48+
# These addresses currently don't collide with a deterministic addrman.
49+
# If the addrman positioning/bucketing is changed, these might collide
50+
# and adding them fails.
51+
success = { "success": True }
52+
assert_equal(node.addpeeraddress(address="1.2.3.4", tried=True, port=8333), success)
53+
assert_equal(node.addpeeraddress(address="2.0.0.0", port=8333), success)
54+
assert_equal(node.addpeeraddress(address="1233:3432:2434:2343:3234:2345:6546:4534", tried=True, port=8333), success)
55+
assert_equal(node.addpeeraddress(address="2803:0:1234:abcd::1", port=45324), success)
56+
assert_equal(node.addpeeraddress(address="fc00:1:2:3:4:5:6:7", port=8333), success)
57+
assert_equal(node.addpeeraddress(address="pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion", tried=True, port=8333), success)
58+
assert_equal(node.addpeeraddress(address="nrfj6inpyf73gpkyool35hcmne5zwfmse3jl3aw23vk7chdemalyaqad.onion", port=45324, tried=True), success)
59+
assert_equal(node.addpeeraddress(address="c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p", port=8333), success)
5660

5761

5862
class NetTest(BitcoinTestFramework):

0 commit comments

Comments
 (0)