@@ -380,6 +380,16 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
380380 assertAssetChan (t .t , dave , yara , daveFundingAmount , assetID )
381381 assertAssetChan (t .t , erin , fabia , erinFundingAmount , assetID )
382382
383+ // Before we start sending out payments, let's make sure each node can
384+ // see the other one in the graph and has all required features.
385+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (charlie , dave ))
386+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (dave , charlie ))
387+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (dave , yara ))
388+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (yara , dave ))
389+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (erin , fabia ))
390+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (fabia , erin ))
391+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (charlie , erin ))
392+
383393 // Print initial channel balances.
384394 logBalance (t .t , nodes , assetID , "initial" )
385395
@@ -723,18 +733,16 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
723733 fabiaTap := newTapClient (t .t , fabia )
724734 yaraTap := newTapClient (t .t , yara )
725735
726- groupAsset := itestAsset
727- groupAsset .NewGroupedAsset = true
736+ groupAssetReq := itest .CopyRequest (& mintrpc.MintAssetRequest {
737+ Asset : itestAsset ,
738+ })
739+ groupAssetReq .Asset .NewGroupedAsset = true
728740
729741 // Mint an asset on Charlie and sync all nodes to Charlie as the
730742 // universe.
731743 mintedAssets := itest .MintAssetsConfirmBatch (
732744 t .t , t .lndHarness .Miner .Client , charlieTap ,
733- []* mintrpc.MintAssetRequest {
734- {
735- Asset : groupAsset ,
736- },
737- },
745+ []* mintrpc.MintAssetRequest {groupAssetReq },
738746 )
739747
740748 cents := mintedAssets [0 ]
@@ -924,6 +932,16 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
924932 assertAssetChan (t .t , dave , yara , daveFundingAmount , assetID )
925933 assertAssetChan (t .t , erin , fabia , erinFundingAmount , assetID )
926934
935+ // Before we start sending out payments, let's make sure each node can
936+ // see the other one in the graph and has all required features.
937+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (charlie , dave ))
938+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (dave , charlie ))
939+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (dave , yara ))
940+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (yara , dave ))
941+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (erin , fabia ))
942+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (fabia , erin ))
943+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (charlie , erin ))
944+
927945 // Print initial channel balances.
928946 logBalance (t .t , nodes , assetID , "initial" )
929947
@@ -1276,9 +1294,7 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness,
12761294
12771295 // Charlie's balance should reflect that the funding asset was added to
12781296 // the DB.
1279- assertAssetBalance (
1280- t .t , charlieTap , assetID , uint64 (itestAsset .Amount ),
1281- )
1297+ assertAssetBalance (t .t , charlieTap , assetID , itestAsset .Amount )
12821298
12831299 // Make sure that Charlie properly uploaded funding proof to the
12841300 // Universe server.
@@ -1291,6 +1307,14 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness,
12911307 ),
12921308 )
12931309
1310+ // Make sure the channel shows the correct asset information.
1311+ assertAssetChan (t .t , charlie , dave , fundingAmount , assetID )
1312+
1313+ // Before we start sending out payments, let's make sure each node can
1314+ // see the other one in the graph and has all required features.
1315+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (charlie , dave ))
1316+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (dave , charlie ))
1317+
12941318 // We'll also have dave sync with Charlie+Zane to ensure he has the
12951319 // proof for the funding output. We sync the transfers as well so he
12961320 // has all the proofs needed.
@@ -1441,22 +1465,6 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness,
14411465 t .t , charlieSweepTransfer ,
14421466 ))
14431467
1444- charlieUTXOs , err := charlieTap .ListUtxos (
1445- ctxb , & taprpc.ListUtxosRequest {},
1446- )
1447- require .NoError (t .t , err )
1448-
1449- t .Logf ("Charlie UTXOs: %v" , toProtoJSON (t .t , charlieUTXOs ))
1450-
1451- daveUTXOs , err := daveTap .ListUtxos (
1452- ctxb , & taprpc.ListUtxosRequest {},
1453- )
1454- require .NoError (t .t , err )
1455-
1456- t .Logf ("Dave UTXOs: %v" , toProtoJSON (t .t , daveUTXOs ))
1457-
1458- // TODO(roasbeef): assert 2 charlie UTXOs
1459-
14601468 // Both sides should now reflect their updated asset balances.
14611469 daveBalance := uint64 (numPayments * keySendAmount )
14621470 charlieBalance := itestAsset .Amount - daveBalance
@@ -1465,26 +1473,12 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness,
14651473
14661474 // Dave should have a single managed UTXO that shows he has a new asset
14671475 // UTXO he can use.
1468- err = wait .NoError (func () error {
1469- daveUTXOs , err = daveTap .ListUtxos (
1470- ctxb , & taprpc.ListUtxosRequest {},
1471- )
1472- if err != nil {
1473- return err
1474- }
1475-
1476- if len (daveUTXOs .ManagedUtxos ) != 1 {
1477- return fmt .Errorf ("expected 1 UTXO, got %d" ,
1478- len (daveUTXOs .ManagedUtxos ))
1479- }
1480-
1481- return nil
1482- }, defaultTimeout )
1483- require .NoError (t .t , err )
1484-
1485- t .Logf ("Dave UTXOs: %v" , toProtoJSON (t .t , daveUTXOs ))
1476+ assertNumAssetUTXOs (t .t , daveTap , 1 )
1477+ assertNumAssetUTXOs (t .t , charlieTap , 2 )
14861478}
14871479
1480+ // testCustomChannelsBreach tests a force close scenario that breaches an old
1481+ // state, after both parties have an active asset balance.
14881482func testCustomChannelsBreach (_ context.Context , net * NetworkHarness ,
14891483 t * harnessTest ) {
14901484
@@ -1528,6 +1522,7 @@ func testCustomChannelsBreach(_ context.Context, net *NetworkHarness,
15281522 connectAllNodes (t .t , net , nodes )
15291523 fundAllNodes (t .t , net , nodes )
15301524
1525+ universeTap := newTapClient (t .t , zane )
15311526 charlieTap := newTapClient (t .t , charlie )
15321527 daveTap := newTapClient (t .t , dave )
15331528
@@ -1569,7 +1564,39 @@ func testCustomChannelsBreach(_ context.Context, net *NetworkHarness,
15691564 // With the channel open, mine a block to confirm it.
15701565 mineBlocks (t , net , 6 , 1 )
15711566
1572- time .Sleep (time .Second * 1 )
1567+ // A transfer for the funding transaction should be found in Charlie's
1568+ // DB.
1569+ fundingTxid , err := chainhash .NewHashFromStr (assetFundResp .Txid )
1570+ require .NoError (t .t , err )
1571+ assetFundingTransfer := locateAssetTransfers (
1572+ t .t , charlieTap , * fundingTxid ,
1573+ )
1574+
1575+ t .Logf ("Channel funding transfer: %v" ,
1576+ toProtoJSON (t .t , assetFundingTransfer ))
1577+
1578+ // Charlie's balance should reflect that the funding asset was added to
1579+ // the DB.
1580+ assertAssetBalance (t .t , charlieTap , assetID , itestAsset .Amount )
1581+
1582+ // Make sure that Charlie properly uploaded funding proof to the
1583+ // Universe server.
1584+ fundingScriptTree := tapchannel .NewFundingScriptTree ()
1585+ fundingScriptKey := fundingScriptTree .TaprootKey
1586+ fundingScriptTreeBytes := fundingScriptKey .SerializeCompressed ()
1587+ assertUniverseProofExists (
1588+ t .t , universeTap , assetID , fundingScriptTreeBytes , fmt .Sprintf (
1589+ "%v:%v" , assetFundResp .Txid , assetFundResp .OutputIndex ,
1590+ ),
1591+ )
1592+
1593+ // Make sure the channel shows the correct asset information.
1594+ assertAssetChan (t .t , charlie , dave , fundingAmount , assetID )
1595+
1596+ // Before we start sending out payments, let's make sure each node can
1597+ // see the other one in the graph and has all required features.
1598+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (charlie , dave ))
1599+ require .NoError (t .t , t .lndHarness .AssertNodeKnown (dave , charlie ))
15731600
15741601 // Next, we'll make keysend payments from Charlie to Dave. we'll use
15751602 // this to reach a state where both parties have funds in the channel.
@@ -1672,8 +1699,10 @@ func assertNumAssetUTXOs(t *testing.T, tapdClient *tapClient,
16721699
16731700 ctxb := context .Background ()
16741701
1702+ var clientUTXOs * taprpc.ListUtxosResponse
16751703 err := wait .NoError (func () error {
1676- clientUTXOs , err := tapdClient .ListUtxos (
1704+ var err error
1705+ clientUTXOs , err = tapdClient .ListUtxos (
16771706 ctxb , & taprpc.ListUtxosRequest {},
16781707 )
16791708 if err != nil {
@@ -1687,21 +1716,8 @@ func assertNumAssetUTXOs(t *testing.T, tapdClient *tapClient,
16871716
16881717 return nil
16891718 }, defaultTimeout )
1690-
1691- clientUTXOs , err2 := tapdClient .ListUtxos (
1692- ctxb , & taprpc.ListUtxosRequest {},
1693- )
1694- require .NoError (t , err2 )
1695-
1696- if err != nil {
1697- t .Logf ("wrong amount of UTXOs, got %d, expected %d: %v" ,
1698- len (clientUTXOs .ManagedUtxos ), numUTXOs ,
1699- toProtoJSON (t , clientUTXOs ))
1700-
1701- t .Fatalf ("failed to assert UTXOs: %v" , err )
1702-
1703- return nil
1704- }
1719+ require .NoErrorf (t , err , "failed to assert UTXOs: %v, last state: %v" ,
1720+ err , clientUTXOs )
17051721
17061722 return clientUTXOs
17071723}
0 commit comments