Skip to content

Commit 864b554

Browse files
committed
itest: test side loading of issuance proof
1 parent 7b0541a commit 864b554

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

itest/test_list_on_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ var testCases = []*testCase{
183183
name: "universe sync",
184184
test: testUniverseSync,
185185
},
186+
{
187+
name: "universe sync manual insert",
188+
test: testUniverseManualSync,
189+
},
186190
{
187191
name: "universe federation",
188192
test: testUniverseFederation,

itest/universe_test.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,88 @@ func testUniverseSync(t *harnessTest) {
292292
)
293293
}
294294

295+
// testUniverseManualSync tests that we're able to insert proofs manually into
296+
// a universe instead of using a full sync.
297+
func testUniverseManualSync(t *harnessTest) {
298+
miner := t.lndHarness.Miner.Client
299+
300+
// First, we'll create out usual set of issuable assets.
301+
rpcIssuableAssets := MintAssetsConfirmBatch(
302+
t.t, miner, t.tapd, issuableAssets,
303+
)
304+
305+
// With those assets created, we'll now create a new node that we'll
306+
// use to exercise the manual Universe sync.
307+
bob := setupTapdHarness(
308+
t.t, t, t.lndHarness.Bob, t.universeServer,
309+
func(params *tapdHarnessParams) {
310+
params.noDefaultUniverseSync = true
311+
},
312+
)
313+
defer func() {
314+
require.NoError(t.t, bob.stop(!*noDelete))
315+
}()
316+
317+
ctxb := context.Background()
318+
ctxt, cancel := context.WithTimeout(ctxb, defaultWaitTimeout)
319+
defer cancel()
320+
321+
// We now side load the issuance proof of our first asset into Bob's
322+
// universe.
323+
firstAsset := rpcIssuableAssets[0]
324+
firstAssetGen := firstAsset.AssetGenesis
325+
sendProofUniRPC(t, t.tapd, bob, firstAsset.ScriptKey, firstAssetGen)
326+
327+
// We should also be able to fetch an asset from Bob's Universe, and
328+
// query for that asset with the compressed script key.
329+
firstOutpoint, err := tap.UnmarshalOutpoint(
330+
firstAsset.ChainAnchor.AnchorOutpoint,
331+
)
332+
require.NoError(t.t, err)
333+
334+
firstAssetProofQuery := unirpc.UniverseKey{
335+
Id: &unirpc.ID{
336+
Id: &unirpc.ID_GroupKey{
337+
GroupKey: firstAsset.AssetGroup.TweakedGroupKey,
338+
},
339+
ProofType: unirpc.ProofType_PROOF_TYPE_ISSUANCE,
340+
},
341+
LeafKey: &unirpc.AssetKey{
342+
Outpoint: &unirpc.AssetKey_Op{
343+
Op: &unirpc.Outpoint{
344+
HashStr: firstOutpoint.Hash.String(),
345+
Index: int32(firstOutpoint.Index),
346+
},
347+
},
348+
ScriptKey: &unirpc.AssetKey_ScriptKeyBytes{
349+
ScriptKeyBytes: firstAsset.ScriptKey,
350+
},
351+
},
352+
}
353+
354+
// We should now be able to query for the asset proof.
355+
_, err = bob.QueryProof(ctxt, &firstAssetProofQuery)
356+
require.NoError(t.t, err)
357+
358+
// We should now also be able to fetch the meta data and group key for
359+
// the asset.
360+
metaData, err := bob.FetchAssetMeta(ctxt, &taprpc.FetchAssetMetaRequest{
361+
Asset: &taprpc.FetchAssetMetaRequest_MetaHash{
362+
MetaHash: firstAssetGen.MetaHash,
363+
},
364+
})
365+
require.NoError(t.t, err)
366+
require.Equal(t.t, firstAssetGen.MetaHash, metaData.MetaHash)
367+
368+
// We should be able to create a new address for the asset, since that
369+
// requires us to know the full genesis and group key.
370+
_, err = bob.NewAddr(ctxt, &taprpc.NewAddrRequest{
371+
AssetId: firstAssetGen.AssetId,
372+
Amt: 500,
373+
})
374+
require.NoError(t.t, err)
375+
}
376+
295377
// unmarshalMerkleSumNode un-marshals a protobuf MerkleSumNode.
296378
func unmarshalMerkleSumNode(root *unirpc.MerkleSumNode) mssmt.Node {
297379
var nodeHash mssmt.NodeHash

0 commit comments

Comments
 (0)