mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-22 23:03:43 +02:00
lnwallet: add initial unit tests for musig2+tapscript root chans
This commit is contained in:
parent
82ba5bf0bf
commit
8588c9bfd7
@ -386,6 +386,12 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("taproot with tapscript root", func(t *testing.T) {
|
||||||
|
flags := channeldb.SimpleTaprootFeatureBit |
|
||||||
|
channeldb.TapscriptRootBit
|
||||||
|
testAddSettleWorkflow(t, true, flags, false)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("storeFinalHtlcResolutions=true", func(t *testing.T) {
|
t.Run("storeFinalHtlcResolutions=true", func(t *testing.T) {
|
||||||
testAddSettleWorkflow(t, false, 0, true)
|
testAddSettleWorkflow(t, false, 0, true)
|
||||||
})
|
})
|
||||||
@ -828,6 +834,16 @@ func TestForceClose(t *testing.T) {
|
|||||||
anchorAmt: AnchorSize * 2,
|
anchorAmt: AnchorSize * 2,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
t.Run("taproot with tapscript root", func(t *testing.T) {
|
||||||
|
testForceClose(t, &forceCloseTestCase{
|
||||||
|
chanType: channeldb.SingleFunderTweaklessBit |
|
||||||
|
channeldb.AnchorOutputsBit |
|
||||||
|
channeldb.SimpleTaprootFeatureBit |
|
||||||
|
channeldb.TapscriptRootBit,
|
||||||
|
expectedCommitWeight: input.TaprootCommitWeight,
|
||||||
|
anchorAmt: AnchorSize * 2,
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type forceCloseTestCase struct {
|
type forceCloseTestCase struct {
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/fn"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
@ -348,6 +349,21 @@ func CreateTestChannels(t *testing.T, chanType channeldb.ChannelType,
|
|||||||
Packager: channeldb.NewChannelPackager(shortChanID),
|
Packager: channeldb.NewChannelPackager(shortChanID),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the channel type has a tapscript root, then we'll also specify
|
||||||
|
// one here to apply to both the channels.
|
||||||
|
if chanType.HasTapscriptRoot() {
|
||||||
|
var tapscriptRoot chainhash.Hash
|
||||||
|
_, err := io.ReadFull(rand.Reader, tapscriptRoot[:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
someRoot := fn.Some(tapscriptRoot)
|
||||||
|
|
||||||
|
aliceChannelState.TapscriptRoot = someRoot
|
||||||
|
bobChannelState.TapscriptRoot = someRoot
|
||||||
|
}
|
||||||
|
|
||||||
aliceSigner := input.NewMockSigner(aliceKeys, nil)
|
aliceSigner := input.NewMockSigner(aliceKeys, nil)
|
||||||
bobSigner := input.NewMockSigner(bobKeys, nil)
|
bobSigner := input.NewMockSigner(bobKeys, nil)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user