regtests: rm sleep from "swapserver_forceclose" test
less reliance on timing (OTOH it hardcodes the output index of the commitment tx... meh)
This commit is contained in:
@@ -1639,7 +1639,8 @@ class Commands(Logger):
|
||||
@command('wnpl')
|
||||
async def close_channel(self, channel_point, force=False, password=None, wallet: Abstract_Wallet = None):
|
||||
"""
|
||||
Close a lightning channel
|
||||
Close a lightning channel.
|
||||
Returns txid of closing tx.
|
||||
|
||||
arg:str:channel_point:channel point
|
||||
arg:bool:force:Force closes (broadcast local commitment transaction)
|
||||
|
||||
@@ -2288,6 +2288,9 @@ class LNWallet(LNWorker):
|
||||
def save_preimage(self, payment_hash: bytes, preimage: bytes, *, write_to_disk: bool = True):
|
||||
if sha256(preimage) != payment_hash:
|
||||
raise Exception("tried to save incorrect preimage for payment_hash")
|
||||
if self._preimages.get(payment_hash.hex()) is not None:
|
||||
return # we already have this preimage
|
||||
self.logger.debug(f"saving preimage for {payment_hash.hex()}")
|
||||
self._preimages[payment_hash.hex()] = preimage.hex()
|
||||
if write_to_disk:
|
||||
self.wallet.save_db()
|
||||
|
||||
@@ -249,11 +249,17 @@ if [[ $1 == "swapserver_forceclose" ]]; then
|
||||
swap=$($alice reverse_swap 0.02 $onchain_amount)
|
||||
echo $swap | jq
|
||||
funding_txid=$(echo $swap| jq -r ".funding_txid")
|
||||
$bob close_channel --force $channel
|
||||
ctx_id=$($bob close_channel --force $channel)
|
||||
new_blocks 1
|
||||
wait_until_spent $funding_txid 0 # alice reveals preimage
|
||||
new_blocks 1
|
||||
sleep 2
|
||||
if [ $TEST_ANCHOR_CHANNELS = True ] ; then
|
||||
output_index=3 # received_htlc_output in bob's ctx. FIXME index depends on Alice not using MPP
|
||||
else
|
||||
output_index=1
|
||||
fi
|
||||
# wait until Bob finds preimage onchain and uses it to create an htlc_success tx
|
||||
wait_until_spent $ctx_id $output_index # alice's to_local gets punished
|
||||
new_blocks 144
|
||||
wait_for_balance bob 0.999
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user