@@ -72,39 +72,44 @@ func TestNewAssetCommitment(t *testing.T) {
7272 t .Parallel ()
7373
7474 genesis1 := asset .RandGenesis (t , asset .Normal )
75+ genesis2 := asset .RandGenesis (t , asset .Normal )
7576 genesis1Collectible := asset .RandGenesis (t , asset .Collectible )
76- genesis1CollectibleScriptKey := asset .RandScriptKey (t )
7777 genesis1CollectibleProtoAsset := asset .NewAssetNoErr (
78- t , genesis1Collectible , 1 , 0 , 0 , genesis1CollectibleScriptKey ,
79- nil ,
80- )
81- genesis2 := asset .RandGenesis (t , asset .Normal )
82- genesis2ProtoAsset := asset .RandAssetWithValues (
83- t , genesis2 , nil , asset .RandScriptKey (t ),
78+ t , genesis1Collectible , 1 , 0 , 0 , asset .RandScriptKey (t ), nil ,
8479 )
8580 group1Anchor := randAsset (t , genesis1 , nil )
8681 groupKey1 , group1PrivBytes := asset .RandGroupKeyWithSigner (
8782 t , genesis1 , group1Anchor ,
8883 )
89- group1Priv , group1Pub := btcec .PrivKeyFromBytes (group1PrivBytes )
90- group1Anchor .GroupKey = groupKey1
84+ group1Anchor = asset .NewAssetNoErr (
85+ t , genesis1 , group1Anchor .Amount , group1Anchor .LockTime ,
86+ group1Anchor .RelativeLockTime , group1Anchor .ScriptKey ,
87+ groupKey1 ,
88+ )
9189 groupKey1Collectible := asset .RandGroupKey (
9290 t , genesis1Collectible , genesis1CollectibleProtoAsset ,
9391 )
92+ genesis2ProtoAsset := randAsset (t , genesis2 , nil )
9493 groupKey2 := asset .RandGroupKey (t , genesis2 , genesis2ProtoAsset )
9594 copyOfGroupKey1Collectible := & asset.GroupKey {
96- RawKey : groupKey1Collectible .RawKey ,
97- GroupPubKey : groupKey1Collectible .GroupPubKey ,
98- Witness : groupKey1Collectible .Witness ,
95+ RawKey : groupKey1Collectible .RawKey ,
96+ GroupPubKey : groupKey1Collectible .GroupPubKey ,
97+ TapscriptRoot : groupKey1Collectible .TapscriptRoot ,
98+ Witness : groupKey1Collectible .Witness ,
9999 }
100100 group1Reissued := randAsset (t , genesis2 , nil )
101101 genTxBuilder := asset.MockGroupTxBuilder {}
102+ group1Priv , group1Pub := btcec .PrivKeyFromBytes (group1PrivBytes )
102103 group1ReissuedGroupKey , err := asset .DeriveGroupKey (
103104 asset .NewMockGenesisSigner (group1Priv ), & genTxBuilder ,
104105 test .PubToKeyDesc (group1Pub ), genesis1 , genesis2ProtoAsset ,
105106 )
106107 require .NoError (t , err )
107- group1Reissued .GroupKey = group1ReissuedGroupKey
108+ group1Reissued = asset .NewAssetNoErr (
109+ t , genesis2 , group1Reissued .Amount , group1Reissued .LockTime ,
110+ group1Reissued .RelativeLockTime , group1Reissued .ScriptKey ,
111+ group1ReissuedGroupKey ,
112+ )
108113
109114 testCases := []struct {
110115 name string
@@ -503,10 +508,6 @@ func TestSplitCommitment(t *testing.T) {
503508 groupKeyCollectible := asset .RandGroupKey (
504509 t , genesisCollectible , collectibleProtoAsset ,
505510 )
506- normalInputAsset := normalProtoAsset .Copy ()
507- normalInputAsset .GroupKey = groupKeyNormal
508- collectibleInputAsset := collectibleProtoAsset .Copy ()
509- collectibleInputAsset .GroupKey = groupKeyCollectible
510511
511512 testCases := []struct {
512513 name string
@@ -898,7 +899,10 @@ func TestTapCommitmentKeyPopulation(t *testing.T) {
898899 var groupKey * asset.GroupKey
899900 if assetDesc .HasGroupKey {
900901 groupKey = asset .RandGroupKey (t , genesis , a )
901- a .GroupKey = groupKey
902+ a = asset .NewAssetNoErr (
903+ t , genesis , a .Amount , a .LockTime ,
904+ a .RelativeLockTime , a .ScriptKey , groupKey ,
905+ )
902906 }
903907
904908 commitment , err := NewAssetCommitment (a )
@@ -932,18 +936,26 @@ func TestUpdateAssetCommitment(t *testing.T) {
932936 groupKey1 , group1PrivBytes := asset .RandGroupKeyWithSigner (
933937 t , genesis1 , group1Anchor ,
934938 )
935- group1Priv , group1Pub := btcec .PrivKeyFromBytes (group1PrivBytes )
936- group1Anchor .GroupKey = groupKey1
939+ group1Anchor = asset .NewAssetNoErr (
940+ t , genesis1 , group1Anchor .Amount , group1Anchor .LockTime ,
941+ group1Anchor .RelativeLockTime , group1Anchor .ScriptKey ,
942+ groupKey1 ,
943+ )
937944 group2Anchor := randAsset (t , genesis2 , nil )
938945 groupKey2 := asset .RandGroupKey (t , genesis2 , group2Anchor )
939- group1Reissued := group2Anchor . Copy ( )
946+ group1Reissued := randAsset ( t , genesis2 , nil )
940947 genTxBuilder := asset.MockGroupTxBuilder {}
948+ group1Priv , group1Pub := btcec .PrivKeyFromBytes (group1PrivBytes )
941949 group1ReissuedGroupKey , err := asset .DeriveGroupKey (
942950 asset .NewMockGenesisSigner (group1Priv ), & genTxBuilder ,
943951 test .PubToKeyDesc (group1Pub ), genesis1 , group1Reissued ,
944952 )
945953 require .NoError (t , err )
946- group1Reissued .GroupKey = group1ReissuedGroupKey
954+ group1Reissued = asset .NewAssetNoErr (
955+ t , genesis2 , group1Reissued .Amount , group1Reissued .LockTime ,
956+ group1Reissued .RelativeLockTime , group1Reissued .ScriptKey ,
957+ group1ReissuedGroupKey ,
958+ )
947959
948960 assetNoGroup := randAsset (t , genesis2 , nil )
949961 copyOfAssetNoGroup := assetNoGroup .Copy ()
@@ -990,19 +1002,6 @@ func TestUpdateAssetCommitment(t *testing.T) {
9901002 {
9911003 name : "insertion of asset with group key" ,
9921004 f : func () (* asset.Asset , error ) {
993- group1Reissued := randAsset (t , genesis2 , nil )
994- genTxBuilder := asset.MockGroupTxBuilder {}
995- gen2ProtoAsset := asset .RandAssetWithValues (
996- t , genesis2 , nil , asset .RandScriptKey (t ),
997- )
998- group1ReissuedGroupKey , err := asset .DeriveGroupKey (
999- asset .NewMockGenesisSigner (group1Priv ),
1000- & genTxBuilder ,
1001- test .PubToKeyDesc (group1Priv .PubKey ()),
1002- genesis1 , gen2ProtoAsset ,
1003- )
1004- require .NoError (t , err )
1005- group1Reissued .GroupKey = group1ReissuedGroupKey
10061005 return group1Reissued ,
10071006 groupAssetCommitment .Upsert (group1Reissued )
10081007 },
@@ -1088,11 +1087,15 @@ func TestUpdateTapCommitment(t *testing.T) {
10881087 genesis3 := asset .RandGenesis (t , asset .Normal )
10891088 asset3 := randAsset (t , genesis3 , groupKey1 )
10901089
1091- asset1 := protoAsset1 .Copy ()
1092- asset1 .GroupKey = groupKey1
1090+ asset1 := asset .NewAssetNoErr (
1091+ t , genesis1 , protoAsset1 .Amount , protoAsset1 .LockTime ,
1092+ protoAsset1 .RelativeLockTime , protoAsset1 .ScriptKey , groupKey1 ,
1093+ )
10931094
1094- asset2 := protoAsset2 .Copy ()
1095- asset2 .GroupKey = groupKey2
1095+ asset2 := asset .NewAssetNoErr (
1096+ t , genesis2 , protoAsset2 .Amount , protoAsset2 .LockTime ,
1097+ protoAsset2 .RelativeLockTime , protoAsset2 .ScriptKey , groupKey2 ,
1098+ )
10961099
10971100 assetCommitment1 , err := NewAssetCommitment (asset1 )
10981101 require .NoError (t , err )
@@ -1260,14 +1263,18 @@ func TestTapCommitmentDeepCopy(t *testing.T) {
12601263 genesis1 := asset .RandGenesis (t , asset .Normal )
12611264 protoAsset1 := randAsset (t , genesis1 , nil )
12621265 groupKey1 := asset .RandGroupKey (t , genesis1 , protoAsset1 )
1263- asset1 := protoAsset1 .Copy ()
1264- asset1 .GroupKey = groupKey1
1266+ asset1 := asset .NewAssetNoErr (
1267+ t , genesis1 , protoAsset1 .Amount , protoAsset1 .LockTime ,
1268+ protoAsset1 .RelativeLockTime , protoAsset1 .ScriptKey , groupKey1 ,
1269+ )
12651270
12661271 genesis2 := asset .RandGenesis (t , asset .Normal )
12671272 protoAsset2 := randAsset (t , genesis2 , nil )
12681273 groupKey2 := asset .RandGroupKey (t , genesis2 , protoAsset2 )
1269- asset2 := protoAsset2 .Copy ()
1270- asset2 .GroupKey = groupKey2
1274+ asset2 := asset .NewAssetNoErr (
1275+ t , genesis2 , protoAsset2 .Amount , protoAsset2 .LockTime ,
1276+ protoAsset2 .RelativeLockTime , protoAsset2 .ScriptKey , groupKey2 ,
1277+ )
12711278
12721279 assetCommitment1 , err := NewAssetCommitment (asset1 )
12731280 require .NoError (t , err )
0 commit comments