mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopin: fail swap when htlc amount is incorrect
Previously the swap would get stuck in a state where it wouldn't ever progress because the server rejected the htlc.
This commit is contained in:
parent
e33d2fb762
commit
a3b7fa5977
3 changed files with 29 additions and 0 deletions
|
|
@ -209,6 +209,20 @@ func testLoopInTimeout(t *testing.T,
|
|||
Tx: &htlcTx,
|
||||
}
|
||||
|
||||
// Assert that the swap is failed in case of an invalid amount.
|
||||
invalidAmt := externalValue != 0 && externalValue != int64(req.Amount)
|
||||
if invalidAmt {
|
||||
ctx.assertState(loopdb.StateFailIncorrectHtlcAmt)
|
||||
ctx.store.assertLoopInState(loopdb.StateFailIncorrectHtlcAmt)
|
||||
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Client starts listening for spend of htlc.
|
||||
<-ctx.lnd.RegisterSpendChannel
|
||||
|
||||
|
|
@ -380,6 +394,7 @@ func testLoopInResume(t *testing.T, state loopdb.SwapState, expired bool) {
|
|||
|
||||
htlcTx.AddTxOut(&wire.TxOut{
|
||||
PkScript: htlc.PkScript,
|
||||
Value: int64(contract.AmountRequested),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue