@@ -473,9 +473,9 @@ func assertPendingChannels(t *testing.T, node *HarnessNode,
473
473
pendingChan .Channel .CustomChannelData , & pendingJSON ,
474
474
)
475
475
require .NoError (t , err )
476
- require .Len (t , pendingJSON .Assets , 1 )
476
+ require .Len (t , pendingJSON .FundingAssets , 1 )
477
477
478
- require .NotZero (t , pendingJSON .Assets [ 0 ]. Capacity )
478
+ require .NotZero (t , pendingJSON .Capacity )
479
479
480
480
// Check the decimal display of the channel funding blob. If no explicit
481
481
// value was set, we assume and expect the value of 0.
@@ -488,7 +488,7 @@ func assertPendingChannels(t *testing.T, node *HarnessNode,
488
488
489
489
require .Equal (
490
490
t , expectedDecimalDisplay ,
491
- pendingJSON .Assets [0 ]. AssetInfo .DecimalDisplay ,
491
+ pendingJSON .FundingAssets [0 ].DecimalDisplay ,
492
492
)
493
493
494
494
// Check the balance of the pending channel.
@@ -501,21 +501,36 @@ func assertPendingChannels(t *testing.T, node *HarnessNode,
501
501
require .EqualValues (t , remoteSum , pendingRemoteBalance )
502
502
}
503
503
504
+ // haveFundingAsset returns true if the given channel has the asset with the
505
+ // given asset ID as a funding asset.
506
+ func haveFundingAsset (assetChannel * rfqmsg.JsonAssetChannel ,
507
+ assetID []byte ) bool {
508
+
509
+ assetIDStr := hex .EncodeToString (assetID )
510
+ for _ , fundingAsset := range assetChannel .FundingAssets {
511
+ if fundingAsset .AssetGenesis .AssetID == assetIDStr {
512
+ return true
513
+ }
514
+ }
515
+
516
+ return false
517
+ }
518
+
504
519
func assertAssetChan (t * testing.T , src , dst * HarnessNode , fundingAmount uint64 ,
505
520
mintedAsset * taprpc.Asset ) {
506
521
507
- assetID := mintedAsset .AssetGenesis .AssetId
508
- assetIDStr := hex .EncodeToString (assetID )
509
522
err := wait .NoError (func () error {
510
523
a , err := getChannelCustomData (src , dst )
511
524
if err != nil {
512
525
return err
513
526
}
514
527
515
- if a .AssetInfo .AssetGenesis .AssetID != assetIDStr {
516
- return fmt .Errorf ("expected asset ID %s, got %s" ,
517
- assetIDStr , a .AssetInfo .AssetGenesis .AssetID )
528
+ assetID := mintedAsset .AssetGenesis .AssetId
529
+ if ! haveFundingAsset (a , assetID ) {
530
+ return fmt .Errorf ("expected asset ID %x, to " +
531
+ "be in channel" , assetID )
518
532
}
533
+
519
534
if a .Capacity != fundingAmount {
520
535
return fmt .Errorf ("expected capacity %d, got %d" ,
521
536
fundingAmount , a .Capacity )
@@ -530,10 +545,10 @@ func assertAssetChan(t *testing.T, src, dst *HarnessNode, fundingAmount uint64,
530
545
)
531
546
}
532
547
533
- if a .AssetInfo .DecimalDisplay != expectedDecimalDisplay {
548
+ if a .FundingAssets [ 0 ] .DecimalDisplay != expectedDecimalDisplay {
534
549
return fmt .Errorf ("expected decimal display %d, got %d" ,
535
550
expectedDecimalDisplay ,
536
- a .AssetInfo .DecimalDisplay )
551
+ a .FundingAssets [ 0 ] .DecimalDisplay )
537
552
}
538
553
539
554
return nil
@@ -580,7 +595,7 @@ func assertChannelKnown(t *testing.T, node *HarnessNode,
580
595
require .NoError (t , err )
581
596
}
582
597
583
- func getChannelCustomData (src , dst * HarnessNode ) (* rfqmsg.JsonAssetChanInfo ,
598
+ func getChannelCustomData (src , dst * HarnessNode ) (* rfqmsg.JsonAssetChannel ,
584
599
error ) {
585
600
586
601
ctxb := context .Background ()
@@ -614,12 +629,12 @@ func getChannelCustomData(src, dst *HarnessNode) (*rfqmsg.JsonAssetChanInfo,
614
629
err )
615
630
}
616
631
617
- if len (assetData .Assets ) != 1 {
632
+ if len (assetData .FundingAssets ) != 1 {
618
633
return nil , fmt .Errorf ("expected 1 asset, got %d" ,
619
- len (assetData .Assets ))
634
+ len (assetData .FundingAssets ))
620
635
}
621
636
622
- return & assetData . Assets [ 0 ] , nil
637
+ return & assetData , nil
623
638
}
624
639
625
640
func getAssetChannelBalance (t * testing.T , node * HarnessNode , assetID []byte ,
@@ -706,10 +721,10 @@ func assertChannelAssetBalance(t *testing.T, node *HarnessNode,
706
721
err := json .Unmarshal (targetChan .CustomChannelData , & assetBalance )
707
722
require .NoError (t , err )
708
723
709
- require .Len (t , assetBalance .Assets , 1 )
724
+ require .Len (t , assetBalance .FundingAssets , 1 )
710
725
711
- require .InDelta (t , local , assetBalance .Assets [ 0 ]. LocalBalance , 1 )
712
- require .InDelta (t , remote , assetBalance .Assets [ 0 ]. RemoteBalance , 1 )
726
+ require .InDelta (t , local , assetBalance .LocalBalance , 1 )
727
+ require .InDelta (t , remote , assetBalance .RemoteBalance , 1 )
713
728
}
714
729
715
730
// addRoutingFee adds the default routing fee (1 part per million fee rate plus
@@ -1385,6 +1400,9 @@ func closeAssetChannelAndAssert(t *harnessTest, net *NetworkHarness,
1385
1400
)
1386
1401
require .NoError (t .t , err )
1387
1402
1403
+ assertWaitingCloseChannelAssetData (t .t , local , chanPoint )
1404
+ assertWaitingCloseChannelAssetData (t .t , remote , chanPoint )
1405
+
1388
1406
mineBlocks (t , net , 1 , 1 )
1389
1407
1390
1408
closeUpdate , err := t .lndHarness .WaitForChannelClose (closeStream )
@@ -1405,6 +1423,9 @@ func closeAssetChannelAndAssert(t *harnessTest, net *NetworkHarness,
1405
1423
t .t , local , remote , closeTx , closeUpdate , assetID , groupKey ,
1406
1424
universeTap ,
1407
1425
)
1426
+
1427
+ assertClosedChannelAssetData (t .t , local , chanPoint )
1428
+ assertClosedChannelAssetData (t .t , remote , chanPoint )
1408
1429
}
1409
1430
1410
1431
// assertDefaultCoOpCloseBalance returns a default implementation of the co-op
@@ -2128,8 +2149,8 @@ func newCloseExpiryInfo(t *testing.T, node *HarnessNode) forceCloseExpiryInfo {
2128
2149
csvDelay : mainChan .CsvDelay ,
2129
2150
currentHeight : nodeInfo .BlockHeight ,
2130
2151
cltvDelays : cltvs ,
2131
- localAssetBalance : assetData .Assets [ 0 ]. LocalBalance ,
2132
- remoteAssetBalance : assetData .Assets [ 0 ]. RemoteBalance ,
2152
+ localAssetBalance : assetData .LocalBalance ,
2153
+ remoteAssetBalance : assetData .RemoteBalance ,
2133
2154
t : t ,
2134
2155
node : node ,
2135
2156
}
@@ -2200,3 +2221,108 @@ func assertInvoiceState(t *testing.T, hn *HarnessNode, payAddr []byte,
2200
2221
}, defaultTimeout )
2201
2222
require .NoError (t , err , "timeout waiting for invoice settled state" )
2202
2223
}
2224
+
2225
+ // assertClosedChannelAssetData asserts that the closed channel has the expected
2226
+ // asset data.
2227
+ func assertClosedChannelAssetData (t * testing.T , node * HarnessNode ,
2228
+ chanPoint * lnrpc.ChannelPoint ) {
2229
+
2230
+ ctxb := context .Background ()
2231
+
2232
+ // Make sure we can find the closed channel in the channel database.
2233
+ closedChannels , err := node .ClosedChannels (
2234
+ ctxb , & lnrpc.ClosedChannelsRequest {},
2235
+ )
2236
+ require .NoError (t , err )
2237
+
2238
+ require .NotEmpty (t , closedChannels .Channels )
2239
+
2240
+ targetChanPointStr := fmt .Sprintf ("%v:%v" , chanPoint .GetFundingTxidStr (),
2241
+ chanPoint .GetOutputIndex ())
2242
+
2243
+ var closedChan * lnrpc.ChannelCloseSummary
2244
+ for _ , ch := range closedChannels .Channels {
2245
+ if ch .ChannelPoint == targetChanPointStr {
2246
+ closedChan = ch
2247
+ break
2248
+ }
2249
+ }
2250
+ require .NotNil (t , closedChan )
2251
+ require .NotEmpty (t , closedChan .CustomChannelData )
2252
+
2253
+ var closeData rfqmsg.JsonAssetChannel
2254
+ err = json .Unmarshal (closedChan .CustomChannelData , & closeData )
2255
+ require .NoError (t , err )
2256
+
2257
+ require .GreaterOrEqual (t , len (closeData .FundingAssets ), 1 )
2258
+ }
2259
+
2260
+ // assertPendingForceCloseChannelAssetData asserts that the pending force close
2261
+ // channel has the expected asset data.
2262
+ func assertPendingForceCloseChannelAssetData (t * testing.T , node * HarnessNode ,
2263
+ chanPoint * lnrpc.ChannelPoint ) {
2264
+
2265
+ ctxb := context .Background ()
2266
+
2267
+ // Make sure we can find the closed channel in the channel database.
2268
+ pendingChannels , err := node .PendingChannels (
2269
+ ctxb , & lnrpc.PendingChannelsRequest {},
2270
+ )
2271
+ require .NoError (t , err )
2272
+
2273
+ require .NotEmpty (t , pendingChannels .PendingForceClosingChannels )
2274
+
2275
+ targetChanPointStr := fmt .Sprintf ("%v:%v" , chanPoint .GetFundingTxidStr (),
2276
+ chanPoint .GetOutputIndex ())
2277
+
2278
+ var pendingChan * lnrpc.PendingChannelsResponse_PendingChannel
2279
+ for _ , ch := range pendingChannels .PendingForceClosingChannels {
2280
+ if ch .Channel .ChannelPoint == targetChanPointStr {
2281
+ pendingChan = ch .Channel
2282
+ break
2283
+ }
2284
+ }
2285
+ require .NotNil (t , pendingChan )
2286
+ require .NotEmpty (t , pendingChan .CustomChannelData )
2287
+
2288
+ var closeData rfqmsg.JsonAssetChannel
2289
+ err = json .Unmarshal (pendingChan .CustomChannelData , & closeData )
2290
+ require .NoError (t , err )
2291
+
2292
+ require .GreaterOrEqual (t , len (closeData .FundingAssets ), 1 )
2293
+ }
2294
+
2295
+ // assertWaitingCloseChannelAssetData asserts that the waiting close channel has
2296
+ // the expected asset data.
2297
+ func assertWaitingCloseChannelAssetData (t * testing.T , node * HarnessNode ,
2298
+ chanPoint * lnrpc.ChannelPoint ) {
2299
+
2300
+ ctxb := context .Background ()
2301
+
2302
+ // Make sure we can find the closed channel in the channel database.
2303
+ pendingChannels , err := node .PendingChannels (
2304
+ ctxb , & lnrpc.PendingChannelsRequest {},
2305
+ )
2306
+ require .NoError (t , err )
2307
+
2308
+ require .NotEmpty (t , pendingChannels .WaitingCloseChannels )
2309
+
2310
+ targetChanPointStr := fmt .Sprintf ("%v:%v" , chanPoint .GetFundingTxidStr (),
2311
+ chanPoint .GetOutputIndex ())
2312
+
2313
+ var waitingCloseChan * lnrpc.PendingChannelsResponse_PendingChannel
2314
+ for _ , ch := range pendingChannels .WaitingCloseChannels {
2315
+ if ch .Channel .ChannelPoint == targetChanPointStr {
2316
+ waitingCloseChan = ch .Channel
2317
+ break
2318
+ }
2319
+ }
2320
+ require .NotNil (t , waitingCloseChan )
2321
+ require .NotEmpty (t , waitingCloseChan .CustomChannelData )
2322
+
2323
+ var closeData rfqmsg.JsonAssetChannel
2324
+ err = json .Unmarshal (waitingCloseChan .CustomChannelData , & closeData )
2325
+ require .NoError (t , err )
2326
+
2327
+ require .GreaterOrEqual (t , len (closeData .FundingAssets ), 1 )
2328
+ }
0 commit comments