8
8
tap "github.com/lightninglabs/taproot-assets"
9
9
"github.com/lightninglabs/taproot-assets/fn"
10
10
"github.com/lightninglabs/taproot-assets/internal/test"
11
+ "github.com/lightninglabs/taproot-assets/proof"
11
12
"github.com/lightninglabs/taproot-assets/tappsbt"
12
13
"github.com/lightninglabs/taproot-assets/taprpc"
13
14
wrpc "github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc"
@@ -40,10 +41,6 @@ func testAddresses(t *harnessTest) {
40
41
// assets made above.
41
42
secondTapd := setupTapdHarness (
42
43
t .t , t , t .lndHarness .Bob , t .universeServer ,
43
- func (params * tapdHarnessParams ) {
44
- params .startupSyncNode = t .tapd
45
- params .startupSyncNumAssets = len (rpcAssets )
46
- },
47
44
)
48
45
defer func () {
49
46
require .NoError (t .t , secondTapd .stop (! * noDelete ))
@@ -79,12 +76,6 @@ func testAddresses(t *harnessTest) {
79
76
// Eventually the event should be marked as confirmed.
80
77
AssertAddrEvent (t .t , secondTapd , addr , 1 , statusConfirmed )
81
78
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
-
88
79
// Make sure we have imported and finalized all proofs.
89
80
AssertNonInteractiveRecvComplete (t .t , secondTapd , idx + 1 )
90
81
@@ -175,10 +166,6 @@ func testMultiAddress(t *harnessTest) {
175
166
alice := t .tapd
176
167
bob := setupTapdHarness (
177
168
t .t , t , t .lndHarness .Bob , t .universeServer ,
178
- func (params * tapdHarnessParams ) {
179
- params .startupSyncNode = alice
180
- params .startupSyncNumAssets = len (rpcAssets )
181
- },
182
169
)
183
170
defer func () {
184
171
require .NoError (t .t , bob .stop (! * noDelete ))
@@ -195,7 +182,12 @@ func testMultiAddress(t *harnessTest) {
195
182
func testAddressAssetSyncer (t * harnessTest ) {
196
183
// We'll kick off the test by making a new node, without hooking it up
197
184
// to any existing Universe server.
198
- bob := setupTapdHarness (t .t , t , t .lndHarness .Bob , nil )
185
+ bob := setupTapdHarness (
186
+ t .t , t , t .lndHarness .Bob , t .universeServer ,
187
+ func (params * tapdHarnessParams ) {
188
+ params .noDefaultUniverseSync = true
189
+ },
190
+ )
199
191
defer func () {
200
192
require .NoError (t .t , bob .stop (! * noDelete ))
201
193
}()
@@ -321,8 +313,9 @@ func testAddressAssetSyncer(t *harnessTest) {
321
313
restartBobNoUniSync := func (disableSyncer bool ) {
322
314
require .NoError (t .t , bob .stop (! * noDelete ))
323
315
bob = setupTapdHarness (
324
- t .t , t , t .lndHarness .Bob , nil ,
316
+ t .t , t , t .lndHarness .Bob , t . universeServer ,
325
317
func (params * tapdHarnessParams ) {
318
+ params .noDefaultUniverseSync = true
326
319
params .addrAssetSyncerDisable = disableSyncer
327
320
},
328
321
)
@@ -436,21 +429,18 @@ func runMultiSendTest(ctxt context.Context, t *harnessTest, alice,
436
429
437
430
// In order to force a split, we don't try to send the full asset.
438
431
const sendAmt = 100
439
- var bobAddresses []* taprpc.Addr
440
432
bobAddr1 , err := bob .NewAddr (ctxt , & taprpc.NewAddrRequest {
441
433
AssetId : genInfo .AssetId ,
442
434
Amt : sendAmt ,
443
435
})
444
436
require .NoError (t .t , err )
445
- bobAddresses = append (bobAddresses , bobAddr1 )
446
437
AssertAddrCreated (t .t , bob , mintedAsset , bobAddr1 )
447
438
448
439
bobAddr2 , err := bob .NewAddr (ctxt , & taprpc.NewAddrRequest {
449
440
AssetId : genInfo .AssetId ,
450
441
Amt : sendAmt ,
451
442
})
452
443
require .NoError (t .t , err )
453
- bobAddresses = append (bobAddresses , bobAddr2 )
454
444
AssertAddrCreated (t .t , bob , mintedAsset , bobAddr2 )
455
445
456
446
// To test that Alice can also receive to multiple addresses in a single
@@ -492,14 +482,6 @@ func runMultiSendTest(ctxt context.Context, t *harnessTest, alice,
492
482
// this point, so the status should go to completed directly.
493
483
AssertAddrEventByStatus (t .t , alice , statusCompleted , numRuns * 2 )
494
484
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
-
503
485
// Make sure we have imported and finalized all proofs.
504
486
AssertNonInteractiveRecvComplete (t .t , bob , numRuns * 2 )
505
487
AssertNonInteractiveRecvComplete (t .t , alice , numRuns * 2 )
@@ -531,6 +513,8 @@ func runMultiSendTest(ctxt context.Context, t *harnessTest, alice,
531
513
require .NoError (t .t , err )
532
514
}
533
515
516
+ // sendProof manually exports a proof from the given source node and imports it
517
+ // using the development only ImportProof RPC on the destination node.
534
518
func sendProof (t * harnessTest , src , dst * tapdHarness , scriptKey []byte ,
535
519
genInfo * taprpc.GenesisInfo ) * tapdevrpc.ImportProofResponse {
536
520
@@ -562,6 +546,85 @@ func sendProof(t *harnessTest, src, dst *tapdHarness, scriptKey []byte,
562
546
return importResp
563
547
}
564
548
549
+ // sendProofUniRPC manually exports a proof from the given source node and
550
+ // imports it using the universe related InsertProof RPC on the destination
551
+ // node.
552
+ func sendProofUniRPC (t * harnessTest , src , dst * tapdHarness , scriptKey []byte ,
553
+ genInfo * taprpc.GenesisInfo ) * unirpc.AssetProofResponse {
554
+
555
+ ctxb := context .Background ()
556
+
557
+ var proofResp * taprpc.ProofFile
558
+ waitErr := wait .NoError (func () error {
559
+ resp , err := src .ExportProof (ctxb , & taprpc.ExportProofRequest {
560
+ AssetId : genInfo .AssetId ,
561
+ ScriptKey : scriptKey ,
562
+ })
563
+ if err != nil {
564
+ return err
565
+ }
566
+
567
+ proofResp = resp
568
+ return nil
569
+ }, defaultWaitTimeout )
570
+ require .NoError (t .t , waitErr )
571
+
572
+ t .Logf ("Importing proof %x using InsertProof" , proofResp .RawProofFile )
573
+
574
+ f := proof.File {}
575
+ err := f .Decode (bytes .NewReader (proofResp .RawProofFile ))
576
+ require .NoError (t .t , err )
577
+
578
+ lastProof , err := f .LastProof ()
579
+ require .NoError (t .t , err )
580
+
581
+ var lastProofBytes bytes.Buffer
582
+ err = lastProof .Encode (& lastProofBytes )
583
+ require .NoError (t .t , err )
584
+ asset := lastProof .Asset
585
+
586
+ proofType := universe .ProofTypeTransfer
587
+ if asset .IsGenesisAsset () {
588
+ proofType = universe .ProofTypeIssuance
589
+ }
590
+
591
+ uniID := universe.Identifier {
592
+ AssetID : asset .ID (),
593
+ ProofType : proofType ,
594
+ }
595
+ if asset .GroupKey != nil {
596
+ uniID .GroupKey = & asset .GroupKey .GroupPubKey
597
+ }
598
+
599
+ rpcUniID , err := tap .MarshalUniID (uniID )
600
+ require .NoError (t .t , err )
601
+
602
+ outpoint := & unirpc.Outpoint {
603
+ HashStr : lastProof .AnchorTx .TxHash ().String (),
604
+ Index : int32 (lastProof .InclusionProof .OutputIndex ),
605
+ }
606
+
607
+ importResp , err := dst .InsertProof (ctxb , & unirpc.AssetProof {
608
+ Key : & unirpc.UniverseKey {
609
+ Id : rpcUniID ,
610
+ LeafKey : & unirpc.AssetKey {
611
+ Outpoint : & unirpc.AssetKey_Op {
612
+ Op : outpoint ,
613
+ },
614
+ ScriptKey : & unirpc.AssetKey_ScriptKeyBytes {
615
+ ScriptKeyBytes : scriptKey ,
616
+ },
617
+ },
618
+ },
619
+ AssetLeaf : & unirpc.AssetLeaf {
620
+ Proof : lastProofBytes .Bytes (),
621
+ },
622
+ })
623
+ require .NoError (t .t , err )
624
+
625
+ return importResp
626
+ }
627
+
565
628
// sendAssetsToAddr spends the given input asset and sends the amount specified
566
629
// in the address to the Taproot output derived from the address.
567
630
func sendAssetsToAddr (t * harnessTest , sender * tapdHarness ,
0 commit comments