@@ -3,8 +3,11 @@ package tapdb
33import (
44 "context"
55 "math/rand"
6+ "net/url"
67 "testing"
78
9+ "github.com/lightninglabs/taproot-assets/asset"
10+ "github.com/lightninglabs/taproot-assets/fn"
811 "github.com/lightninglabs/taproot-assets/proof"
912 "github.com/stretchr/testify/require"
1013)
@@ -46,15 +49,54 @@ func TestAssetMetaUpsert(t *testing.T) {
4649 // Now we'll insert the meta hash again, but this time we'll add the
4750 // blob.
4851 metaID , err = db .UpsertAssetMeta (ctx , NewAssetMeta {
49- MetaDataHash : metaHash [:],
50- MetaDataBlob : assetMeta .Data ,
52+ MetaDataHash : metaHash [:],
53+ MetaDataBlob : assetMeta .Data ,
54+ MetaDecimalDisplay : sqlInt32 (11 ),
55+ MetaUniverseCommitments : sqlBool (true ),
56+ MetaCanonicalUniverses : []byte ("http://test1\x00 http://test2" ),
57+ MetaDelegationKey : asset .NUMSBytes ,
5158 })
5259 require .NoError (t , err )
5360
5461 // If we fetch the meta, then we should get the blob back this time.
5562 fetchedMeta , err := db .FetchAssetMeta (ctx , metaID )
5663 require .NoError (t , err )
5764 require .Equal (t , metaBlob [:], fetchedMeta .AssetsMetum .MetaDataBlob )
65+ require .Equal (
66+ t , sqlInt32 (11 ), fetchedMeta .AssetsMetum .MetaDecimalDisplay ,
67+ )
68+ require .Equal (
69+ t , sqlBool (true ),
70+ fetchedMeta .AssetsMetum .MetaUniverseCommitments ,
71+ )
72+ require .Equal (
73+ t , []byte ("http://test1\x00 http://test2" ),
74+ fetchedMeta .AssetsMetum .MetaCanonicalUniverses ,
75+ )
76+ require .Equal (
77+ t , asset .NUMSBytes ,
78+ fetchedMeta .AssetsMetum .MetaDelegationKey ,
79+ )
80+
81+ parsed , err := parseAssetMetaReveal (fetchedMeta .AssetsMetum )
82+ require .NoError (t , err )
83+ require .True (t , parsed .IsSome ())
84+
85+ url1 , err := url .ParseRequestURI ("http://test1" )
86+ require .NoError (t , err )
87+ url2 , err := url .ParseRequestURI ("http://test2" )
88+ require .NoError (t , err )
89+ parsed .WhenSome (func (reveal proof.MetaReveal ) {
90+ require .Equal (t , fn .Some (uint32 (11 )), reveal .DecimalDisplay )
91+ require .Equal (t , true , reveal .UniverseCommitments )
92+ require .Equal (
93+ t , fn .Some ([]url.URL {* url1 , * url2 }),
94+ reveal .CanonicalUniverses ,
95+ )
96+ require .Equal (
97+ t , fn .MaybeSome (asset .NUMSPubKey ), reveal .DelegationKey ,
98+ )
99+ })
58100
59101 // If we insert a meta of all zeroes twice, then we should get the same
60102 // value back.
0 commit comments