Skip to content

Commit d4f5e17

Browse files
committed
vm: test group anchors with script witnesses
1 parent a338f0e commit d4f5e17

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

vm/vm_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,19 @@ func splitCollectibleStateTransition(validRoot bool) stateTransitionFunc {
444444
}
445445
}
446446

447+
func groupAnchorStateTransition(useHashLock, BIP86, keySpend, valid bool,
448+
assetType asset.Type) stateTransitionFunc {
449+
450+
return func(t *testing.T) (*asset.Asset, commitment.SplitSet,
451+
commitment.InputSet) {
452+
453+
gen := asset.RandGenesis(t, assetType)
454+
return asset.AssetCustomGroupKey(
455+
t, useHashLock, BIP86, keySpend, valid, gen,
456+
), nil, nil
457+
}
458+
}
459+
447460
func scriptTreeSpendStateTransition(t *testing.T, useHashLock,
448461
valid bool, sigHashType txscript.SigHashType) stateTransitionFunc {
449462

@@ -557,6 +570,48 @@ func TestVM(t *testing.T) {
557570
),
558571
err: newErrKind(ErrInvalidGenesisStateTransition),
559572
},
573+
{
574+
name: "collectible group anchor BIP86 key",
575+
f: groupAnchorStateTransition(
576+
true, true, false, false, asset.Collectible,
577+
),
578+
err: nil,
579+
},
580+
{
581+
name: "normal group anchor key spend",
582+
f: groupAnchorStateTransition(
583+
true, false, true, true, asset.Normal,
584+
),
585+
err: nil,
586+
},
587+
{
588+
name: "normal group anchor hash lock witness",
589+
f: groupAnchorStateTransition(
590+
true, false, false, true, asset.Normal,
591+
),
592+
err: nil,
593+
},
594+
{
595+
name: "collectible group anchor sig script witness",
596+
f: groupAnchorStateTransition(
597+
false, false, false, true, asset.Collectible,
598+
),
599+
err: nil,
600+
},
601+
{
602+
name: "collectible group anchor invalid hash lock",
603+
f: groupAnchorStateTransition(
604+
true, false, false, false, asset.Collectible,
605+
),
606+
err: invalidHashLockErr,
607+
},
608+
{
609+
name: "normal group anchor invalid sig",
610+
f: groupAnchorStateTransition(
611+
false, false, false, false, asset.Normal,
612+
),
613+
err: invalidSigErr,
614+
},
560615
{
561616
name: "invalid split collectible input",
562617
f: splitCollectibleStateTransition(false),

0 commit comments

Comments
 (0)