diff options
author | Dhruv Mehta <856960+dhruv@users.noreply.github.com> | 2021-02-12 09:35:18 -0800 |
---|---|---|
committer | Dhruv Mehta <856960+dhruv@users.noreply.github.com> | 2021-02-12 09:35:18 -0800 |
commit | d4187e46194e7b31f5ace48b08ff64416b967ec4 (patch) | |
tree | c8d1af766ffaff3f6c8a36a167d5015b0722ebf0 /test/functional/feature_config_args.py | |
parent | 015637dd445e0158dc763d0d8c55f471d0bc4305 (diff) |
[test] Use mocktime in test_seed_peers()
Test case now takes < 5 seconds instead of > 2 minutes
Diffstat (limited to 'test/functional/feature_config_args.py')
-rwxr-xr-x | test/functional/feature_config_args.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py index 9e22203028..573760a8cb 100755 --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -149,20 +149,21 @@ class ConfArgsTest(BitcoinTestFramework): self.stop_node(0) def test_seed_peers(self): - self.log.info('Test seed peers, this will take about 2 minutes') + self.log.info('Test seed peers') 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() + start = int(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 + "0 addresses found from DNS seeds"]): + self.start_node(0, extra_args=['-dnsseed=1 -mocktime={}'.format(start)]) + with self.nodes[0].assert_debug_log(expected_msgs=[ + "Adding fixed seeds as 60 seconds have passed and addrman is empty"]): + self.nodes[0].setmocktime(start + 65) self.stop_node(0) # No peers.dat exists and -dnsseed=0 @@ -192,14 +193,14 @@ class ConfArgsTest(BitcoinTestFramework): # 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() + start = int(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 + "DNS seeding disabled"]): + self.start_node(0, extra_args=['-dnsseed=0', '-addnode=fakenodeaddr -mocktime={}'.format(start)]) + with self.nodes[0].assert_debug_log(expected_msgs=[ + "Adding fixed seeds as 60 seconds have passed and addrman is empty"]): + self.nodes[0].setmocktime(start + 65) self.stop_node(0) |