diff options
author | Dhruv Mehta <856960+dhruv@users.noreply.github.com> | 2020-09-05 09:51:33 -0700 |
---|---|---|
committer | Dhruv Mehta <856960+dhruv@users.noreply.github.com> | 2021-02-11 16:10:40 -0800 |
commit | fe3e993968d6b46777d5a16a662cd22790ddf5bb (patch) | |
tree | d0d052a5545aab0bd3efd5902cf8045a0ea28aa4 /test/functional/feature_config_args.py | |
parent | 6c6140846f37de8c132b3b6abf09f3d7940554a7 (diff) |
[p2p] No delay in adding fixed seeds if -dnsseed=0 and peers.dat is empty. Add -fixedseeds arg.
Diffstat (limited to 'test/functional/feature_config_args.py')
-rwxr-xr-x | test/functional/feature_config_args.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py index 2445b6d977..82dd0e3b80 100755 --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -5,6 +5,7 @@ """Test various command line arguments and configuration file parameters.""" import os +import time from test_framework.test_framework import BitcoinTestFramework from test_framework import util @@ -147,11 +148,67 @@ class ConfArgsTest(BitcoinTestFramework): self.start_node(0, extra_args=['-nonetworkactive=1']) self.stop_node(0) + def test_seed_peers(self): + self.log.info('Test seed peers, this will take about 2 minutes') + default_data_dir = self.nodes[0].datadir + + # No peers.dat exists and -dnsseed=1 + # We expect the node will use DNS Seeds, but Regtest mode has 0 DNS seeds + # So after 60 seconds, the node should fallback to fixed seeds (this is a slow test) + assert not os.path.exists(os.path.join(default_data_dir, "peers.dat")) + start = time.time() + with self.nodes[0].assert_debug_log(expected_msgs=[ + "Loaded 0 addresses from peers.dat", + "0 addresses found from DNS seeds", + "Adding fixed seeds as 60 seconds have passed and addrman is empty"], timeout=80): + self.start_node(0, extra_args=['-dnsseed=1']) + assert time.time() - start >= 60 + self.stop_node(0) + + # No peers.dat exists and -dnsseed=0 + # We expect the node will fallback immediately to fixed seeds + assert not os.path.exists(os.path.join(default_data_dir, "peers.dat")) + start = time.time() + with self.nodes[0].assert_debug_log(expected_msgs=[ + "Loaded 0 addresses from peers.dat", + "DNS seeding disabled", + "Adding fixed seeds as -dnsseed=0, -addnode is not provided and and all -seednode(s) attempted\n"]): + self.start_node(0, extra_args=['-dnsseed=0']) + assert time.time() - start < 60 + self.stop_node(0) + + # No peers.dat exists and dns seeds are disabled. + # We expect the node will not add fixed seeds when explicitly disabled. + assert not os.path.exists(os.path.join(default_data_dir, "peers.dat")) + start = time.time() + with self.nodes[0].assert_debug_log(expected_msgs=[ + "Loaded 0 addresses from peers.dat", + "DNS seeding disabled", + "Fixed seeds are disabled"]): + self.start_node(0, extra_args=['-dnsseed=0', '-fixedseeds=0']) + assert time.time() - start < 60 + self.stop_node(0) + + # No peers.dat exists and -dnsseed=0, but a -addnode is provided + # We expect the node will allow 60 seconds prior to using fixed seeds + assert not os.path.exists(os.path.join(default_data_dir, "peers.dat")) + start = time.time() + with self.nodes[0].assert_debug_log(expected_msgs=[ + "Loaded 0 addresses from peers.dat", + "DNS seeding disabled", + "Adding fixed seeds as 60 seconds have passed and addrman is empty"], + timeout=80): + self.start_node(0, extra_args=['-dnsseed=0', '-addnode=fakenodeaddr']) + assert time.time() - start >= 60 + self.stop_node(0) + + def run_test(self): self.stop_node(0) self.test_log_buffer() self.test_args_log() + self.test_seed_peers() self.test_networkactive() self.test_config_file_parser() |