diff --git a/itest/integration_test.go b/itest/integration_test.go index fd8c87c9c..23ce88307 100644 --- a/itest/integration_test.go +++ b/itest/integration_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/lightninglabs/taproot-assets/taprpc" + "github.com/lightninglabs/taproot-assets/taprpc/priceoraclerpc" "github.com/lightningnetwork/lnd/lntest" "github.com/stretchr/testify/require" ) @@ -129,3 +130,23 @@ func testGetInfo(t *harnessTest) { // Ensure the response matches the expected response. require.Equal(t.t, resp, respCli) } + +// testPriceOracleProxy tests the price oracle proxy. +func testPriceOracleProxy(t *harnessTest) { + ctxb := context.Background() + ctxt, cancel := context.WithTimeout(ctxb, defaultWaitTimeout) + defer cancel() + + resp, err := t.tapd.PriceOracleClient.QueryAssetRates( + ctxt, &priceoraclerpc.QueryAssetRatesRequest{}, + ) + require.NoError(t.t, err) + + okResp := resp.GetOk() + require.NotNil(t.t, okResp) + + require.Equal( + t.t, fmt.Sprintf("%v", mockPriceOracleCoef), + okResp.AssetRates.SubjectAssetRate.Coefficient, + ) +} diff --git a/itest/tapd_harness.go b/itest/tapd_harness.go index 11a61ba63..98e534357 100644 --- a/itest/tapd_harness.go +++ b/itest/tapd_harness.go @@ -23,6 +23,7 @@ import ( "github.com/lightninglabs/taproot-assets/taprpc" "github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc" "github.com/lightninglabs/taproot-assets/taprpc/mintrpc" + "github.com/lightninglabs/taproot-assets/taprpc/priceoraclerpc" "github.com/lightninglabs/taproot-assets/taprpc/rfqrpc" tchrpc "github.com/lightninglabs/taproot-assets/taprpc/tapchannelrpc" "github.com/lightninglabs/taproot-assets/taprpc/tapdevrpc" @@ -83,6 +84,10 @@ const ( // timeout we'll use for waiting for a receiver to acknowledge a proof // transfer. defaultProofTransferReceiverAckTimeout = 500 * time.Millisecond + + // mockPriceOracleCoef is the coefficient used in the mock price oracle + // to calculate the asset rate. + mockPriceOracleCoef = 5_820_600 ) // tapdHarness is a test harness that holds everything that is needed to @@ -102,6 +107,7 @@ type tapdHarness struct { tchrpc.TaprootAssetChannelsClient universerpc.UniverseClient tapdevrpc.TapDevClient + priceoraclerpc.PriceOracleClient } // tapdConfig holds all configuration items that are required to start a tapd @@ -223,7 +229,7 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig, Rfq: rfq.CliConfig{ //nolint:lll PriceOracleAddress: rfq.MockPriceOracleServiceAddress, - MockOracleAssetsPerBTC: 5_820_600, + MockOracleAssetsPerBTC: mockPriceOracleCoef, }, } @@ -425,6 +431,7 @@ func (hs *tapdHarness) start(expectErrExit bool) error { ) hs.UniverseClient = universerpc.NewUniverseClient(rpcConn) hs.TapDevClient = tapdevrpc.NewTapDevClient(rpcConn) + hs.PriceOracleClient = priceoraclerpc.NewPriceOracleClient(rpcConn) return nil } diff --git a/itest/test_list_on_test.go b/itest/test_list_on_test.go index 02f6dd0a0..a1db82168 100644 --- a/itest/test_list_on_test.go +++ b/itest/test_list_on_test.go @@ -336,6 +336,10 @@ var testCases = []*testCase{ name: "asset signing after lnd restore from seed", test: testRestoreLndFromSeed, }, + { + name: "price oracle proxy", + test: testPriceOracleProxy, + }, } var optionalTestCases = []*testCase{