Skip to content

Commit 87da1d3

Browse files
authored
Merge pull request #712 from lightninglabs/itest-proof-courier
itest: add main universe server harness, turn on proof courier for all test cases
2 parents 564795a + 6361160 commit 87da1d3

25 files changed

+225
-430
lines changed

itest/addrs_test.go

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ func testAddresses(t *harnessTest) {
4040
// assets made above.
4141
secondTapd := setupTapdHarness(
4242
t.t, t, t.lndHarness.Bob, t.universeServer,
43-
func(params *tapdHarnessParams) {
44-
params.startupSyncNode = t.tapd
45-
params.startupSyncNumAssets = len(rpcAssets)
46-
},
4743
)
4844
defer func() {
4945
require.NoError(t.t, secondTapd.stop(!*noDelete))
@@ -79,12 +75,6 @@ func testAddresses(t *harnessTest) {
7975
// Eventually the event should be marked as confirmed.
8076
AssertAddrEvent(t.t, secondTapd, addr, 1, statusConfirmed)
8177

82-
// To complete the transfer, we'll export the proof from the
83-
// sender and import it into the receiver for each asset set.
84-
sendProof(
85-
t, t.tapd, secondTapd, addr.ScriptKey, a.AssetGenesis,
86-
)
87-
8878
// Make sure we have imported and finalized all proofs.
8979
AssertNonInteractiveRecvComplete(t.t, secondTapd, idx+1)
9080

@@ -175,10 +165,6 @@ func testMultiAddress(t *harnessTest) {
175165
alice := t.tapd
176166
bob := setupTapdHarness(
177167
t.t, t, t.lndHarness.Bob, t.universeServer,
178-
func(params *tapdHarnessParams) {
179-
params.startupSyncNode = alice
180-
params.startupSyncNumAssets = len(rpcAssets)
181-
},
182168
)
183169
defer func() {
184170
require.NoError(t.t, bob.stop(!*noDelete))
@@ -195,7 +181,12 @@ func testMultiAddress(t *harnessTest) {
195181
func testAddressAssetSyncer(t *harnessTest) {
196182
// We'll kick off the test by making a new node, without hooking it up
197183
// to any existing Universe server.
198-
bob := setupTapdHarness(t.t, t, t.lndHarness.Bob, nil)
184+
bob := setupTapdHarness(
185+
t.t, t, t.lndHarness.Bob, t.universeServer,
186+
func(params *tapdHarnessParams) {
187+
params.noDefaultUniverseSync = true
188+
},
189+
)
199190
defer func() {
200191
require.NoError(t.t, bob.stop(!*noDelete))
201192
}()
@@ -321,8 +312,9 @@ func testAddressAssetSyncer(t *harnessTest) {
321312
restartBobNoUniSync := func(disableSyncer bool) {
322313
require.NoError(t.t, bob.stop(!*noDelete))
323314
bob = setupTapdHarness(
324-
t.t, t, t.lndHarness.Bob, nil,
315+
t.t, t, t.lndHarness.Bob, t.universeServer,
325316
func(params *tapdHarnessParams) {
317+
params.noDefaultUniverseSync = true
326318
params.addrAssetSyncerDisable = disableSyncer
327319
},
328320
)
@@ -436,21 +428,18 @@ func runMultiSendTest(ctxt context.Context, t *harnessTest, alice,
436428

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

448438
bobAddr2, err := bob.NewAddr(ctxt, &taprpc.NewAddrRequest{
449439
AssetId: genInfo.AssetId,
450440
Amt: sendAmt,
451441
})
452442
require.NoError(t.t, err)
453-
bobAddresses = append(bobAddresses, bobAddr2)
454443
AssertAddrCreated(t.t, bob, mintedAsset, bobAddr2)
455444

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

495-
// To complete the transfer, we'll export the proof from the sender and
496-
// import it into the receiver for each asset set. This should not be
497-
// necessary for the sends to Alice, as she is both the sender and
498-
// receiver and should detect the local proof once it's written to disk.
499-
for i := range bobAddresses {
500-
sendProof(t, alice, bob, bobAddresses[i].ScriptKey, genInfo)
501-
}
502-
503484
// Make sure we have imported and finalized all proofs.
504485
AssertNonInteractiveRecvComplete(t.t, bob, numRuns*2)
505486
AssertNonInteractiveRecvComplete(t.t, alice, numRuns*2)

itest/aperture_harness.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type ApertureHarness struct {
2727

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

58-
return ApertureHarness{
58+
return &ApertureHarness{
5959
ListenAddr: listenAddr,
6060
Service: service,
6161
}

itest/assertions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ func AssertBalanceByID(t *testing.T, client taprpc.TaprootAssetsClient,
870870
}
871871

872872
require.True(t, ok)
873-
require.Equal(t, uint64(amt), uint64(balance.Balance))
873+
require.Equal(t, amt, balance.Balance)
874874
}
875875

876876
// AssertBalanceByGroup asserts that the balance of a single asset group

itest/collectible_split_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ func testCollectibleSend(t *harnessTest) {
5353
// serve as the node which'll receive the assets.
5454
secondTapd := setupTapdHarness(
5555
t.t, t, t.lndHarness.Bob, t.universeServer,
56-
func(params *tapdHarnessParams) {
57-
params.startupSyncNode = t.tapd
58-
params.startupSyncNumAssets = len(rpcAssets)
59-
},
6056
)
6157
defer func() {
6258
require.NoError(t.t, secondTapd.stop(!*noDelete))

itest/full_value_split_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ func testFullValueSend(t *harnessTest) {
3333
// serve as the node which'll receive the assets.
3434
secondTapd := setupTapdHarness(
3535
t.t, t, t.lndHarness.Bob, t.universeServer,
36-
func(params *tapdHarnessParams) {
37-
params.startupSyncNode = t.tapd
38-
params.startupSyncNumAssets = len(rpcAssets)
39-
},
4036
)
4137
defer func() {
4238
require.NoError(t.t, secondTapd.stop(!*noDelete))
@@ -88,8 +84,8 @@ func runFullValueSendTests(ctxt context.Context, t *harnessTest, alice,
8884
[]uint64{0, fullAmount}, senderTransferIdx,
8985
senderTransferIdx+1,
9086
)
91-
_ = sendProof(
92-
t, alice, bob, receiverAddr.ScriptKey, genInfo,
87+
AssertNonInteractiveRecvComplete(
88+
t.t, bob, senderTransferIdx+1,
9389
)
9490
senderTransferIdx++
9591
} else {
@@ -108,8 +104,8 @@ func runFullValueSendTests(ctxt context.Context, t *harnessTest, alice,
108104
genInfo.AssetId, []uint64{0, fullAmount},
109105
receiverTransferIdx, receiverTransferIdx+1,
110106
)
111-
_ = sendProof(
112-
t, bob, alice, receiverAddr.ScriptKey, genInfo,
107+
AssertNonInteractiveRecvComplete(
108+
t.t, alice, receiverTransferIdx+1,
113109
)
114110
receiverTransferIdx++
115111
}

itest/integration_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@ func TestTaprootAssetsDaemon(t *testing.T) {
5959
// The universe server and tapd client are both freshly
6060
// created and later discarded for each test run to
6161
// assure no state is taken over between runs.
62-
tapdHarness, universeServer, proofCourier :=
63-
setupHarnesses(
64-
t1, ht, lndHarness,
65-
testCase.proofCourierType,
66-
)
62+
tapdHarness, uniHarness, proofCourier := setupHarnesses(
63+
t1, ht, lndHarness,
64+
testCase.proofCourierType,
65+
)
6766
lndHarness.EnsureConnected(
6867
lndHarness.Alice, lndHarness.Bob,
6968
)
@@ -72,8 +71,8 @@ func TestTaprootAssetsDaemon(t *testing.T) {
7271
lndHarness.Bob.AddToLogf(logLine)
7372

7473
ht := ht.newHarnessTest(
75-
t1, lndHarness, universeServer,
76-
tapdHarness, proofCourier,
74+
t1, lndHarness, uniHarness, tapdHarness,
75+
proofCourier,
7776
)
7877

7978
// Now we have everything to run the test case.

itest/mint_batch_stress_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func testMintBatchNStressTest(t *harnessTest, batchSize int,
5757
// If we create a second tapd instance and sync the universe state,
5858
// the synced tree should match the source tree.
5959
bob := setupTapdHarness(
60-
t.t, t, t.lndHarness.Bob, nil,
60+
t.t, t, t.lndHarness.Bob, t.universeServer,
6161
)
6262
defer func() {
6363
require.NoError(t.t, bob.stop(!*noDelete))

itest/multi_asset_group_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ func testMintMultiAssetGroups(t *harnessTest) {
9797
// ensure that they can be sent and received correctly.
9898
secondTapd := setupTapdHarness(
9999
t.t, t, t.lndHarness.Bob, t.universeServer,
100-
func(params *tapdHarnessParams) {
101-
params.startupSyncNode = t.tapd
102-
params.startupSyncNumAssets = 4
103-
},
104100
)
105101
defer func() {
106102
require.NoError(t.t, secondTapd.stop(!*noDelete))
@@ -129,10 +125,6 @@ func testMintMultiAssetGroups(t *harnessTest) {
129125
normalMember.AssetGenesis.AssetId,
130126
[]uint64{0, normalMember.Amount}, 0, 1,
131127
)
132-
_ = sendProof(
133-
t, t.tapd, secondTapd, bobNormalAddr.ScriptKey,
134-
normalMemberGenInfo,
135-
)
136128
AssertNonInteractiveRecvComplete(t.t, secondTapd, 1)
137129

138130
AssertBalanceByGroup(
@@ -170,10 +162,6 @@ func testMintMultiAssetGroups(t *harnessTest) {
170162
collectMember.AssetGenesis.AssetId,
171163
[]uint64{0, collectMember.Amount}, 1, 2,
172164
)
173-
sendProof(
174-
t, t.tapd, secondTapd, bobCollectAddr.ScriptKey,
175-
collectMemberGenInfo,
176-
)
177165
AssertNonInteractiveRecvComplete(t.t, secondTapd, 2)
178166

179167
AssertBalanceByGroup(
@@ -333,10 +321,6 @@ func testMultiAssetGroupSend(t *harnessTest) {
333321
// assets made above.
334322
secondTapd := setupTapdHarness(
335323
t.t, t, t.lndHarness.Bob, t.universeServer,
336-
func(params *tapdHarnessParams) {
337-
params.startupSyncNode = t.tapd
338-
params.startupSyncNumAssets = groupCount
339-
},
340324
)
341325
defer func() {
342326
require.NoError(t.t, secondTapd.stop(!*noDelete))

0 commit comments

Comments
 (0)