loopin: record htlx tx hash

This commit is contained in:
Joost Jager 2020-06-25 12:35:22 +02:00
parent a3b7fa5977
commit f91422d188
No known key found for this signature in database
GPG key ID: A61B9D4C393C59C7
3 changed files with 76 additions and 13 deletions

View file

@ -10,6 +10,7 @@ import (
"github.com/lightninglabs/loop/test"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/stretchr/testify/require"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
@ -61,6 +62,10 @@ func TestLoopInSuccess(t *testing.T) {
// Expect htlc to be published.
htlcTx := <-ctx.lnd.SendOutputsChannel
// Expect the same state to be written again with the htlc tx hash.
state := ctx.store.assertLoopInState(loopdb.StateHtlcPublished)
require.NotNil(t, state.HtlcTxHash)
// Expect register for htlc conf.
<-ctx.lnd.RegisterConfChannel
<-ctx.lnd.RegisterConfChannel
@ -182,6 +187,10 @@ func testLoopInTimeout(t *testing.T,
if externalValue == 0 {
// Expect htlc to be published.
htlcTx = <-ctx.lnd.SendOutputsChannel
// Expect the same state to be written again with the htlc tx hash.
state := ctx.store.assertLoopInState(loopdb.StateHtlcPublished)
require.NotNil(t, state.HtlcTxHash)
} else {
// Create an external htlc publish tx.
var pkScript []byte
@ -389,6 +398,11 @@ func testLoopInResume(t *testing.T, state loopdb.SwapState, expired bool) {
// Expect htlc to be published.
htlcTx = <-ctx.lnd.SendOutputsChannel
// Expect the same state to be written again with the htlc tx
// hash.
state := ctx.store.assertLoopInState(loopdb.StateHtlcPublished)
require.NotNil(t, state.HtlcTxHash)
} else {
ctx.assertState(loopdb.StateHtlcPublished)