Skip to content

Commit 7e35182

Browse files
committed
itest: add George node to multi-rfq topology
1 parent 079ba9a commit 7e35182

File tree

2 files changed

+106
-13
lines changed

2 files changed

+106
-13
lines changed

itest/assets_test.go

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,32 @@ type itestNode struct {
7777
// multiRfqNodes contains all the itest nodes that are required to set up the
7878
// multi RFQ network topology.
7979
type multiRfqNodes struct {
80-
charlie, dave, erin, fabia, yara itestNode
81-
universeTap *tapClient
80+
charlie, dave, erin, fabia, yara, george itestNode
81+
universeTap *tapClient
8282
}
8383

8484
// createTestMultiRFQAssetNetwork creates a lightning network topology which
8585
// consists of both bitcoin and asset channels. It focuses on the property of
8686
// having multiple channels available on both the sender and receiver side.
87+
// The George node is using a way different oracle that provides asset rates
88+
// that fall outside of the configured tolerance bounds, leading to RFQ
89+
// negotiation failures.
8790
//
8891
// The topology we are going for looks like the following:
8992
//
90-
// /---[sats]--> Erin --[assets]--\
91-
// / \
92-
// / \
93+
// /---[sats]--> Erin --[assets]--\
94+
// / \
95+
// / \
96+
// / \
9397
//
94-
// Charlie -----[sats]--> Dave --[assets]---->Fabia
98+
// Charlie -----[sats]--> Dave --[assets]--> Fabia
9599
//
96-
// \ /
97-
// \ /
98-
// \---[sats]--> Yara --[assets]--/
100+
// \ / /
101+
// \ / /
102+
// \---[sats]--> Yara --[assets]-----/ /
103+
// \ /
104+
// \ /
105+
// \--[sats]-> George --[assets]-/
99106
func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness,
100107
nodes multiRfqNodes, mintedAsset *taprpc.Asset, assetSendAmount,
101108
fundingAmount uint64, pushSat int64) (*lnrpc.ChannelPoint,
@@ -106,6 +113,7 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness,
106113
erin, erinTap := nodes.erin.Lnd, nodes.erin.Tapd
107114
_, fabiaTap := nodes.fabia.Lnd, nodes.fabia.Tapd
108115
yara, yaraTap := nodes.yara.Lnd, nodes.yara.Tapd
116+
george, georgeTap := nodes.george.Lnd, nodes.george.Tapd
109117
universeTap := nodes.universeTap
110118

111119
// Let's open the normal sats channels between Charlie and the routing
@@ -131,6 +139,13 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness,
131139
},
132140
)
133141

142+
_ = openChannelAndAssert(
143+
t, net, charlie, george, lntest.OpenChannelParams{
144+
Amt: 10_000_000,
145+
SatPerVByte: 5,
146+
},
147+
)
148+
134149
ctxb := context.Background()
135150
assetID := mintedAsset.AssetGenesis.AssetId
136151
var groupKey []byte
@@ -225,6 +240,34 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness,
225240
)
226241
itest.AssertNonInteractiveRecvComplete(t.t, yaraTap, 1)
227242

243+
// We need to send some assets to George, so he can fund an asset
244+
// channel with Fabia.
245+
georgeAddr, err := georgeTap.NewAddr(ctxb, &taprpc.NewAddrRequest{
246+
Amt: assetSendAmount,
247+
AssetId: assetID,
248+
ProofCourierAddr: fmt.Sprintf(
249+
"%s://%s", proof.UniverseRpcCourierType,
250+
charlieTap.node.Cfg.LitAddr(),
251+
),
252+
})
253+
require.NoError(t.t, err)
254+
255+
t.Logf("Sending %v asset units to George...", assetSendAmount)
256+
257+
// Send the assets to George.
258+
itest.AssertAddrCreated(t.t, georgeTap, mintedAsset, georgeAddr)
259+
sendResp, err = charlieTap.SendAsset(ctxb, &taprpc.SendAssetRequest{
260+
TapAddrs: []string{georgeAddr.Encoded},
261+
})
262+
require.NoError(t.t, err)
263+
itest.ConfirmAndAssertOutboundTransfer(
264+
t.t, t.lndHarness.Miner.Client, charlieTap, sendResp, assetID,
265+
[]uint64{
266+
mintedAsset.Amount - 4*assetSendAmount, assetSendAmount,
267+
}, 3, 4,
268+
)
269+
itest.AssertNonInteractiveRecvComplete(t.t, georgeTap, 1)
270+
228271
// We fund the Dave->Fabia channel.
229272
fundRespDF, err := daveTap.FundChannel(
230273
ctxb, &tchrpc.FundChannelRequest{
@@ -264,6 +307,19 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness,
264307
require.NoError(t.t, err)
265308
t.Logf("Funded channel between Yara and Fabia: %v", fundRespYF)
266309

310+
// We fund the George->Fabia channel.
311+
fundRespGF, err := georgeTap.FundChannel(
312+
ctxb, &tchrpc.FundChannelRequest{
313+
AssetAmount: fundingAmount,
314+
AssetId: assetID,
315+
PeerPubkey: fabiaTap.node.PubKey[:],
316+
FeeRateSatPerVbyte: 5,
317+
PushSat: pushSat,
318+
},
319+
)
320+
require.NoError(t.t, err)
321+
t.Logf("Funded channel between George and Fabia: %v", fundRespGF)
322+
267323
// Make sure the pending channel shows up in the list and has the
268324
// custom records set as JSON.
269325
assertPendingChannels(
@@ -275,17 +331,21 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness,
275331
assertPendingChannels(
276332
t.t, yaraTap.node, mintedAsset, 1, fundingAmount, 0,
277333
)
334+
assertPendingChannels(
335+
t.t, georgeTap.node, mintedAsset, 1, fundingAmount, 0,
336+
)
278337

279338
// Now that we've looked at the pending channels, let's actually confirm
280339
// all three of them.
281-
mineBlocks(t, net, 6, 3)
340+
mineBlocks(t, net, 6, 4)
282341

283342
// We'll be tracking the expected asset balances throughout the test, so
284343
// we can assert it after each action.
285-
charlieAssetBalance := mintedAsset.Amount - 3*assetSendAmount
344+
charlieAssetBalance := mintedAsset.Amount - 4*assetSendAmount
286345
daveAssetBalance := assetSendAmount - fundingAmount
287346
erinAssetBalance := assetSendAmount - fundingAmount
288347
yaraAssetBalance := assetSendAmount - fundingAmount
348+
georgeAssetBalance := assetSendAmount - fundingAmount
289349

290350
itest.AssertBalances(
291351
t.t, charlieTap, charlieAssetBalance,
@@ -304,6 +364,10 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness,
304364
t.t, yaraTap, yaraAssetBalance, itest.WithAssetID(assetID),
305365
)
306366

367+
itest.AssertBalances(
368+
t.t, georgeTap, georgeAssetBalance, itest.WithAssetID(assetID),
369+
)
370+
307371
// Assert that the proofs for both channels has been uploaded to the
308372
// designated Universe server.
309373
assertUniverseProofExists(
@@ -318,6 +382,10 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness,
318382
t.t, universeTap, assetID, groupKey, fundingScriptTreeBytes,
319383
fmt.Sprintf("%v:%v", fundRespYF.Txid, fundRespYF.OutputIndex),
320384
)
385+
assertUniverseProofExists(
386+
t.t, universeTap, assetID, groupKey, fundingScriptTreeBytes,
387+
fmt.Sprintf("%v:%v", fundRespGF.Txid, fundRespGF.OutputIndex),
388+
)
321389

322390
return nil, nil, nil
323391
}

itest/litd_custom_channels_test.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ var (
9494
"not_use_on_mainnet",
9595
"--taproot-assets.experimental.rfq.mockoracleassetsperbtc=" +
9696
"5820600",
97+
"--taproot-assets.experimental.rfq.acceptpricedeviationppm=50000",
98+
}...)
99+
100+
litdArgsTemplateDiffOracle = append(litdArgsTemplateNoOracle, []string{
101+
"--taproot-assets.experimental.rfq.priceoracleaddress=" +
102+
"use_mock_price_oracle_service_promise_to_" +
103+
"not_use_on_mainnet",
104+
"--taproot-assets.experimental.rfq.mockoracleassetsperbtc=" +
105+
"8820600",
106+
"--taproot-assets.experimental.rfq.acceptpricedeviationppm=50000",
97107
}...)
98108
)
99109

