@@ -727,86 +727,6 @@ func TestAssetID(t *testing.T) {
727727 require .NotEqual (t , id [:], differentID [:])
728728}
729729
730- // TestDeriveGroupKey tests that group key derivation fails for assets that are
731- // not eligible to be group anchors.
732- func TestDeriveGroupKey (t * testing.T ) {
733- t .Parallel ()
734-
735- groupPriv := test .RandPrivKey ()
736- groupPub := groupPriv .PubKey ()
737- groupKeyDesc := test .PubToKeyDesc (groupPub )
738- genSigner := NewMockGenesisSigner (groupPriv )
739- genBuilder := MockGroupTxBuilder {}
740-
741- baseGen := RandGenesis (t , Normal )
742- collectGen := RandGenesis (t , Collectible )
743- baseScriptKey := RandScriptKey (t )
744- protoAsset := RandAssetWithValues (t , baseGen , nil , baseScriptKey )
745- nonGenProtoAsset := protoAsset .Copy ()
746- nonGenProtoAsset .PrevWitnesses = []Witness {{
747- PrevID : & PrevID {
748- OutPoint : wire.OutPoint {
749- Hash : hashBytes1 ,
750- Index : 1 ,
751- },
752- ID : hashBytes1 ,
753- ScriptKey : ToSerialized (pubKey ),
754- },
755- TxWitness : sigWitness ,
756- SplitCommitment : nil ,
757- }}
758- groupedProtoAsset := protoAsset .Copy ()
759- groupedProtoAsset .GroupKey = & GroupKey {
760- GroupPubKey : * groupPub ,
761- }
762- groupReq := GroupKeyRequest {
763- RawKey : groupKeyDesc ,
764- AnchorGen : baseGen ,
765- }
766-
767- // A prototype asset is required for building the genesis virtual TX.
768- _ , err := groupReq .BuildGroupVirtualTx (& genBuilder )
769- require .ErrorContains (t , err , "grouped asset cannot be nil" )
770-
771- // The prototype asset must have a genesis witness.
772- groupReq .NewAsset = nonGenProtoAsset
773- _ , err = groupReq .BuildGroupVirtualTx (& genBuilder )
774- require .ErrorContains (t , err , "asset is not a genesis asset" )
775-
776- // The prototype asset must not have a group key set.
777- groupReq .NewAsset = groupedProtoAsset
778- _ , err = groupReq .BuildGroupVirtualTx (& genBuilder )
779- require .ErrorContains (t , err , "asset already has group key" )
780-
781- // The anchor genesis used for signing must have the same asset type
782- // as the prototype asset being signed.
783- groupReq .AnchorGen = collectGen
784- groupReq .NewAsset = protoAsset
785- _ , err = groupReq .BuildGroupVirtualTx (& genBuilder )
786- require .ErrorContains (t , err , "asset group type mismatch" )
787-
788- // The group key request must include an internal key.
789- groupReq .AnchorGen = baseGen
790- groupReq .RawKey .PubKey = nil
791- _ , err = groupReq .BuildGroupVirtualTx (& genBuilder )
792- require .ErrorContains (t , err , "missing group internal key" )
793-
794- // The tapscript root in the group key request must be exactly 32 bytes
795- // if present.
796- groupReq .RawKey = groupKeyDesc
797- groupReq .TapscriptRoot = test .RandBytes (33 )
798- _ , err = groupReq .BuildGroupVirtualTx (& genBuilder )
799- require .ErrorContains (t , err , "tapscript root must be 32 bytes" )
800-
801- groupReq .TapscriptRoot = test .RandBytes (32 )
802- genTx , err := groupReq .BuildGroupVirtualTx (& genBuilder )
803- require .NoError (t , err )
804-
805- groupKey , err := DeriveGroupKey (genSigner , * genTx , groupReq , nil )
806- require .NoError (t , err )
807- require .NotNil (t , groupKey )
808- }
809-
810730// TestAssetWitnesses tests that the asset group witness can be serialized and
811731// parsed correctly, and that signature detection works correctly.
812732func TestAssetWitnesses (t * testing.T ) {
0 commit comments