@@ -20,7 +20,9 @@ import (
2020 "github.com/lightninglabs/taproot-assets/fn"
2121 "github.com/lightninglabs/taproot-assets/proof"
2222 "github.com/lightninglabs/taproot-assets/taprpc"
23+ wrpc "github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc"
2324 "github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
25+ "github.com/lightninglabs/taproot-assets/taprpc/tapdevrpc"
2426 unirpc "github.com/lightninglabs/taproot-assets/taprpc/universerpc"
2527 "github.com/lightninglabs/taproot-assets/universe"
2628 "github.com/lightningnetwork/lnd/lnrpc/chainrpc"
3638 statusCompleted = taprpc .AddrEventStatus_ADDR_EVENT_STATUS_COMPLETED
3739)
3840
41+ // tapClient is an interface that covers all currently available RPC interfaces
42+ // a client should implement.
43+ type tapClient interface {
44+ taprpc.TaprootAssetsClient
45+ wrpc.AssetWalletClient
46+ tapdevrpc.TapDevClient
47+ mintrpc.MintClient
48+ unirpc.UniverseClient
49+ }
50+
3951// AssetCheck is a function type that checks an RPC asset's property.
4052type AssetCheck func (a * taprpc.Asset ) error
4153
@@ -593,7 +605,7 @@ func VerifyProofBlob(t *testing.T, tapClient taprpc.TaprootAssetsClient,
593605
594606// AssertAddrCreated makes sure an address was created correctly for the given
595607// asset.
596- func AssertAddrCreated (t * testing.T , client taprpc. TaprootAssetsClient ,
608+ func AssertAddrCreated (t * testing.T , client tapClient ,
597609 expected * taprpc.Asset , actual * taprpc.Addr ) {
598610
599611 // Was the address created correctly?
@@ -631,6 +643,43 @@ func AssertAddrCreated(t *testing.T, client taprpc.TaprootAssetsClient,
631643
632644 // Does the address in the list contain all information we expect?
633645 AssertAddr (t , expected , rpcAddr )
646+
647+ // We also make sure we can query the script and internal keys of the
648+ // address correctly.
649+ scriptKeyResp , err := client .QueryScriptKey (
650+ ctxt , & wrpc.QueryScriptKeyRequest {
651+ TweakedScriptKey : actual .ScriptKey ,
652+ },
653+ )
654+ require .NoError (t , err )
655+ require .NotNil (t , scriptKeyResp .ScriptKey )
656+ require .NotNil (t , scriptKeyResp .ScriptKey .KeyDesc )
657+ require .NotNil (t , scriptKeyResp .ScriptKey .KeyDesc .KeyLoc )
658+ require .EqualValues (
659+ t , asset .TaprootAssetsKeyFamily ,
660+ scriptKeyResp .ScriptKey .KeyDesc .KeyLoc .KeyFamily ,
661+ )
662+ require .NotEqual (
663+ t , scriptKeyResp .ScriptKey .PubKey ,
664+ scriptKeyResp .ScriptKey .KeyDesc .RawKeyBytes ,
665+ )
666+
667+ internalKeyResp , err := client .QueryInternalKey (
668+ ctxt , & wrpc.QueryInternalKeyRequest {
669+ InternalKey : actual .InternalKey ,
670+ },
671+ )
672+ require .NoError (t , err )
673+ require .NotNil (t , internalKeyResp .InternalKey )
674+ require .NotNil (t , internalKeyResp .InternalKey .KeyLoc )
675+ require .EqualValues (
676+ t , asset .TaprootAssetsKeyFamily ,
677+ internalKeyResp .InternalKey .KeyLoc .KeyFamily ,
678+ )
679+ require .Equal (
680+ t , actual .InternalKey ,
681+ internalKeyResp .InternalKey .RawKeyBytes ,
682+ )
634683}
635684
636685// AssertAddrEvent makes sure the given address was detected by the given
@@ -850,11 +899,8 @@ func AssertAddr(t *testing.T, expected *taprpc.Asset, actual *taprpc.Addr) {
850899 if expected .AssetGroup == nil {
851900 require .Nil (t , actual .GroupKey )
852901 } else {
853- // TODO(guggero): Address 33-byte vs. 32-byte issue in encoded
854- // address vs. database.
855902 require .Equal (
856- t , expected .AssetGroup .TweakedGroupKey [1 :],
857- actual .GroupKey [1 :],
903+ t , expected .AssetGroup .TweakedGroupKey , actual .GroupKey ,
858904 )
859905 }
860906
@@ -863,7 +909,7 @@ func AssertAddr(t *testing.T, expected *taprpc.Asset, actual *taprpc.Addr) {
863909 require .NotEqual (t , expected .ScriptKey , actual .ScriptKey )
864910}
865911
866- // assertEqualAsset asserts that two taprpc.Asset objects are equal, ignoring
912+ // AssertAsset asserts that two taprpc.Asset objects are equal, ignoring
867913// node-specific fields like if script keys are local, if the asset is spent,
868914// or if the anchor information is populated.
869915func AssertAsset (t * testing.T , expected , actual * taprpc.Asset ) {
0 commit comments