@@ -59,8 +59,8 @@ func assertOutputExistsByValue(t *testing.T, commitTx *wire.MsgTx,
5959
6060// testAddSettleWorkflow tests a simple channel scenario where Alice and Bob
6161// add, the settle an HTLC between themselves.
62- func testAddSettleWorkflow (t * testing.T , tweakless ,
63- storeFinalHtlcResolutions bool ) {
62+ func testAddSettleWorkflow (t * testing.T , tweakless bool ,
63+ chanTypeModifier channeldb. ChannelType , storeFinalHtlcResolutions bool ) {
6464
6565 // Create a test channel which will be used for the duration of this
6666 // unittest. The channel will be funded evenly with Alice having 5 BTC,
@@ -70,6 +70,10 @@ func testAddSettleWorkflow(t *testing.T, tweakless,
7070 chanType = channeldb .SingleFunderBit
7171 }
7272
73+ if chanTypeModifier != 0 {
74+ chanType |= chanTypeModifier
75+ }
76+
7377 aliceChannel , bobChannel , err := CreateTestChannels (
7478 t , chanType ,
7579 channeldb .OptionStoreFinalHtlcResolutions (
@@ -193,12 +197,18 @@ func testAddSettleWorkflow(t *testing.T, tweakless,
193197
194198 // Both commitment transactions should have three outputs, and one of
195199 // them should be exactly the amount of the HTLC.
196- if len (aliceChannel .channelState .LocalCommitment .CommitTx .TxOut ) != 3 {
200+ numOutputs := 3
201+ if chanTypeModifier .HasAnchors () {
202+ // In this case we expect two extra outputs as both sides need an
203+ // anchor output.
204+ numOutputs = 5
205+ }
206+ if len (aliceChannel .channelState .LocalCommitment .CommitTx .TxOut ) != numOutputs {
197207 t .Fatalf ("alice should have three commitment outputs, instead " +
198208 "have %v" ,
199209 len (aliceChannel .channelState .LocalCommitment .CommitTx .TxOut ))
200210 }
201- if len (bobChannel .channelState .LocalCommitment .CommitTx .TxOut ) != 3 {
211+ if len (bobChannel .channelState .LocalCommitment .CommitTx .TxOut ) != numOutputs {
202212 t .Fatalf ("bob should have three commitment outputs, instead " +
203213 "have %v" ,
204214 len (bobChannel .channelState .LocalCommitment .CommitTx .TxOut ))
@@ -350,13 +360,28 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
350360
351361 for _ , tweakless := range []bool {true , false } {
352362 tweakless := tweakless
363+
353364 t .Run (fmt .Sprintf ("tweakless=%v" , tweakless ), func (t * testing.T ) {
354- testAddSettleWorkflow (t , tweakless , false )
365+ testAddSettleWorkflow (t , tweakless , 0 , false )
355366 })
356367 }
357368
369+ t .Run ("anchors" , func (t * testing.T ) {
370+ testAddSettleWorkflow (
371+ t , true ,
372+ channeldb .AnchorOutputsBit | channeldb .ZeroHtlcTxFeeBit ,
373+ false ,
374+ )
375+ })
376+
377+ t .Run ("taproot" , func (t * testing.T ) {
378+ testAddSettleWorkflow (
379+ t , true , channeldb .SimpleTaprootFeatureBit , false ,
380+ )
381+ })
382+
358383 t .Run ("storeFinalHtlcResolutions=true" , func (t * testing.T ) {
359- testAddSettleWorkflow (t , false , true )
384+ testAddSettleWorkflow (t , false , 0 , true )
360385 })
361386}
362387
0 commit comments