@@ -71,7 +71,7 @@ func TestAppendTransition(t *testing.T) {
7171 withBip86Change : true ,
7272 },
7373 {
74- name : "normal with change" ,
74+ name : "normal with change (with split) " ,
7575 assetType : asset .Normal ,
7676 amt : 100 ,
7777 withSplit : true ,
@@ -135,6 +135,14 @@ func runAppendTransitionTest(t *testing.T, assetType asset.Type, amt uint64,
135135
136136 // Add some alt leaves to the commitment anchoring the asset transfer.
137137 altLeaves := asset .ToAltLeaves (asset .RandAltLeaves (t , true ))
138+
139+ // Commit to the stxo of the previous asset. Otherwise, the inclusion
140+ // proofs will fail.
141+ stxoAsset , err := asset .MakeSpentAsset (newAsset .PrevWitnesses [0 ])
142+ require .NoError (t , err )
143+
144+ stxoLeaf := asset .ToAltLeaves ([]* asset.Asset {stxoAsset })
145+ altLeaves = append (altLeaves , stxoLeaf ... )
138146 err = tapCommitment .MergeAltLeaves (altLeaves )
139147 require .NoError (t , err )
140148
@@ -213,6 +221,7 @@ func runAppendTransitionTest(t *testing.T, assetType asset.Type, amt uint64,
213221 // Append the new transition to the genesis blob.
214222 transitionBlob , transitionProof , err := AppendTransition (
215223 genesisBlob , transitionParams , MockVerifierCtx ,
224+ WithVersion (TransitionV1 ),
216225 )
217226 require .NoError (t , err )
218227 require .Greater (t , len (transitionBlob ), len (genesisBlob ))
@@ -293,8 +302,17 @@ func runAppendTransitionTest(t *testing.T, assetType asset.Type, amt uint64,
293302 nil , split1Commitment ,
294303 )
295304 require .NoError (t , err )
305+
306+ // Commit to the stxo of the previous asset. Otherwise, the inclusion
307+ // proofs will fail. With splits this is only needed for the root asset.
308+ stxoAsset1 , err := asset .MakeSpentAsset (split1Asset .PrevWitnesses [0 ])
309+ require .NoError (t , err )
310+
311+ stxoLeaf1 := asset .ToAltLeaves ([]* asset.Asset {stxoAsset1 })
312+ split1AltLeaves = append (split1AltLeaves , stxoLeaf1 ... )
296313 err = tap1Commitment .MergeAltLeaves (split1AltLeaves )
297314 require .NoError (t , err )
315+
298316 tap2Commitment , err := commitment .NewTapCommitment (
299317 nil , split2Commitment ,
300318 )
@@ -361,12 +379,34 @@ func runAppendTransitionTest(t *testing.T, assetType asset.Type, amt uint64,
361379 split1Asset .AssetCommitmentKey (),
362380 )
363381 require .NoError (t , err )
382+
383+ // For the transfer root we also need to the stxo exclusion proofs.
384+ _ , stxo1In2exclusionProof , err := tap2Commitment .Proof (
385+ stxoAsset1 .TapCommitmentKey (),
386+ stxoAsset1 .AssetCommitmentKey (),
387+ )
388+ require .NoError (t , err )
389+
390+ stxoID := asset .ToSerialized (stxoAsset1 .ScriptKey .PubKey )
391+ stxo1In2Proofs := make (map [asset.SerializedKey ]commitment.Proof , 1 )
392+ stxo1In2Proofs [stxoID ] = * stxo1In2exclusionProof
393+
364394 _ , split1In3ExclusionProof , err := tap3Commitment .Proof (
365395 split1Asset .TapCommitmentKey (),
366396 split1Asset .AssetCommitmentKey (),
367397 )
368398 require .NoError (t , err )
369399
400+ // For the transfer root we also need to the stxo exclusion proofs.
401+ _ , stxo1In3exclusionProof , err := tap3Commitment .Proof (
402+ stxoAsset1 .TapCommitmentKey (),
403+ stxoAsset1 .AssetCommitmentKey (),
404+ )
405+ require .NoError (t , err )
406+
407+ stxo1In3Proofs := make (map [asset.SerializedKey ]commitment.Proof , 1 )
408+ stxo1In3Proofs [stxoID ] = * stxo1In3exclusionProof
409+
370410 _ , split2In1ExclusionProof , err := tap1Commitment .Proof (
371411 split2Asset .TapCommitmentKey (),
372412 split2Asset .AssetCommitmentKey (),
@@ -406,13 +446,15 @@ func runAppendTransitionTest(t *testing.T, assetType asset.Type, amt uint64,
406446 OutputIndex : 1 ,
407447 InternalKey : internalKey2 ,
408448 CommitmentProof : & CommitmentProof {
409- Proof : * split1In2ExclusionProof ,
449+ Proof : * split1In2ExclusionProof ,
450+ STXOProofs : stxo1In2Proofs ,
410451 },
411452 }, {
412453 OutputIndex : 2 ,
413454 InternalKey : internalKey3 ,
414455 CommitmentProof : & CommitmentProof {
415- Proof : * split1In3ExclusionProof ,
456+ Proof : * split1In3ExclusionProof ,
457+ STXOProofs : stxo1In3Proofs ,
416458 },
417459 }},
418460 },
@@ -421,6 +463,7 @@ func runAppendTransitionTest(t *testing.T, assetType asset.Type, amt uint64,
421463
422464 split1Blob , split1Proof , err := AppendTransition (
423465 transitionBlob , split1Params , MockVerifierCtx ,
466+ WithVersion (TransitionV1 ),
424467 )
425468 require .NoError (t , err )
426469 require .Greater (t , len (split1Blob ), len (transitionBlob ))
@@ -463,6 +506,7 @@ func runAppendTransitionTest(t *testing.T, assetType asset.Type, amt uint64,
463506
464507 split2Blob , split2Proof , err := AppendTransition (
465508 transitionBlob , split2Params , MockVerifierCtx ,
509+ WithVersion (TransitionV1 ),
466510 )
467511 require .NoError (t , err )
468512 require .Greater (t , len (split2Blob ), len (transitionBlob ))
@@ -506,6 +550,7 @@ func runAppendTransitionTest(t *testing.T, assetType asset.Type, amt uint64,
506550
507551 split3Blob , split3Proof , err := AppendTransition (
508552 transitionBlob , split3Params , MockVerifierCtx ,
553+ WithVersion (TransitionV1 ),
509554 )
510555 require .NoError (t , err )
511556 require .Greater (t , len (split3Blob ), len (transitionBlob ))
0 commit comments