@@ -2980,6 +2990,7 @@ func testCustomChannelsMultiRFQ(ctx context.Context, net *NetworkHarness,
29802990

29812991
lndArgs := slices.Clone(lndArgsTemplate)
29822992
litdArgs := slices.Clone(litdArgsTemplate)
2993+
litdArgsDiffOracle := slices.Clone(litdArgsTemplateDiffOracle)
29832994

29842995
charlie, err := net.NewNode(
29852996
t.t, "Charlie", lndArgs, false, true, litdArgs...,
@@ -2991,6 +3002,11 @@ func testCustomChannelsMultiRFQ(ctx context.Context, net *NetworkHarness,
29913002
proof.UniverseRpcCourierType, charlie.Cfg.LitAddr(),
29923003
))
29933004

3005+
litdArgsDiffOracle = append(litdArgsDiffOracle, fmt.Sprintf(
3006+
"--taproot-assets.proofcourieraddr=%s://%s",
3007+
proof.UniverseRpcCourierType, charlie.Cfg.LitAddr(),
3008+
))
3009+
29943010
dave, err := net.NewNode(t.t, "Dave", lndArgs, false, true, litdArgs...)
29953011
require.NoError(t.t, err)
29963012
erin, err := net.NewNode(t.t, "Erin", lndArgs, false, true, litdArgs...)
@@ -3003,8 +3019,12 @@ func testCustomChannelsMultiRFQ(ctx context.Context, net *NetworkHarness,
30033019
t.t, "Yara", lndArgs, false, true, litdArgs...,
30043020
)
30053021
require.NoError(t.t, err)
3022+
george, err := net.NewNode(
3023+
t.t, "George", lndArgs, false, true, litdArgsDiffOracle...,
3024+
)
3025+
require.NoError(t.t, err)
30063026

3007-
nodes := []*HarnessNode{charlie, dave, erin, fabia, yara}
3027+
nodes := []*HarnessNode{charlie, dave, erin, fabia, yara, george}
30083028
connectAllNodes(t.t, net, nodes)
30093029
fundAllNodes(t.t, net, nodes)
30103030

@@ -3014,6 +3034,7 @@ func testCustomChannelsMultiRFQ(ctx context.Context, net *NetworkHarness,
30143034
erinTap := newTapClient(t.t, erin)
30153035
fabiaTap := newTapClient(t.t, fabia)
30163036
yaraTap := newTapClient(t.t, yara)
3037+
georgeTap := newTapClient(t.t, george)
30173038

30183039
assetReq := itest.CopyRequest(&mintrpc.MintAssetRequest{
30193040
Asset: itestAsset,
@@ -3031,7 +3052,7 @@ func testCustomChannelsMultiRFQ(ctx context.Context, net *NetworkHarness,
30313052
assetID := cents.AssetGenesis.AssetId
30323053
groupID := cents.GetAssetGroup().GetTweakedGroupKey()
30333054

3034-
syncUniverses(t.t, charlieTap, dave, erin, fabia, yara)
3055+
syncUniverses(t.t, charlieTap, dave, erin, fabia, yara, george)
30353056

30363057
multiRfqNodes := multiRfqNodes{
30373058
charlie: itestNode{
@@ -3054,6 +3075,10 @@ func testCustomChannelsMultiRFQ(ctx context.Context, net *NetworkHarness,
30543075
Lnd: yara,
30553076
Tapd: yaraTap,
30563077
},
3078+
george: itestNode{
3079+
Lnd: george,
3080+
Tapd: georgeTap,
3081+
},
30573082
universeTap: charlieTap,
30583083
}
30593084

0 commit comments

Comments
 (0)