-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fixes to test_long_sync_untrusted_break #20327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emlowe
wants to merge
3
commits into
main
Choose a base branch
from
EL.test_long_sync_untrusted_break
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1650,27 +1650,16 @@ async def test_long_sync_untrusted_break( | |
| wallet_node.config["trusted_peers"] = {trusted_full_node_server.node_id.hex(): None} | ||
| wallet_node.config["use_delta_sync"] = use_delta_sync | ||
|
|
||
| sync_canceled = False | ||
|
|
||
| async def register_for_ph_updates( | ||
| self: object, | ||
| request: wallet_protocol.RegisterForPhUpdates, | ||
| peer: WSChiaConnection, | ||
| ) -> None: | ||
| nonlocal sync_canceled | ||
| # Just sleep a long time here to simulate a long-running untrusted sync | ||
| try: | ||
| await asyncio.sleep(120) | ||
| except Exception: | ||
| sync_canceled = True | ||
| raise | ||
| await peer.wait_until_closed() | ||
|
|
||
| def wallet_syncing() -> bool: | ||
| return wallet_node.wallet_state_manager.sync_mode | ||
|
|
||
| def check_sync_canceled() -> bool: | ||
| return sync_canceled | ||
|
|
||
| def synced_to_trusted() -> bool: | ||
| return trusted_full_node_server.node_id in wallet_node.synced_peers | ||
|
|
||
|
|
@@ -1683,22 +1672,26 @@ def only_trusted_peer() -> bool: | |
|
|
||
| await add_blocks_in_batches(default_1000_blocks[:400], untrusted_full_node_api.full_node) | ||
|
|
||
| with patch_request_handler(api=untrusted_full_node_api, handler=register_for_ph_updates): | ||
| with ( | ||
| patch_request_handler(api=untrusted_full_node_api, handler=register_for_ph_updates), | ||
| caplog.at_level(logging.INFO), | ||
| ): | ||
| # Connect to the untrusted peer and wait until the long sync started | ||
| await wallet_server.start_client(PeerInfo(self_hostname, untrusted_full_node_server.get_port()), None) | ||
| assert await wallet_server.start_client(PeerInfo(self_hostname, untrusted_full_node_server.get_port()), None) | ||
| await time_out_assert(30, wallet_syncing) | ||
| with caplog.at_level(logging.INFO): | ||
| # Connect to the trusted peer and make sure the running untrusted long sync gets interrupted via disconnect | ||
| await wallet_server.start_client(PeerInfo(self_hostname, trusted_full_node_server.get_port()), None) | ||
| await time_out_assert(600, wallet_height_at_least, True, wallet_node, len(default_400_blocks) - 1) | ||
| assert time_out_assert(10, synced_to_trusted) | ||
| assert untrusted_full_node_server.node_id not in wallet_node.synced_peers | ||
| assert "Connected to a synced trusted peer, disconnecting from all untrusted nodes." in caplog.text | ||
|
|
||
| # Make sure the sync was interrupted | ||
| assert time_out_assert(30, check_sync_canceled) | ||
|
|
||
| # Connect to the trusted peer and make sure the running untrusted long sync gets interrupted via disconnect | ||
| assert await wallet_server.start_client(PeerInfo(self_hostname, trusted_full_node_server.get_port()), None) | ||
| await time_out_assert(600, wallet_height_at_least, True, wallet_node, len(default_400_blocks) - 1) | ||
| await time_out_assert(10, synced_to_trusted) | ||
| assert untrusted_full_node_server.node_id not in wallet_node.synced_peers | ||
|
|
||
| assert "Connected to a synced trusted peer, disconnecting from all untrusted nodes." in caplog.text | ||
| # check that we disconnected from the untrusted peer | ||
| assert f"Connection closed: 127.0.0.1, node id: {untrusted_full_node_server.node_id.hex()}" in caplog.text | ||
|
|
||
| # And that we only have a trusted peer left | ||
| assert time_out_assert(30, only_trusted_peer) | ||
| await time_out_assert(30, only_trusted_peer) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I see I think they just had a thinko about asserting |
||
|
|
||
|
|
||
| @pytest.mark.anyio | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.