Skip to content

Commit

Permalink
Merge pull request lightninglabs#712 from lightninglabs/itest-proof-c…
Browse files Browse the repository at this point in the history
…ourier

itest: add main universe server harness, turn on proof courier for all test cases
  • Loading branch information
Roasbeef authored Dec 7, 2023
2 parents 564795a + 6361160 commit 87da1d3
Show file tree
Hide file tree
Showing 25 changed files with 225 additions and 430 deletions.
35 changes: 8 additions & 27 deletions itest/addrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ func testAddresses(t *harnessTest) {
// assets made above.
secondTapd := setupTapdHarness(
t.t, t, t.lndHarness.Bob, t.universeServer,
func(params *tapdHarnessParams) {
params.startupSyncNode = t.tapd
params.startupSyncNumAssets = len(rpcAssets)
},
)
defer func() {
require.NoError(t.t, secondTapd.stop(!*noDelete))
Expand Down Expand Up @@ -79,12 +75,6 @@ func testAddresses(t *harnessTest) {
// Eventually the event should be marked as confirmed.
AssertAddrEvent(t.t, secondTapd, addr, 1, statusConfirmed)

// To complete the transfer, we'll export the proof from the
// sender and import it into the receiver for each asset set.
sendProof(
t, t.tapd, secondTapd, addr.ScriptKey, a.AssetGenesis,
)

// Make sure we have imported and finalized all proofs.
AssertNonInteractiveRecvComplete(t.t, secondTapd, idx+1)

Expand Down Expand Up @@ -175,10 +165,6 @@ func testMultiAddress(t *harnessTest) {
alice := t.tapd
bob := setupTapdHarness(
t.t, t, t.lndHarness.Bob, t.universeServer,
func(params *tapdHarnessParams) {
params.startupSyncNode = alice
params.startupSyncNumAssets = len(rpcAssets)
},
)
defer func() {
require.NoError(t.t, bob.stop(!*noDelete))
Expand All @@ -195,7 +181,12 @@ func testMultiAddress(t *harnessTest) {
func testAddressAssetSyncer(t *harnessTest) {
// We'll kick off the test by making a new node, without hooking it up
// to any existing Universe server.
bob := setupTapdHarness(t.t, t, t.lndHarness.Bob, nil)
bob := setupTapdHarness(
t.t, t, t.lndHarness.Bob, t.universeServer,
func(params *tapdHarnessParams) {
params.noDefaultUniverseSync = true
},
)
defer func() {
require.NoError(t.t, bob.stop(!*noDelete))
}()
Expand Down Expand Up @@ -321,8 +312,9 @@ func testAddressAssetSyncer(t *harnessTest) {
restartBobNoUniSync := func(disableSyncer bool) {
require.NoError(t.t, bob.stop(!*noDelete))
bob = setupTapdHarness(
t.t, t, t.lndHarness.Bob, nil,
t.t, t, t.lndHarness.Bob, t.universeServer,
func(params *tapdHarnessParams) {
params.noDefaultUniverseSync = true
params.addrAssetSyncerDisable = disableSyncer
},
)
Expand Down Expand Up @@ -436,21 +428,18 @@ func runMultiSendTest(ctxt context.Context, t *harnessTest, alice,

// In order to force a split, we don't try to send the full asset.
const sendAmt = 100
var bobAddresses []*taprpc.Addr
bobAddr1, err := bob.NewAddr(ctxt, &taprpc.NewAddrRequest{
AssetId: genInfo.AssetId,
Amt: sendAmt,
})
require.NoError(t.t, err)
bobAddresses = append(bobAddresses, bobAddr1)
AssertAddrCreated(t.t, bob, mintedAsset, bobAddr1)

bobAddr2, err := bob.NewAddr(ctxt, &taprpc.NewAddrRequest{
AssetId: genInfo.AssetId,
Amt: sendAmt,
})
require.NoError(t.t, err)
bobAddresses = append(bobAddresses, bobAddr2)
AssertAddrCreated(t.t, bob, mintedAsset, bobAddr2)

// To test that Alice can also receive to multiple addresses in a single
Expand Down Expand Up @@ -492,14 +481,6 @@ func runMultiSendTest(ctxt context.Context, t *harnessTest, alice,
// this point, so the status should go to completed directly.
AssertAddrEventByStatus(t.t, alice, statusCompleted, numRuns*2)

// To complete the transfer, we'll export the proof from the sender and
// import it into the receiver for each asset set. This should not be
// necessary for the sends to Alice, as she is both the sender and
// receiver and should detect the local proof once it's written to disk.
for i := range bobAddresses {
sendProof(t, alice, bob, bobAddresses[i].ScriptKey, genInfo)
}

// Make sure we have imported and finalized all proofs.
AssertNonInteractiveRecvComplete(t.t, bob, numRuns*2)
AssertNonInteractiveRecvComplete(t.t, alice, numRuns*2)
Expand Down
4 changes: 2 additions & 2 deletions itest/aperture_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type ApertureHarness struct {

// NewApertureHarness creates a new instance of the aperture service. It returns
// a harness which includes useful values for testing.
func NewApertureHarness(t *testing.T, port int) ApertureHarness {
func NewApertureHarness(t *testing.T, port int) *ApertureHarness {
// Create a temporary directory for the aperture service to use.
baseDir := filepath.Join(t.TempDir(), "aperture")
err := os.MkdirAll(baseDir, os.ModePerm)
Expand Down Expand Up @@ -55,7 +55,7 @@ func NewApertureHarness(t *testing.T, port int) ApertureHarness {
}
service := aperture.NewAperture(cfg)

return ApertureHarness{
return &ApertureHarness{
ListenAddr: listenAddr,
Service: service,
}
Expand Down
2 changes: 1 addition & 1 deletion itest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ func AssertBalanceByID(t *testing.T, client taprpc.TaprootAssetsClient,
}

require.True(t, ok)
require.Equal(t, uint64(amt), uint64(balance.Balance))
require.Equal(t, amt, balance.Balance)
}

// AssertBalanceByGroup asserts that the balance of a single asset group
Expand Down
4 changes: 0 additions & 4 deletions itest/collectible_split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ func testCollectibleSend(t *harnessTest) {
// serve as the node which'll receive the assets.
secondTapd := setupTapdHarness(
t.t, t, t.lndHarness.Bob, t.universeServer,
func(params *tapdHarnessParams) {
params.startupSyncNode = t.tapd
params.startupSyncNumAssets = len(rpcAssets)
},
)
defer func() {
require.NoError(t.t, secondTapd.stop(!*noDelete))
Expand Down
12 changes: 4 additions & 8 deletions itest/full_value_split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ func testFullValueSend(t *harnessTest) {
// serve as the node which'll receive the assets.
secondTapd := setupTapdHarness(
t.t, t, t.lndHarness.Bob, t.universeServer,
func(params *tapdHarnessParams) {
params.startupSyncNode = t.tapd
params.startupSyncNumAssets = len(rpcAssets)
},
)
defer func() {
require.NoError(t.t, secondTapd.stop(!*noDelete))
Expand Down Expand Up @@ -88,8 +84,8 @@ func runFullValueSendTests(ctxt context.Context, t *harnessTest, alice,
[]uint64{0, fullAmount}, senderTransferIdx,
senderTransferIdx+1,
)
_ = sendProof(
t, alice, bob, receiverAddr.ScriptKey, genInfo,
AssertNonInteractiveRecvComplete(
t.t, bob, senderTransferIdx+1,
)
senderTransferIdx++
} else {
Expand All @@ -108,8 +104,8 @@ func runFullValueSendTests(ctxt context.Context, t *harnessTest, alice,
genInfo.AssetId, []uint64{0, fullAmount},
receiverTransferIdx, receiverTransferIdx+1,
)
_ = sendProof(
t, bob, alice, receiverAddr.ScriptKey, genInfo,
AssertNonInteractiveRecvComplete(
t.t, alice, receiverTransferIdx+1,
)
receiverTransferIdx++
}
Expand Down
13 changes: 6 additions & 7 deletions itest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ func TestTaprootAssetsDaemon(t *testing.T) {
// The universe server and tapd client are both freshly
// created and later discarded for each test run to
// assure no state is taken over between runs.
tapdHarness, universeServer, proofCourier :=
setupHarnesses(
t1, ht, lndHarness,
testCase.proofCourierType,
)
tapdHarness, uniHarness, proofCourier := setupHarnesses(
t1, ht, lndHarness,
testCase.proofCourierType,
)
lndHarness.EnsureConnected(
lndHarness.Alice, lndHarness.Bob,
)
Expand All @@ -72,8 +71,8 @@ func TestTaprootAssetsDaemon(t *testing.T) {
lndHarness.Bob.AddToLogf(logLine)

ht := ht.newHarnessTest(
t1, lndHarness, universeServer,
tapdHarness, proofCourier,
t1, lndHarness, uniHarness, tapdHarness,
proofCourier,
)

// Now we have everything to run the test case.
Expand Down
2 changes: 1 addition & 1 deletion itest/mint_batch_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testMintBatchNStressTest(t *harnessTest, batchSize int,
// If we create a second tapd instance and sync the universe state,
// the synced tree should match the source tree.
bob := setupTapdHarness(
t.t, t, t.lndHarness.Bob, nil,
t.t, t, t.lndHarness.Bob, t.universeServer,
)
defer func() {
require.NoError(t.t, bob.stop(!*noDelete))
Expand Down
16 changes: 0 additions & 16 deletions itest/multi_asset_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ func testMintMultiAssetGroups(t *harnessTest) {
// ensure that they can be sent and received correctly.
secondTapd := setupTapdHarness(
t.t, t, t.lndHarness.Bob, t.universeServer,
func(params *tapdHarnessParams) {
params.startupSyncNode = t.tapd
params.startupSyncNumAssets = 4
},
)
defer func() {
require.NoError(t.t, secondTapd.stop(!*noDelete))
Expand Down Expand Up @@ -129,10 +125,6 @@ func testMintMultiAssetGroups(t *harnessTest) {
normalMember.AssetGenesis.AssetId,
[]uint64{0, normalMember.Amount}, 0, 1,
)
_ = sendProof(
t, t.tapd, secondTapd, bobNormalAddr.ScriptKey,
normalMemberGenInfo,
)
AssertNonInteractiveRecvComplete(t.t, secondTapd, 1)

AssertBalanceByGroup(
Expand Down Expand Up @@ -170,10 +162,6 @@ func testMintMultiAssetGroups(t *harnessTest) {
collectMember.AssetGenesis.AssetId,
[]uint64{0, collectMember.Amount}, 1, 2,
)
sendProof(
t, t.tapd, secondTapd, bobCollectAddr.ScriptKey,
collectMemberGenInfo,
)
AssertNonInteractiveRecvComplete(t.t, secondTapd, 2)

AssertBalanceByGroup(
Expand Down Expand Up @@ -333,10 +321,6 @@ func testMultiAssetGroupSend(t *harnessTest) {
// assets made above.
secondTapd := setupTapdHarness(
t.t, t, t.lndHarness.Bob, t.universeServer,
func(params *tapdHarnessParams) {
params.startupSyncNode = t.tapd
params.startupSyncNumAssets = groupCount
},
)
defer func() {
require.NoError(t.t, secondTapd.stop(!*noDelete))
Expand Down
Loading

0 comments on commit 87da1d3

Please sign in to comment.