File tree 2 files changed +39
-1
lines changed
2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -210,7 +210,7 @@ mod tests {
210
210
use super :: super :: BankMsg ;
211
211
use super :: * ;
212
212
use crate :: results:: submessages:: { ReplyOn , UNUSED_MSG_ID } ;
213
- use crate :: { coins, from_slice, to_vec} ;
213
+ use crate :: { coins, from_slice, to_vec, ContractResult } ;
214
214
215
215
#[ test]
216
216
fn can_serialize_and_deserialize_init_response ( ) {
@@ -248,4 +248,20 @@ mod tests {
248
248
let deserialized: Response = from_slice ( & serialized) . expect ( "decode contract result" ) ;
249
249
assert_eq ! ( deserialized, original) ;
250
250
}
251
+
252
+ #[ test]
253
+ fn contract_result_is_ok_works ( ) {
254
+ let success = ContractResult :: < ( ) > :: Ok ( ( ) ) ;
255
+ let failure = ContractResult :: < ( ) > :: Err ( "broken" . to_string ( ) ) ;
256
+ assert ! ( success. is_ok( ) ) ;
257
+ assert ! ( !failure. is_ok( ) ) ;
258
+ }
259
+
260
+ #[ test]
261
+ fn contract_result_is_err_works ( ) {
262
+ let success = ContractResult :: < ( ) > :: Ok ( ( ) ) ;
263
+ let failure = ContractResult :: < ( ) > :: Err ( "broken" . to_string ( ) ) ;
264
+ assert ! ( failure. is_err( ) ) ;
265
+ assert ! ( !success. is_err( ) ) ;
266
+ }
251
267
}
Original file line number Diff line number Diff line change @@ -263,6 +263,28 @@ mod tests {
263
263
}
264
264
}
265
265
266
+ #[ test]
267
+ fn sub_msg_result_is_ok_works ( ) {
268
+ let success = SubMsgResult :: Ok ( SubMsgExecutionResponse {
269
+ data : Some ( Binary :: from_base64 ( "MTIzCg==" ) . unwrap ( ) ) ,
270
+ events : vec ! [ Event :: new( "wasm" ) . add_attribute( "fo" , "ba" ) ] ,
271
+ } ) ;
272
+ let failure = SubMsgResult :: Err ( "broken" . to_string ( ) ) ;
273
+ assert ! ( success. is_ok( ) ) ;
274
+ assert ! ( !failure. is_ok( ) ) ;
275
+ }
276
+
277
+ #[ test]
278
+ fn sub_msg_result_is_err_works ( ) {
279
+ let success = SubMsgResult :: Ok ( SubMsgExecutionResponse {
280
+ data : Some ( Binary :: from_base64 ( "MTIzCg==" ) . unwrap ( ) ) ,
281
+ events : vec ! [ Event :: new( "wasm" ) . add_attribute( "fo" , "ba" ) ] ,
282
+ } ) ;
283
+ let failure = SubMsgResult :: Err ( "broken" . to_string ( ) ) ;
284
+ assert ! ( failure. is_err( ) ) ;
285
+ assert ! ( !success. is_err( ) ) ;
286
+ }
287
+
266
288
#[ test]
267
289
fn sub_msg_result_can_convert_from_core_result ( ) {
268
290
let original: Result < SubMsgExecutionResponse , StdError > = Ok ( SubMsgExecutionResponse {
You can’t perform that action at this time.
0 commit comments