@@ -390,8 +390,8 @@ mod test {
390
390
use super :: * ;
391
391
use crate :: test_helpers:: * ;
392
392
393
- use crate :: contract:: { execute, query_channel} ;
394
- use crate :: msg:: { ExecuteMsg , TransferMsg } ;
393
+ use crate :: contract:: { execute, migrate , query_channel} ;
394
+ use crate :: msg:: { ExecuteMsg , MigrateMsg , TransferMsg } ;
395
395
use cosmwasm_std:: testing:: { mock_env, mock_info} ;
396
396
use cosmwasm_std:: { coins, to_vec, IbcEndpoint , IbcMsg , IbcTimeout , Timestamp } ;
397
397
use cw20:: Cw20ReceiveMsg ;
@@ -625,4 +625,39 @@ mod test {
625
625
assert_eq ! ( state. balances, vec![ Amount :: native( 111111111 , denom) ] ) ;
626
626
assert_eq ! ( state. total_sent, vec![ Amount :: native( 987654321 , denom) ] ) ;
627
627
}
628
+
629
+ #[ test]
630
+ fn check_gas_limit_handles_all_cases ( ) {
631
+ let send_channel = "channel-9" ;
632
+ let allowed = "foobar" ;
633
+ let allowed_gas = 777666 ;
634
+ let mut deps = setup ( & [ send_channel] , & [ ( allowed, allowed_gas) ] ) ;
635
+
636
+ // allow list will get proper gas
637
+ let limit = check_gas_limit ( deps. as_ref ( ) , & Amount :: cw20 ( 500 , allowed) ) . unwrap ( ) ;
638
+ assert_eq ! ( limit, Some ( allowed_gas) ) ;
639
+
640
+ // non-allow list will error
641
+ let random = "tokenz" ;
642
+ check_gas_limit ( deps. as_ref ( ) , & Amount :: cw20 ( 500 , random) ) . unwrap_err ( ) ;
643
+
644
+ // add default_gas_limit
645
+ let def_limit = 54321 ;
646
+ migrate (
647
+ deps. as_mut ( ) ,
648
+ mock_env ( ) ,
649
+ MigrateMsg {
650
+ default_gas_limit : Some ( def_limit) ,
651
+ } ,
652
+ )
653
+ . unwrap ( ) ;
654
+
655
+ // allow list still gets proper gas
656
+ let limit = check_gas_limit ( deps. as_ref ( ) , & Amount :: cw20 ( 500 , allowed) ) . unwrap ( ) ;
657
+ assert_eq ! ( limit, Some ( allowed_gas) ) ;
658
+
659
+ // non-allow list will now get default
660
+ let limit = check_gas_limit ( deps. as_ref ( ) , & Amount :: cw20 ( 500 , random) ) . unwrap ( ) ;
661
+ assert_eq ! ( limit, Some ( def_limit) ) ;
662
+ }
628
663
}
0 commit comments