unit: adjust for incorrect amount sweep

pull/676/head
Slyghtning 4 months ago
parent 3db464955d
commit 855fa8dccf
No known key found for this signature in database
GPG Key ID: F82D456EA023C9BF

@ -277,14 +277,19 @@ func testLoopInTimeout(t *testing.T, externalValue int64) {
Tx: &htlcTx, Tx: &htlcTx,
} }
// Assert that the swap is failed in case of an invalid amount. isInvalidAmt := externalValue != 0 && externalValue != int64(req.Amount)
invalidAmt := externalValue != 0 && externalValue != int64(req.Amount) handleHtlcExpiry(
if invalidAmt { t, ctx, inSwap, htlcTx, cost, errChan, isInvalidAmt,
ctx.assertState(loopdb.StateFailIncorrectHtlcAmt) )
ctx.store.AssertLoopInState(loopdb.StateFailIncorrectHtlcAmt) }
require.NoError(t, <-errChan) func handleHtlcExpiry(t *testing.T, ctx *loopInTestContext, inSwap *loopInSwap,
return htlcTx wire.MsgTx, cost loopdb.SwapCost, errChan chan error,
isInvalidAmount bool) {
if isInvalidAmount {
ctx.store.AssertLoopInState(loopdb.StateFailIncorrectHtlcAmt)
ctx.assertState(loopdb.StateFailIncorrectHtlcAmt)
} }
// Client starts listening for spend of htlc. // Client starts listening for spend of htlc.
@ -329,8 +334,16 @@ func testLoopInTimeout(t *testing.T, externalValue int64) {
// Signal that the invoice was canceled. // Signal that the invoice was canceled.
ctx.updateInvoiceState(0, invpkg.ContractCanceled) ctx.updateInvoiceState(0, invpkg.ContractCanceled)
ctx.assertState(loopdb.StateFailTimeout) var state loopdb.SwapStateData
state := ctx.store.AssertLoopInState(loopdb.StateFailTimeout) if isInvalidAmount {
state = ctx.store.AssertLoopInState(
loopdb.StateFailIncorrectHtlcAmtSwept,
)
ctx.assertState(loopdb.StateFailIncorrectHtlcAmtSwept)
} else {
ctx.assertState(loopdb.StateFailTimeout)
state = ctx.store.AssertLoopInState(loopdb.StateFailTimeout)
}
require.Equal(t, cost, state.Cost) require.Equal(t, cost, state.Cost)
require.NoError(t, <-errChan) require.NoError(t, <-errChan)

Loading…
Cancel
Save