@@ -1844,6 +1844,10 @@ func defaultCoOpCloseBalanceCheck(t *testing.T, local, remote *HarnessNode,
18441844 assetIDs [][]byte , groupKey []byte , universeTap * tapClient ,
18451845 remoteBtcBalance , remoteAssetBalance bool ) {
18461846
1847+ ctxb := context .Background ()
1848+ ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
1849+ defer cancel ()
1850+
18471851 // With the channel closed, we'll now assert that the co-op close
18481852 // transaction was inserted into the local universe.
18491853 //
@@ -1941,10 +1945,34 @@ func defaultCoOpCloseBalanceCheck(t *testing.T, local, remote *HarnessNode,
19411945 closeTx .TxOut [localAssetIndex ].PkScript ,
19421946 )
19431947
1948+ // Because we don't exactly know what asset IDs made it into the close
1949+ // transaction, we need to fetch the closed channel to find that out.
1950+ closedChans , err := local .ClosedChannels (
1951+ ctxt , & lnrpc.ClosedChannelsRequest {
1952+ Cooperative : true ,
1953+ },
1954+ )
1955+ require .NoError (t , err )
1956+ require .NotEmpty (t , closedChans .Channels )
1957+
1958+ var closedJsonChannel * rfqmsg.JsonAssetChannel
1959+ for _ , closedChan := range closedChans .Channels {
1960+ if closedChan .ClosingTxHash == closeTx .TxHash ().String () {
1961+ closedJsonChannel = & rfqmsg.JsonAssetChannel {}
1962+ err = json .Unmarshal (
1963+ closedChan .CustomChannelData , closedJsonChannel ,
1964+ )
1965+ require .NoError (t , err )
1966+
1967+ break
1968+ }
1969+ }
1970+ require .NotNil (t , closedJsonChannel )
1971+
19441972 // We now verify the arrival of the local balance asset proof at the
19451973 // universe server.
19461974 var localAssetCloseOut rfqmsg.JsonCloseOutput
1947- err : = json .Unmarshal (
1975+ err = json .Unmarshal (
19481976 localCloseOut .CustomChannelData , & localAssetCloseOut ,
19491977 )
19501978 require .NoError (t , err )
@@ -1956,6 +1984,19 @@ func defaultCoOpCloseBalanceCheck(t *testing.T, local, remote *HarnessNode,
19561984
19571985 require .Contains (t , assetIDStrings , assetIDStr )
19581986
1987+ // We only check for a proof if an asset of that asset ID was
1988+ // actually in the close output, which might not always be the
1989+ // case in grouped asset channels.
1990+ localAssetIDs := fn .NewSet [string ](fn .Map (
1991+ func (t rfqmsg.JsonAssetTranche ) string {
1992+ return t .AssetID
1993+ },
1994+ closedJsonChannel .LocalAssets ,
1995+ )... )
1996+ if ! localAssetIDs .Contains (assetIDStr ) {
1997+ continue
1998+ }
1999+
19592000 assetID , err := hex .DecodeString (assetIDStr )
19602001 require .NoError (t , err )
19612002
@@ -1995,6 +2036,19 @@ func defaultCoOpCloseBalanceCheck(t *testing.T, local, remote *HarnessNode,
19952036
19962037 require .Contains (t , assetIDStrings , assetIDStr )
19972038
2039+ // We only check for a proof if an asset of that asset ID was
2040+ // actually in the close output, which might not always be the
2041+ // case in grouped asset channels.
2042+ remoteAssetIDs := fn .NewSet [string ](fn .Map (
2043+ func (t rfqmsg.JsonAssetTranche ) string {
2044+ return t .AssetID
2045+ },
2046+ closedJsonChannel .RemoteAssets ,
2047+ )... )
2048+ if ! remoteAssetIDs .Contains (assetIDStr ) {
2049+ continue
2050+ }
2051+
19982052 assetID , err := hex .DecodeString (assetIDStr )
19992053 require .NoError (t , err )
20002054
0 commit comments