@@ -147,12 +147,13 @@ func TestBeforeSendHook(t *testing.T) {
147
147
// to properly test if we are gas metering trackBeforeSend properly.
148
148
func TestInfiniteTrackBeforeSend (t * testing.T ) {
149
149
for _ , tc := range []struct {
150
- name string
151
- wasmFile string
152
- tokenToSend sdk.Coins
153
- useFactoryDenom bool
154
- blockBeforeSend bool
155
- expectedError bool
150
+ name string
151
+ wasmFile string
152
+ tokenToSend sdk.Coins
153
+ useFactoryDenom bool
154
+ blockBeforeSend bool
155
+ expectedError bool
156
+ useInvalidContract bool
156
157
}{
157
158
{
158
159
name : "sending tokenfactory denom from module to module with infinite contract should panic" ,
@@ -176,6 +177,13 @@ func TestInfiniteTrackBeforeSend(t *testing.T) {
176
177
wasmFile : "./testdata/no100.wasm" ,
177
178
useFactoryDenom : true ,
178
179
},
180
+ {
181
+ name : "Try using invalid contract" ,
182
+ wasmFile : "./testdata/no100.wasm" ,
183
+ useFactoryDenom : true ,
184
+ useInvalidContract : true ,
185
+ expectedError : true ,
186
+ },
179
187
} {
180
188
t .Run (fmt .Sprintf ("Case %s" , tc .name ), func (t * testing.T ) {
181
189
ctx , input := createDefaultTestInput (t )
@@ -211,9 +219,18 @@ func TestInfiniteTrackBeforeSend(t *testing.T) {
211
219
input .Faucet .Fund (ctx , input .AccountKeeper .GetModuleAccount (ctx , authtypes .Minter ).GetAddress (), tokenToSend ... )
212
220
}
213
221
222
+ if tc .useInvalidContract {
223
+ cosmwasmAddress = make (sdk.AccAddress , 32 )
224
+ }
225
+
214
226
// set beforesend hook to the new denom
215
227
// we register infinite loop contract here to test if we are gas metering properly
216
228
_ , err = msgServer .SetBeforeSendHook (ctx , types .NewMsgSetBeforeSendHook (addrs [0 ].String (), factoryDenom , cosmwasmAddress .String ()))
229
+ if tc .useInvalidContract {
230
+ require .Error (t , err , "test: %v" , tc .name )
231
+ return
232
+ }
233
+
217
234
require .NoError (t , err , "test: %v" , tc .name )
218
235
219
236
if tc .blockBeforeSend {
0 commit comments