-
Notifications
You must be signed in to change notification settings - Fork 104
Multi rfq send itest #1097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GeorgeTsagk
wants to merge
5
commits into
lightninglabs:master
Choose a base branch
from
GeorgeTsagk:multi-rfq-send-itest
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Multi rfq send itest #1097
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
decf800
(temp)build: bump tapd, lnd & loop
GeorgeTsagk 574b59e
itest: allow setting empty peer pubkey on tapd SendPayment
GeorgeTsagk 26032b0
itest: enhance multi-rfq itest with sending
GeorgeTsagk 533a39f
make+itest: pin multi-rfq Yara node to v0.15.0-alpha
GeorgeTsagk 33aa187
itest: add George node to multi-rfq topology
GeorgeTsagk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ import ( | |
"github.com/lightninglabs/taproot-assets/tapfreighter" | ||
"github.com/lightninglabs/taproot-assets/taprpc" | ||
"github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc" | ||
"github.com/lightninglabs/taproot-assets/taprpc/authmailboxrpc" | ||
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc" | ||
"github.com/lightninglabs/taproot-assets/taprpc/rfqrpc" | ||
tchrpc "github.com/lightninglabs/taproot-assets/taprpc/tapchannelrpc" | ||
|
@@ -76,25 +77,32 @@ type itestNode struct { | |
// multiRfqNodes contains all the itest nodes that are required to set up the | ||
// multi RFQ network topology. | ||
type multiRfqNodes struct { | ||
charlie, dave, erin, fabia, yara itestNode | ||
universeTap *tapClient | ||
charlie, dave, erin, fabia, yara, george itestNode | ||
universeTap *tapClient | ||
} | ||
|
||
// createTestMultiRFQAssetNetwork creates a lightning network topology which | ||
// consists of both bitcoin and asset channels. It focuses on the property of | ||
// having multiple channels available on both the sender and receiver side. | ||
// The George node is using a way different oracle that provides asset rates | ||
// that fall outside of the configured tolerance bounds, leading to RFQ | ||
// negotiation failures. | ||
// | ||
// The topology we are going for looks like the following: | ||
// | ||
// /---[sats]--> Erin --[assets]--\ | ||
// / \ | ||
// / \ | ||
// /---[sats]--> Erin --[assets]--\ | ||
// / \ | ||
// / \ | ||
// / \ | ||
// | ||
// Charlie -----[sats]--> Dave --[assets]---->Fabia | ||
// Charlie -----[sats]--> Dave --[assets]--> Fabia | ||
// | ||
// \ / | ||
// \ / | ||
// \---[sats]--> Yara --[assets]--/ | ||
// \ / / | ||
// \ / / | ||
// \---[sats]--> Yara --[assets]-----/ / | ||
// \ / | ||
// \ / | ||
// \--[sats]-> George --[assets]-/ | ||
func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness, | ||
nodes multiRfqNodes, mintedAsset *taprpc.Asset, assetSendAmount, | ||
fundingAmount uint64, pushSat int64) (*lnrpc.ChannelPoint, | ||
|
@@ -105,6 +113,7 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness, | |
erin, erinTap := nodes.erin.Lnd, nodes.erin.Tapd | ||
_, fabiaTap := nodes.fabia.Lnd, nodes.fabia.Tapd | ||
yara, yaraTap := nodes.yara.Lnd, nodes.yara.Tapd | ||
george, georgeTap := nodes.george.Lnd, nodes.george.Tapd | ||
universeTap := nodes.universeTap | ||
|
||
// Let's open the normal sats channels between Charlie and the routing | ||
|
@@ -130,6 +139,13 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness, | |
}, | ||
) | ||
|
||
_ = openChannelAndAssert( | ||
t, net, charlie, george, lntest.OpenChannelParams{ | ||
Amt: 10_000_000, | ||
SatPerVByte: 5, | ||
}, | ||
) | ||
|
||
ctxb := context.Background() | ||
assetID := mintedAsset.AssetGenesis.AssetId | ||
var groupKey []byte | ||
|
@@ -224,6 +240,34 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness, | |
) | ||
itest.AssertNonInteractiveRecvComplete(t.t, yaraTap, 1) | ||
|
||
// We need to send some assets to George, so he can fund an asset | ||
// channel with Fabia. | ||
georgeAddr, err := georgeTap.NewAddr(ctxb, &taprpc.NewAddrRequest{ | ||
Amt: assetSendAmount, | ||
AssetId: assetID, | ||
ProofCourierAddr: fmt.Sprintf( | ||
"%s://%s", proof.UniverseRpcCourierType, | ||
charlieTap.node.Cfg.LitAddr(), | ||
), | ||
}) | ||
require.NoError(t.t, err) | ||
|
||
t.Logf("Sending %v asset units to George...", assetSendAmount) | ||
|
||
// Send the assets to George. | ||
itest.AssertAddrCreated(t.t, georgeTap, mintedAsset, georgeAddr) | ||
sendResp, err = charlieTap.SendAsset(ctxb, &taprpc.SendAssetRequest{ | ||
TapAddrs: []string{georgeAddr.Encoded}, | ||
}) | ||
require.NoError(t.t, err) | ||
itest.ConfirmAndAssertOutboundTransfer( | ||
t.t, t.lndHarness.Miner.Client, charlieTap, sendResp, assetID, | ||
[]uint64{ | ||
mintedAsset.Amount - 4*assetSendAmount, assetSendAmount, | ||
}, 3, 4, | ||
) | ||
itest.AssertNonInteractiveRecvComplete(t.t, georgeTap, 1) | ||
|
||
// We fund the Dave->Fabia channel. | ||
fundRespDF, err := daveTap.FundChannel( | ||
ctxb, &tchrpc.FundChannelRequest{ | ||
|
@@ -263,6 +307,19 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness, | |
require.NoError(t.t, err) | ||
t.Logf("Funded channel between Yara and Fabia: %v", fundRespYF) | ||
|
||
// We fund the Yara->Fabia channel. | ||
fundRespGF, err := georgeTap.FundChannel( | ||
ctxb, &tchrpc.FundChannelRequest{ | ||
AssetAmount: fundingAmount, | ||
AssetId: assetID, | ||
PeerPubkey: fabiaTap.node.PubKey[:], | ||
FeeRateSatPerVbyte: 5, | ||
PushSat: pushSat, | ||
}, | ||
) | ||
require.NoError(t.t, err) | ||
t.Logf("Funded channel between George and Fabia: %v", fundRespGF) | ||
|
||
// Make sure the pending channel shows up in the list and has the | ||
// custom records set as JSON. | ||
assertPendingChannels( | ||
|
@@ -274,17 +331,21 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness, | |
assertPendingChannels( | ||
t.t, yaraTap.node, mintedAsset, 1, fundingAmount, 0, | ||
) | ||
assertPendingChannels( | ||
t.t, georgeTap.node, mintedAsset, 1, fundingAmount, 0, | ||
) | ||
|
||
// Now that we've looked at the pending channels, let's actually confirm | ||
// all three of them. | ||
mineBlocks(t, net, 6, 3) | ||
mineBlocks(t, net, 6, 4) | ||
|
||
// We'll be tracking the expected asset balances throughout the test, so | ||
// we can assert it after each action. | ||
charlieAssetBalance := mintedAsset.Amount - 3*assetSendAmount | ||
charlieAssetBalance := mintedAsset.Amount - 4*assetSendAmount | ||
daveAssetBalance := assetSendAmount - fundingAmount | ||
erinAssetBalance := assetSendAmount - fundingAmount | ||
yaraAssetBalance := assetSendAmount - fundingAmount | ||
georgeAssetBalance := assetSendAmount - fundingAmount | ||
|
||
itest.AssertBalances( | ||
t.t, charlieTap, charlieAssetBalance, | ||
|
@@ -303,6 +364,10 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness, | |
t.t, yaraTap, yaraAssetBalance, itest.WithAssetID(assetID), | ||
) | ||
|
||
itest.AssertBalances( | ||
t.t, georgeTap, georgeAssetBalance, itest.WithAssetID(assetID), | ||
) | ||
|
||
// Assert that the proofs for both channels has been uploaded to the | ||
// designated Universe server. | ||
assertUniverseProofExists( | ||
|
@@ -317,6 +382,10 @@ func createTestMultiRFQAssetNetwork(t *harnessTest, net *NetworkHarness, | |
t.t, universeTap, assetID, groupKey, fundingScriptTreeBytes, | ||
fmt.Sprintf("%v:%v", fundRespYF.Txid, fundRespYF.OutputIndex), | ||
) | ||
assertUniverseProofExists( | ||
t.t, universeTap, assetID, groupKey, fundingScriptTreeBytes, | ||
fmt.Sprintf("%v:%v", fundRespGF.Txid, fundRespGF.OutputIndex), | ||
) | ||
|
||
return nil, nil, nil | ||
} | ||
|
@@ -1686,14 +1755,18 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode, | |
sendReq.MaxShardSizeMsat = 80_000_000 | ||
} | ||
|
||
var rfqBytes []byte | ||
var rfqBytes, peerPubKey []byte | ||
cfg.rfq.WhenSome(func(i rfqmsg.ID) { | ||
rfqBytes = make([]byte, len(i[:])) | ||
copy(rfqBytes, i[:]) | ||
}) | ||
|
||
if rfqPeer != nil { | ||
peerPubKey = rfqPeer.PubKey[:] | ||
} | ||
|
||
request := &tchrpc.SendPaymentRequest{ | ||
PeerPubkey: rfqPeer.PubKey[:], | ||
PeerPubkey: peerPubKey, | ||
PaymentRequest: sendReq, | ||
RfqId: rfqBytes, | ||
AllowOverpay: cfg.allowOverpay, | ||
|
@@ -1732,8 +1805,8 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode, | |
acceptedQuote := quoteMsg.GetAcceptedSellOrder() | ||
require.NotNil(t, acceptedQuote) | ||
|
||
peerPubKey := acceptedQuote.Peer | ||
require.Equal(t, peerPubKey, rfqPeer.PubKeyStr) | ||
// peerPubKey := acceptedQuote.Peer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: commented out code. |
||
// require.Equal(t, peerPubKey, rfqPeer.PubKeyStr) | ||
|
||
rpcRate := acceptedQuote.BidAssetRate | ||
rate, err := rpcutils.UnmarshalRfqFixedPoint(rpcRate) | ||
|
@@ -2548,6 +2621,7 @@ type tapClient struct { | |
rfqrpc.RfqClient | ||
tchrpc.TaprootAssetChannelsClient | ||
universerpc.UniverseClient | ||
authmailboxrpc.MailboxClient | ||
} | ||
|
||
func newTapClient(t *testing.T, node *HarnessNode) *tapClient { | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: comment mismatch.