Skip to content

Commit 4048004

Browse files
committed
itest: use oracle harness on rfq group key test
In order to test the new harness and the previous changes, we introduce the oracle server harness in one of our rfq related tests. The 2 peers in this test will now query a real oracle price server instead of defaulting to their mock.
1 parent 5a9239d commit 4048004

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

itest/rfq_test.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import (
88
"testing"
99
"time"
1010

11+
"github.com/btcsuite/btcd/btcec/v2"
1112
"github.com/btcsuite/btcd/btcutil"
1213
"github.com/lightninglabs/taproot-assets/asset"
1314
"github.com/lightninglabs/taproot-assets/fn"
15+
"github.com/lightninglabs/taproot-assets/rfqmath"
1416
"github.com/lightninglabs/taproot-assets/rfqmsg"
1517
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
1618
"github.com/lightninglabs/taproot-assets/taprpc/rfqrpc"
@@ -19,6 +21,7 @@ import (
1921
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
2022
"github.com/lightningnetwork/lnd/lntest"
2123
"github.com/lightningnetwork/lnd/lntest/node"
24+
"github.com/lightningnetwork/lnd/lntest/port"
2225
"github.com/lightningnetwork/lnd/lntest/wait"
2326
"github.com/lightningnetwork/lnd/lnwire"
2427
"github.com/lightningnetwork/lnd/tlv"
@@ -427,8 +430,17 @@ func testRfqAssetSellHtlcIntercept(t *harnessTest) {
427430
// testRfqNegotiationGroupKey checks that two nodes can negotiate and register
428431
// quotes based on a specifier that only uses a group key.
429432
func testRfqNegotiationGroupKey(t *harnessTest) {
433+
// For this test we'll use an actual oracle RPC server harness.
434+
oracleAddr := fmt.Sprintf("localhost:%d", port.NextAvailablePort())
435+
oracle := newOracleHarness(oracleAddr)
436+
oracle.start(t.t)
437+
t.t.Cleanup(oracle.stop)
438+
439+
// We need to craft the oracle server URL in the correct format.
440+
oracleURL := fmt.Sprintf("rfqrpc://%s", oracleAddr)
441+
430442
// Initialize a new test scenario.
431-
ts := newRfqTestScenario(t)
443+
ts := newRfqTestScenario(t, WithRfqOracleServer(oracleURL))
432444

433445
// Mint an asset with Alice's tapd node.
434446
rpcAssets := MintAssetsConfirmBatch(
@@ -438,6 +450,18 @@ func testRfqNegotiationGroupKey(t *harnessTest) {
438450

439451
mintedAssetGroupKey := rpcAssets[0].AssetGroup.TweakedGroupKey
440452

453+
groupKey, err := btcec.ParsePubKey(mintedAssetGroupKey)
454+
require.NoError(t.t, err)
455+
456+
specifierGK := asset.NewSpecifierFromGroupKey(*groupKey)
457+
458+
// Let's set some dummy ask and bid prices. The peers should reach an
459+
// agreement on price.
460+
askPrice := rfqmath.NewBigIntFixedPoint(99_000_00, 2)
461+
bidPrice := rfqmath.NewBigIntFixedPoint(101_000_00, 2)
462+
463+
oracle.setPrice(specifierGK, bidPrice, askPrice)
464+
441465
ctxb := context.Background()
442466
ctxt, cancel := context.WithTimeout(ctxb, defaultWaitTimeout)
443467
defer cancel()

0 commit comments

Comments
 (0)