From 3155980a12b34fa9a87d38864654b38add321234 Mon Sep 17 00:00:00 2001 From: ffranr Date: Thu, 31 Aug 2023 21:59:33 +0100 Subject: [PATCH] itest: add universe RPC harness and utilise for basic send --- itest/tapd_harness.go | 7 +++++ itest/test_harness.go | 3 +++ itest/test_list_on_test.go | 5 ++++ itest/universerpc_harness.go | 51 ++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 itest/universerpc_harness.go diff --git a/itest/tapd_harness.go b/itest/tapd_harness.go index feb533955..948e2315b 100644 --- a/itest/tapd_harness.go +++ b/itest/tapd_harness.go @@ -176,6 +176,13 @@ func newTapdHarness(ht *harnessTest, cfg tapdConfig, ReceiverAckTimeout: receiverAckTimeout, BackoffCfg: backoffCfg, } + + case *UniverseRPCHarness: + finalCfg.DefaultProofCourierAddr = fmt.Sprintf( + "%s://%s", proof.UniverseRpcCourierType, + typedProofCourier.ListenAddr, + ) + default: finalCfg.DefaultProofCourierAddr = "" finalCfg.HashMailCourier = nil diff --git a/itest/test_harness.go b/itest/test_harness.go index e17bfbe9e..4fa3d20d5 100644 --- a/itest/test_harness.go +++ b/itest/test_harness.go @@ -284,6 +284,9 @@ func setupHarnesses(t *testing.T, ht *harnessTest, port := nextAvailablePort() apHarness := NewApertureHarness(ht.t, port) proofCourier = &apHarness + + case proof.UniverseRpcCourierType: + proofCourier = NewUniverseRPCHarness(t, ht, lndHarness.Bob) } // Start the proof courier harness if specified. diff --git a/itest/test_list_on_test.go b/itest/test_list_on_test.go index bd021ac10..20c6c9e76 100644 --- a/itest/test_list_on_test.go +++ b/itest/test_list_on_test.go @@ -28,6 +28,11 @@ var testCases = []*testCase{ test: testBasicSendUnidirectional, proofCourierType: proof.ApertureCourier, }, + { + name: "basic send universerpc proof courier", + test: testBasicSendUnidirectional, + proofCourierType: proof.UniverseRpcCourierType, + }, { name: "resume pending package send", test: testResumePendingPackageSend, diff --git a/itest/universerpc_harness.go b/itest/universerpc_harness.go new file mode 100644 index 000000000..b0dcd16d5 --- /dev/null +++ b/itest/universerpc_harness.go @@ -0,0 +1,51 @@ +package itest + +import ( + "testing" + + "github.com/lightninglabs/taproot-assets/proof" + "github.com/lightningnetwork/lnd/lntest/node" + "github.com/stretchr/testify/require" +) + +// UniverseRPCHarness is an integration testing harness for the universe tap +// service. +type UniverseRPCHarness struct { + // service is the instance of the universe tap service. + service *tapdHarness + + // ListenAddr is the address that the service is listening on. + ListenAddr string +} + +// NewUniverseRPCHarness creates a new test harness for a universe tap service. +func NewUniverseRPCHarness(t *testing.T, ht *harnessTest, + lndHarness *node.HarnessNode) *UniverseRPCHarness { + + service, err := newTapdHarness( + ht, tapdConfig{ + NetParams: harnessNetParams, + LndNode: lndHarness, + }, nil, nil, nil, + ) + require.NoError(t, err) + + return &UniverseRPCHarness{ + service: service, + ListenAddr: service.rpcHost(), + } +} + +// Start starts the service. +func (h *UniverseRPCHarness) Start(_ chan error) error { + return h.service.start(false) +} + +// Stop stops the service. +func (h *UniverseRPCHarness) Stop() error { + return h.service.stop(true) +} + +// Ensure that NewUniverseRPCHarness implements the proof.CourierHarness +// interface. +var _ proof.CourierHarness = (*UniverseRPCHarness)(nil)