@@ -61,83 +61,41 @@ func TestDecode(t *testing.T) {
6161 gogoproto .RegisterType (& testpb.A {}, string ((& testpb.A {}).ProtoReflect ().Descriptor ().FullName ()))
6262
6363 testCases := []struct {
64- name string
65- msg proto.Message
66- authInfo * txv1beta1. AuthInfo
67- error string
68- numSigners int
64+ name string
65+ msg proto.Message
66+ feePayer string
67+ error string
68+ expectedSigners int
6969 }{
7070 {
71- name : "happy path" ,
72- msg : & bankv1beta1.MsgSend {},
73- authInfo : & txv1beta1.AuthInfo {
74- SignerInfos : signerInfo ,
75- Fee : & txv1beta1.Fee {
76- Amount : []* basev1beta1.Coin {{Amount : "100" , Denom : "denom" }},
77- GasLimit : 100 ,
78- Payer : "" ,
79- Granter : "" ,
80- },
81- },
82- numSigners : 1 ,
71+ name : "happy path" ,
72+ msg : & bankv1beta1.MsgSend {},
73+ expectedSigners : 1 ,
8374 },
8475 {
85- name : "empty signer option" ,
86- msg : & testpb.A {},
87- authInfo : & txv1beta1.AuthInfo {
88- SignerInfos : signerInfo ,
89- Fee : & txv1beta1.Fee {
90- Amount : []* basev1beta1.Coin {{Amount : "100" , Denom : "denom" }},
91- GasLimit : 100 ,
92- Payer : "" ,
93- Granter : "" ,
94- },
95- },
76+ name : "empty signer option" ,
77+ msg : & testpb.A {},
9678 error : "no cosmos.msg.v1.signer option found for message A; use DefineCustomGetSigners to specify a custom getter: tx parse error" ,
9779 },
9880 {
99- name : "invalid feePayer" ,
100- msg : & bankv1beta1.MsgSend {},
101- authInfo : & txv1beta1.AuthInfo {
102- SignerInfos : signerInfo ,
103- Fee : & txv1beta1.Fee {
104- Amount : []* basev1beta1.Coin {{Amount : "100" , Denom : "denom" }},
105- GasLimit : 100 ,
106- Payer : "payer" ,
107- Granter : "" ,
108- },
109- },
110- error : `encoding/hex: invalid byte: U+0070 'p': tx parse error` ,
81+ name : "invalid feePayer" ,
82+ msg : & bankv1beta1.MsgSend {},
83+ feePayer : "payer" ,
84+ error : `encoding/hex: invalid byte: U+0070 'p': tx parse error` ,
11185 },
11286 {
113- name : "valid feePayer" ,
114- msg : & bankv1beta1.MsgSend {},
115- authInfo : & txv1beta1.AuthInfo {
116- SignerInfos : signerInfo ,
117- Fee : & txv1beta1.Fee {
118- Amount : []* basev1beta1.Coin {{Amount : "100" , Denom : "denom" }},
119- GasLimit : 100 ,
120- Payer : "636f736d6f733168363935356b3836397a72306770383975717034337a373263393033666d35647a366b75306c" , // hexadecimal to work with dummyAddressCodec
121- Granter : "" ,
122- },
123- },
124- numSigners : 2 ,
87+ name : "valid feePayer" ,
88+ msg : & bankv1beta1.MsgSend {},
89+ feePayer : "636f736d6f733168363935356b3836397a72306770383975717034337a373263393033666d35647a366b75306c" , // hexadecimal to work with dummyAddressCodec
90+ expectedSigners : 2 ,
12591 },
12692 {
12793 name : "same msg signer and feePayer" ,
12894 msg : & bankv1beta1.MsgSend {
12995 FromAddress : "636f736d6f733168363935356b3836397a72306770383975717034337a373263393033666d35647a366b75306c" ,
13096 },
131- authInfo : & txv1beta1.AuthInfo {
132- SignerInfos : signerInfo ,
133- Fee : & txv1beta1.Fee {
134- Amount : []* basev1beta1.Coin {{Amount : "100" , Denom : "denom" }},
135- GasLimit : 100 ,
136- Payer : "636f736d6f733168363935356b3836397a72306770383975717034337a373263393033666d35647a366b75306c" ,
137- Granter : "" ,
138- },
139- },
140- numSigners : 1 ,
97+ feePayer : "636f736d6f733168363935356b3836397a72306770383975717034337a373263393033666d35647a366b75306c" ,
98+ expectedSigners : 1 ,
14199 },
142100 }
143101
@@ -154,7 +112,15 @@ func TestDecode(t *testing.T) {
154112 Memo : "memo" ,
155113 TimeoutHeight : 0 ,
156114 },
157- AuthInfo : tc .authInfo ,
115+ AuthInfo : & txv1beta1.AuthInfo {
116+ SignerInfos : signerInfo ,
117+ Fee : & txv1beta1.Fee {
118+ Amount : []* basev1beta1.Coin {{Amount : "100" , Denom : "denom" }},
119+ GasLimit : 100 ,
120+ Payer : tc .feePayer ,
121+ Granter : "" ,
122+ },
123+ },
158124 Signatures : nil ,
159125 }
160126 txBytes , err := proto .Marshal (tx )
@@ -166,7 +132,7 @@ func TestDecode(t *testing.T) {
166132 return
167133 }
168134 require .NoError (t , err )
169- require .Equal (t , len (decodeTx .Signers ), tc .numSigners )
135+ require .Equal (t , len (decodeTx .Signers ), tc .expectedSigners )
170136
171137 require .Equal (t ,
172138 fmt .Sprintf ("/%s" , tc .msg .ProtoReflect ().Descriptor ().FullName ()),
0 commit comments