Wait until the node is connected to at least one new peer. We detect this by watching for an increased highest peer id, using the `getpeerinfo` RPC call. Note that the simpler approach of only accounting for the number of peers suffers from race conditions, as discon
(self, timeout=5)
| 645 | |
| 646 | @contextlib.contextmanager |
| 647 | def wait_for_new_peer(self, timeout=5): |
| 648 | """ |
| 649 | Wait until the node is connected to at least one new peer. We detect this |
| 650 | by watching for an increased highest peer id, using the `getpeerinfo` RPC call. |
| 651 | Note that the simpler approach of only accounting for the number of peers |
| 652 | suffers from race conditions, as disconnects from unrelated previous peers |
| 653 | could happen anytime in-between. |
| 654 | """ |
| 655 | def get_highest_peer_id(): |
| 656 | peer_info = self.getpeerinfo() |
| 657 | return peer_info[-1]["id"] if peer_info else -1 |
| 658 | |
| 659 | initial_peer_id = get_highest_peer_id() |
| 660 | yield |
| 661 | self.wait_until(lambda: get_highest_peer_id() > initial_peer_id, timeout=timeout) |
| 662 | |
| 663 | def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, match=ErrorMatch.FULL_TEXT, *args, **kwargs): |
| 664 | """Attempt to start the node and expect it to raise an error. |
no test coverage detected