submarine_swaps: wait for broadcast in wait_for_htlcs_and_broadcast#10661
Open
f321x wants to merge 1 commit into
Open
submarine_swaps: wait for broadcast in wait_for_htlcs_and_broadcast#10661f321x wants to merge 1 commit into
f321x wants to merge 1 commit into
Conversation
840a7aa to
7dbaaa9
Compare
Wait for broadcast of the funding transaction in
`SwapManager.wait_for_htlcs_and_broadcast` before returning.
Previously it might have returned the swap funding txid before the
funding tx was broadcast.
This caused the regtest `test_swapserver_success_forward` to fail
as it expected the funding tx to be broadcast once the CLI command
returned.
See:
```
.***** test_swapserver_success_forward ******
initializing alice
funding alice
ec354953f96e0de7be4354ab156611da9e31bd85c2d25664bdb995950530c12e
initializing bob
funding bob
1df19a419b5ae5b961bae6cfaf4e7c8e772c6632d30782fab8de6992a8901e4a
mining 1 blocks
starting daemon (PID 7471)
/tmp/alice/regtest/wallets/default_wallet
true
starting daemon (PID 7502)
/tmp/bob/regtest/wallets/default_wallet
true
alice opens channel
mining 3 blocks
wait until alice sees channel open.
wait until alice sees channel open..
wait until alice sees channel open...
alice initiates forward-swap
{
"lightning_amount": "0.01967661",
"onchain_amount": "0.02",
"txid": "b0f9ba48b670ee4a1f182655fe18f3f7d5c310923b7c85ad396b24e0a2f8e0cc"
}
utxo b0f9ba48b670ee4a1f182655fe18f3f7d5c310923b7c85ad396b24e0a2f8e0cc:0 does not exist
FDaemon stopped
Daemon stopped
======================================================================
FAIL: test_swapserver_success_forward (tests.regtest.TestLightningSwapserver.test_swapserver_success_forward)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/cirrus-ci-build/tests/regtest.py", line 105, in test_swapserver_success_forward
self.run_shell(['swapserver_success_forward'])
File "/tmp/cirrus-ci-build/tests/regtest.py", line 19, in run_shell
assert process.returncode == 0
^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
```
Can be reproduced with:
```diff
diff --git a/electrum/submarine_swaps.py b/electrum/submarine_swaps.py
index f83d653..242aef070 100644
--- a/electrum/submarine_swaps.py
+++ b/electrum/submarine_swaps.py
@@ -1052,6 +1052,7 @@ class SwapManager(Logger):
@log_exceptions
async def broadcast_funding_tx(self, swap: SwapData, tx: Transaction) -> None:
swap.funding_txid = tx.txid()
+ await asyncio.sleep(5)
await self.network.broadcast_transaction(tx)
async def reverse_swap(
```
7dbaaa9 to
2a1eda4
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Wait for broadcast of the funding transaction in
SwapManager.wait_for_htlcs_and_broadcastbefore returning. Previously it might have returned the swap funding txid before the funding tx was broadcast.This caused the regtest
test_swapserver_success_forwardto fail in the CI as it expected the funding tx to be broadcast once the CLI command returned.See:
Can be reproduced with: