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.
This commit is contained in:
0xb10c 2024-03-12 16:17:01 +01:00
parent c1223188e0
commit 89b84ea91a
No known key found for this signature in database
GPG Key ID: E2FFD5B1D88CA97D
1 changed files with 12 additions and 8 deletions

View File

@ -45,14 +45,18 @@ def seed_addrman(node):
""" Populate the addrman with addresses from different networks. """ Populate the addrman with addresses from different networks.
Here 2 ipv4, 2 ipv6, 1 cjdns, 2 onion and 1 i2p addresses are added. Here 2 ipv4, 2 ipv6, 1 cjdns, 2 onion and 1 i2p addresses are added.
""" """
node.addpeeraddress(address="1.2.3.4", tried=True, port=8333) # These addresses currently don't collide with a deterministic addrman.
node.addpeeraddress(address="2.0.0.0", port=8333) # If the addrman positioning/bucketing is changed, these might collide
node.addpeeraddress(address="1233:3432:2434:2343:3234:2345:6546:4534", tried=True, port=8333) # and adding them fails.
node.addpeeraddress(address="2803:0:1234:abcd::1", port=45324) success = { "success": True }
node.addpeeraddress(address="fc00:1:2:3:4:5:6:7", port=8333) assert_equal(node.addpeeraddress(address="1.2.3.4", tried=True, port=8333), success)
node.addpeeraddress(address="pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion", tried=True, port=8333) assert_equal(node.addpeeraddress(address="2.0.0.0", port=8333), success)
node.addpeeraddress(address="nrfj6inpyf73gpkyool35hcmne5zwfmse3jl3aw23vk7chdemalyaqad.onion", port=45324, tried=True) assert_equal(node.addpeeraddress(address="1233:3432:2434:2343:3234:2345:6546:4534", tried=True, port=8333), success)
node.addpeeraddress(address="c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p", port=8333) assert_equal(node.addpeeraddress(address="2803:0:1234:abcd::1", port=45324), success)
assert_equal(node.addpeeraddress(address="fc00:1:2:3:4:5:6:7", port=8333), success)
assert_equal(node.addpeeraddress(address="pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion", tried=True, port=8333), success)
assert_equal(node.addpeeraddress(address="nrfj6inpyf73gpkyool35hcmne5zwfmse3jl3aw23vk7chdemalyaqad.onion", port=45324, tried=True), success)
assert_equal(node.addpeeraddress(address="c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p", port=8333), success)
class NetTest(BitcoinTestFramework): class NetTest(BitcoinTestFramework):