@@ -1844,6 +1844,10 @@ func defaultCoOpCloseBalanceCheck(t *testing.T, local, remote *HarnessNode,
1844
1844
assetIDs [][]byte , groupKey []byte , universeTap * tapClient ,
1845
1845
remoteBtcBalance , remoteAssetBalance bool ) {
1846
1846
1847
+ ctxb := context .Background ()
1848
+ ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
1849
+ defer cancel ()
1850
+
1847
1851
// With the channel closed, we'll now assert that the co-op close
1848
1852
// transaction was inserted into the local universe.
1849
1853
//
@@ -1941,10 +1945,34 @@ func defaultCoOpCloseBalanceCheck(t *testing.T, local, remote *HarnessNode,
1941
1945
closeTx .TxOut [localAssetIndex ].PkScript ,
1942
1946
)
1943
1947
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
+
1944
1972
// We now verify the arrival of the local balance asset proof at the
1945
1973
// universe server.
1946
1974
var localAssetCloseOut rfqmsg.JsonCloseOutput
1947
- err : = json .Unmarshal (
1975
+ err = json .Unmarshal (
1948
1976
localCloseOut .CustomChannelData , & localAssetCloseOut ,
1949
1977
)
1950
1978
require .NoError (t , err )
@@ -1956,6 +1984,19 @@ func defaultCoOpCloseBalanceCheck(t *testing.T, local, remote *HarnessNode,
1956
1984
1957
1985
require .Contains (t , assetIDStrings , assetIDStr )
1958
1986
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
+
1959
2000
assetID , err := hex .DecodeString (assetIDStr )
1960
2001
require .NoError (t , err )
1961
2002
@@ -1995,6 +2036,19 @@ func defaultCoOpCloseBalanceCheck(t *testing.T, local, remote *HarnessNode,
1995
2036
1996
2037
require .Contains (t , assetIDStrings , assetIDStr )
1997
2038
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
+
1998
2052
assetID , err := hex .DecodeString (assetIDStr )
1999
2053
require .NoError (t , err )
2000
2054
0 commit comments