@@ -380,6 +380,16 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
380
380
assertAssetChan (t .t , dave , yara , daveFundingAmount , assetID )
381
381
assertAssetChan (t .t , erin , fabia , erinFundingAmount , assetID )
382
382
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
+
383
393
// Print initial channel balances.
384
394
logBalance (t .t , nodes , assetID , "initial" )
385
395
@@ -723,18 +733,16 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
723
733
fabiaTap := newTapClient (t .t , fabia )
724
734
yaraTap := newTapClient (t .t , yara )
725
735
726
- groupAsset := itestAsset
727
- groupAsset .NewGroupedAsset = true
736
+ groupAssetReq := itest .CopyRequest (& mintrpc.MintAssetRequest {
737
+ Asset : itestAsset ,
738
+ })
739
+ groupAssetReq .Asset .NewGroupedAsset = true
728
740
729
741
// Mint an asset on Charlie and sync all nodes to Charlie as the
730
742
// universe.
731
743
mintedAssets := itest .MintAssetsConfirmBatch (
732
744
t .t , t .lndHarness .Miner .Client , charlieTap ,
733
- []* mintrpc.MintAssetRequest {
734
- {
735
- Asset : groupAsset ,
736
- },
737
- },
745
+ []* mintrpc.MintAssetRequest {groupAssetReq },
738
746
)
739
747
740
748
cents := mintedAssets [0 ]
@@ -924,6 +932,16 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
924
932
assertAssetChan (t .t , dave , yara , daveFundingAmount , assetID )
925
933
assertAssetChan (t .t , erin , fabia , erinFundingAmount , assetID )
926
934
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
+
927
945
// Print initial channel balances.
928
946
logBalance (t .t , nodes , assetID , "initial" )
929
947
@@ -1276,9 +1294,7 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness,
1276
1294
1277
1295
// Charlie's balance should reflect that the funding asset was added to
1278
1296
// the DB.
1279
- assertAssetBalance (
1280
- t .t , charlieTap , assetID , uint64 (itestAsset .Amount ),
1281
- )
1297
+ assertAssetBalance (t .t , charlieTap , assetID , itestAsset .Amount )
1282
1298
1283
1299
// Make sure that Charlie properly uploaded funding proof to the
1284
1300
// Universe server.
@@ -1291,6 +1307,14 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness,
1291
1307
),
1292
1308
)
1293
1309
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
+
1294
1318
// We'll also have dave sync with Charlie+Zane to ensure he has the
1295
1319
// proof for the funding output. We sync the transfers as well so he
1296
1320
// has all the proofs needed.
@@ -1441,22 +1465,6 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness,
1441
1465
t .t , charlieSweepTransfer ,
1442
1466
))
1443
1467
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
-
1460
1468
// Both sides should now reflect their updated asset balances.
1461
1469
daveBalance := uint64 (numPayments * keySendAmount )
1462
1470
charlieBalance := itestAsset .Amount - daveBalance
@@ -1465,26 +1473,12 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness,
1465
1473
1466
1474
// Dave should have a single managed UTXO that shows he has a new asset
1467
1475
// 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 )
1486
1478
}
1487
1479
1480
+ // testCustomChannelsBreach tests a force close scenario that breaches an old
1481
+ // state, after both parties have an active asset balance.
1488
1482
func testCustomChannelsBreach (_ context.Context , net * NetworkHarness ,
1489
1483
t * harnessTest ) {
1490
1484
@@ -1528,6 +1522,7 @@ func testCustomChannelsBreach(_ context.Context, net *NetworkHarness,
1528
1522
connectAllNodes (t .t , net , nodes )
1529
1523
fundAllNodes (t .t , net , nodes )
1530
1524
1525
+ universeTap := newTapClient (t .t , zane )
1531
1526
charlieTap := newTapClient (t .t , charlie )
1532
1527
daveTap := newTapClient (t .t , dave )
1533
1528
@@ -1569,7 +1564,39 @@ func testCustomChannelsBreach(_ context.Context, net *NetworkHarness,
1569
1564
// With the channel open, mine a block to confirm it.
1570
1565
mineBlocks (t , net , 6 , 1 )
1571
1566
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 ))
1573
1600
1574
1601
// Next, we'll make keysend payments from Charlie to Dave. we'll use
1575
1602
// this to reach a state where both parties have funds in the channel.
@@ -1672,8 +1699,10 @@ func assertNumAssetUTXOs(t *testing.T, tapdClient *tapClient,
1672
1699
1673
1700
ctxb := context .Background ()
1674
1701
1702
+ var clientUTXOs * taprpc.ListUtxosResponse
1675
1703
err := wait .NoError (func () error {
1676
- clientUTXOs , err := tapdClient .ListUtxos (
1704
+ var err error
1705
+ clientUTXOs , err = tapdClient .ListUtxos (
1677
1706
ctxb , & taprpc.ListUtxosRequest {},
1678
1707
)
1679
1708
if err != nil {
@@ -1687,21 +1716,8 @@ func assertNumAssetUTXOs(t *testing.T, tapdClient *tapClient,
1687
1716
1688
1717
return nil
1689
1718
}, 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 )
1705
1721
1706
1722
return clientUTXOs
1707
1723
}
0 commit comments