@@ -473,9 +473,9 @@ func assertPendingChannels(t *testing.T, node *HarnessNode,
473473 pendingChan .Channel .CustomChannelData , & pendingJSON ,
474474 )
475475 require .NoError (t , err )
476- require .Len (t , pendingJSON .Assets , 1 )
476+ require .Len (t , pendingJSON .FundingAssets , 1 )
477477
478- require .NotZero (t , pendingJSON .Assets [ 0 ]. Capacity )
478+ require .NotZero (t , pendingJSON .Capacity )
479479
480480 // Check the decimal display of the channel funding blob. If no explicit
481481 // value was set, we assume and expect the value of 0.
@@ -488,7 +488,7 @@ func assertPendingChannels(t *testing.T, node *HarnessNode,
488488
489489 require .Equal (
490490 t , expectedDecimalDisplay ,
491- pendingJSON .Assets [0 ]. AssetInfo .DecimalDisplay ,
491+ pendingJSON .FundingAssets [0 ].DecimalDisplay ,
492492 )
493493
494494 // Check the balance of the pending channel.
@@ -501,21 +501,36 @@ func assertPendingChannels(t *testing.T, node *HarnessNode,
501501 require .EqualValues (t , remoteSum , pendingRemoteBalance )
502502}
503503
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+
504519func assertAssetChan (t * testing.T , src , dst * HarnessNode , fundingAmount uint64 ,
505520 mintedAsset * taprpc.Asset ) {
506521
507- assetID := mintedAsset .AssetGenesis .AssetId
508- assetIDStr := hex .EncodeToString (assetID )
509522 err := wait .NoError (func () error {
510523 a , err := getChannelCustomData (src , dst )
511524 if err != nil {
512525 return err
513526 }
514527
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 )
518532 }
533+
519534 if a .Capacity != fundingAmount {
520535 return fmt .Errorf ("expected capacity %d, got %d" ,
521536 fundingAmount , a .Capacity )
@@ -530,10 +545,10 @@ func assertAssetChan(t *testing.T, src, dst *HarnessNode, fundingAmount uint64,
530545 )
531546 }
532547
533- if a .AssetInfo .DecimalDisplay != expectedDecimalDisplay {
548+ if a .FundingAssets [ 0 ] .DecimalDisplay != expectedDecimalDisplay {
534549 return fmt .Errorf ("expected decimal display %d, got %d" ,
535550 expectedDecimalDisplay ,
536- a .AssetInfo .DecimalDisplay )
551+ a .FundingAssets [ 0 ] .DecimalDisplay )
537552 }
538553
539554 return nil
@@ -580,7 +595,7 @@ func assertChannelKnown(t *testing.T, node *HarnessNode,
580595 require .NoError (t , err )
581596}
582597
583- func getChannelCustomData (src , dst * HarnessNode ) (* rfqmsg.JsonAssetChanInfo ,
598+ func getChannelCustomData (src , dst * HarnessNode ) (* rfqmsg.JsonAssetChannel ,
584599 error ) {
585600
586601 ctxb := context .Background ()
@@ -614,12 +629,12 @@ func getChannelCustomData(src, dst *HarnessNode) (*rfqmsg.JsonAssetChanInfo,
614629 err )
615630 }
616631
617- if len (assetData .Assets ) != 1 {
632+ if len (assetData .FundingAssets ) != 1 {
618633 return nil , fmt .Errorf ("expected 1 asset, got %d" ,
619- len (assetData .Assets ))
634+ len (assetData .FundingAssets ))
620635 }
621636
622- return & assetData . Assets [ 0 ] , nil
637+ return & assetData , nil
623638}
624639
625640func getAssetChannelBalance (t * testing.T , node * HarnessNode , assetID []byte ,
@@ -706,10 +721,10 @@ func assertChannelAssetBalance(t *testing.T, node *HarnessNode,
706721 err := json .Unmarshal (targetChan .CustomChannelData , & assetBalance )
707722 require .NoError (t , err )
708723
709- require .Len (t , assetBalance .Assets , 1 )
724+ require .Len (t , assetBalance .FundingAssets , 1 )
710725
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 )
713728}
714729
715730// addRoutingFee adds the default routing fee (1 part per million fee rate plus
@@ -1385,6 +1400,9 @@ func closeAssetChannelAndAssert(t *harnessTest, net *NetworkHarness,
13851400 )
13861401 require .NoError (t .t , err )
13871402
1403+ assertWaitingCloseChannelAssetData (t .t , local , chanPoint )
1404+ assertWaitingCloseChannelAssetData (t .t , remote , chanPoint )
1405+
13881406 mineBlocks (t , net , 1 , 1 )
13891407
13901408 closeUpdate , err := t .lndHarness .WaitForChannelClose (closeStream )
@@ -1405,6 +1423,9 @@ func closeAssetChannelAndAssert(t *harnessTest, net *NetworkHarness,
14051423 t .t , local , remote , closeTx , closeUpdate , assetID , groupKey ,
14061424 universeTap ,
14071425 )
1426+
1427+ assertClosedChannelAssetData (t .t , local , chanPoint )
1428+ assertClosedChannelAssetData (t .t , remote , chanPoint )
14081429}
14091430
14101431// assertDefaultCoOpCloseBalance returns a default implementation of the co-op
@@ -2128,8 +2149,8 @@ func newCloseExpiryInfo(t *testing.T, node *HarnessNode) forceCloseExpiryInfo {
21282149 csvDelay : mainChan .CsvDelay ,
21292150 currentHeight : nodeInfo .BlockHeight ,
21302151 cltvDelays : cltvs ,
2131- localAssetBalance : assetData .Assets [ 0 ]. LocalBalance ,
2132- remoteAssetBalance : assetData .Assets [ 0 ]. RemoteBalance ,
2152+ localAssetBalance : assetData .LocalBalance ,
2153+ remoteAssetBalance : assetData .RemoteBalance ,
21332154 t : t ,
21342155 node : node ,
21352156 }
@@ -2200,3 +2221,112 @@ func assertInvoiceState(t *testing.T, hn *HarnessNode, payAddr []byte,
22002221 }, defaultTimeout )
22012222 require .NoError (t , err , "timeout waiting for invoice settled state" )
22022223}
2224+
2225+ type pendingChan = lnrpc.PendingChannelsResponse_PendingChannel
2226+
2227+ // assertWaitingCloseChannelAssetData asserts that the waiting close channel has
2228+ // the expected asset data.
2229+ func assertPendingChannelAssetData (t * testing.T , node * HarnessNode ,
2230+ chanPoint * lnrpc.ChannelPoint ,
2231+ find func (string , * lnrpc.PendingChannelsResponse ) * pendingChan ) {
2232+
2233+ ctxb := context .Background ()
2234+
2235+ // Make sure we can find the closed channel in the channel database.
2236+ pendingChannels , err := node .PendingChannels (
2237+ ctxb , & lnrpc.PendingChannelsRequest {},
2238+ )
2239+ require .NoError (t , err )
2240+
2241+ targetChanPointStr := fmt .Sprintf ("%v:%v" ,
2242+ chanPoint .GetFundingTxidStr (), chanPoint .GetOutputIndex ())
2243+
2244+ targetChan := find (targetChanPointStr , pendingChannels )
2245+ require .NotNil (t , targetChan )
2246+ require .NotEmpty (t , targetChan .CustomChannelData )
2247+
2248+ var closeData rfqmsg.JsonAssetChannel
2249+ err = json .Unmarshal (targetChan .CustomChannelData , & closeData )
2250+ require .NoError (t , err )
2251+
2252+ require .GreaterOrEqual (t , len (closeData .FundingAssets ), 1 )
2253+ }
2254+
2255+ // assertPendingForceCloseChannelAssetData asserts that the pending force close
2256+ // channel has the expected asset data.
2257+ func assertPendingForceCloseChannelAssetData (t * testing.T , node * HarnessNode ,
2258+ chanPoint * lnrpc.ChannelPoint ) {
2259+
2260+ assertPendingChannelAssetData (
2261+ t , node , chanPoint , func (chanPoint string ,
2262+ resp * lnrpc.PendingChannelsResponse ) * pendingChan {
2263+
2264+ require .NotEmpty (t , resp .PendingForceClosingChannels )
2265+
2266+ for _ , ch := range resp .PendingForceClosingChannels {
2267+ if ch .Channel .ChannelPoint == chanPoint {
2268+ return ch .Channel
2269+ }
2270+ }
2271+
2272+ return nil
2273+ },
2274+ )
2275+ }
2276+
2277+ // assertWaitingCloseChannelAssetData asserts that the waiting close channel has
2278+ // the expected asset data.
2279+ func assertWaitingCloseChannelAssetData (t * testing.T , node * HarnessNode ,
2280+ chanPoint * lnrpc.ChannelPoint ) {
2281+
2282+ assertPendingChannelAssetData (
2283+ t , node , chanPoint , func (chanPoint string ,
2284+ resp * lnrpc.PendingChannelsResponse ) * pendingChan {
2285+
2286+ require .NotEmpty (t , resp .WaitingCloseChannels )
2287+
2288+ for _ , ch := range resp .WaitingCloseChannels {
2289+ if ch .Channel .ChannelPoint == chanPoint {
2290+ return ch .Channel
2291+ }
2292+ }
2293+
2294+ return nil
2295+ },
2296+ )
2297+ }
2298+
2299+ // assertClosedChannelAssetData asserts that the closed channel has the expected
2300+ // asset data.
2301+ func assertClosedChannelAssetData (t * testing.T , node * HarnessNode ,
2302+ chanPoint * lnrpc.ChannelPoint ) {
2303+
2304+ ctxb := context .Background ()
2305+
2306+ // Make sure we can find the closed channel in the channel database.
2307+ closedChannels , err := node .ClosedChannels (
2308+ ctxb , & lnrpc.ClosedChannelsRequest {},
2309+ )
2310+ require .NoError (t , err )
2311+
2312+ require .NotEmpty (t , closedChannels .Channels )
2313+
2314+ targetChanPointStr := fmt .Sprintf ("%v:%v" ,
2315+ chanPoint .GetFundingTxidStr (), chanPoint .GetOutputIndex ())
2316+
2317+ var closedChan * lnrpc.ChannelCloseSummary
2318+ for _ , ch := range closedChannels .Channels {
2319+ if ch .ChannelPoint == targetChanPointStr {
2320+ closedChan = ch
2321+ break
2322+ }
2323+ }
2324+ require .NotNil (t , closedChan )
2325+ require .NotEmpty (t , closedChan .CustomChannelData )
2326+
2327+ var closeData rfqmsg.JsonAssetChannel
2328+ err = json .Unmarshal (closedChan .CustomChannelData , & closeData )
2329+ require .NoError (t , err )
2330+
2331+ require .GreaterOrEqual (t , len (closeData .FundingAssets ), 1 )
2332+ }
0 commit comments