@@ -1759,6 +1759,84 @@ func TestAssetGroupComplexWitness(t *testing.T) {
17591759 require .True (t , groupKey .IsEqual (storedGroup .GroupKey ))
17601760}
17611761
1762+ // TestAssetGroupV1 tests that we can store and fetch an asset group version 1.
1763+ func TestAssetGroupV1 (t * testing.T ) {
1764+ t .Parallel ()
1765+
1766+ mintingStore , assetStore , db := newAssetStore (t )
1767+ ctx := context .Background ()
1768+
1769+ internalKey := test .RandPubKey (t )
1770+ groupAnchorGen := asset .RandGenesis (t , asset .RandAssetType (t ))
1771+ groupAnchorGen .MetaHash = [32 ]byte {}
1772+ tapscriptRoot := test .RandBytes (32 )
1773+ customTapscriptRoot := test .RandHash ()
1774+ groupSig := test .RandBytes (64 )
1775+
1776+ // First, we'll insert all the required rows we need to satisfy the
1777+ // foreign key constraints needed to insert a new genesis witness.
1778+ genesisPointID , err := upsertGenesisPoint (
1779+ ctx , db , groupAnchorGen .FirstPrevOut ,
1780+ )
1781+ require .NoError (t , err )
1782+
1783+ genAssetID , err := upsertGenesis (
1784+ ctx , db , genesisPointID , groupAnchorGen ,
1785+ )
1786+ require .NoError (t , err )
1787+
1788+ groupKey := asset.GroupKey {
1789+ Version : asset .GroupKeyV1 ,
1790+ RawKey : keychain.KeyDescriptor {
1791+ PubKey : internalKey ,
1792+ },
1793+ GroupPubKey : * internalKey ,
1794+ TapscriptRoot : tapscriptRoot ,
1795+ CustomTapscriptRoot : fn.Some [chainhash.Hash ](
1796+ customTapscriptRoot ,
1797+ ),
1798+ Witness : fn .MakeSlice (tapscriptRoot , groupSig ),
1799+ }
1800+
1801+ // Upsert, fetch, and check the group key.
1802+ _ , err = upsertGroupKey (
1803+ ctx , & groupKey , assetStore .db , genesisPointID , genAssetID ,
1804+ )
1805+ require .NoError (t , err )
1806+
1807+ storedGroup , err := mintingStore .FetchGroupByGroupKey (ctx , internalKey )
1808+ require .NoError (t , err )
1809+
1810+ require .Equal (t , groupAnchorGen , * storedGroup .Genesis )
1811+ require .True (t , groupKey .IsEqual (storedGroup .GroupKey ))
1812+
1813+ // Formulate a new group key where the custom tapscript root is None.
1814+ // Check that we can insert and fetch the group key.
1815+ groupKeyCustomRootNone := asset.GroupKey {
1816+ Version : asset .GroupKeyV1 ,
1817+ RawKey : keychain.KeyDescriptor {
1818+ PubKey : internalKey ,
1819+ },
1820+ GroupPubKey : * internalKey ,
1821+ TapscriptRoot : tapscriptRoot ,
1822+ CustomTapscriptRoot : fn .None [chainhash.Hash ](),
1823+ Witness : fn .MakeSlice (tapscriptRoot , groupSig ),
1824+ }
1825+
1826+ // Upsert, fetch, and check the group key.
1827+ _ , err = upsertGroupKey (
1828+ ctx , & groupKeyCustomRootNone , assetStore .db , genesisPointID ,
1829+ genAssetID ,
1830+ )
1831+ require .NoError (t , err )
1832+
1833+ storedGroup2 , err := mintingStore .FetchGroupByGroupKey (ctx , internalKey )
1834+ require .NoError (t , err )
1835+
1836+ require .Equal (t , groupAnchorGen , * storedGroup2 .Genesis )
1837+ require .True (t , groupKeyCustomRootNone .IsEqual (storedGroup2 .GroupKey ))
1838+ }
1839+
17621840// TestAssetGroupKeyUpsert tests that if you try to insert another asset group
17631841// key with the same tweaked_group_key, then only one is actually created.
17641842func TestAssetGroupKeyUpsert (t * testing.T ) {
0 commit comments