@@ -19,11 +19,11 @@ mod test {
1919
2020 use crate :: error:: ContractError ;
2121 use crate :: state:: {
22- get_key_ics20_ibc_denom, increase_channel_balance, ChannelState , SingleStepReplyArgs ,
23- CHANNEL_REVERSE_STATE , SINGLE_STEP_REPLY_ARGS ,
22+ get_key_ics20_ibc_denom, increase_channel_balance, ChannelState , IbcSingleStepData ,
23+ SingleStepReplyArgs , CHANNEL_REVERSE_STATE , SINGLE_STEP_REPLY_ARGS ,
2424 } ;
2525 use cw20:: { Cw20Coin , Cw20ExecuteMsg } ;
26- use cw20_ics20_msg:: amount:: Amount ;
26+ use cw20_ics20_msg:: amount:: { convert_local_to_remote , Amount } ;
2727
2828 use crate :: contract:: { execute, migrate, query_channel} ;
2929 use crate :: msg:: { ExecuteMsg , MigrateMsg , TransferMsg , UpdatePairMsg } ;
@@ -638,6 +638,10 @@ mod test {
638638 denom : "orai" . to_string ( ) ,
639639 } ;
640640 let amount = Uint128 :: from ( 10u128 ) ;
641+ let remote_decimals = 18 ;
642+ let asset_info_decimals = 6 ;
643+ let remote_amount =
644+ convert_local_to_remote ( amount, remote_decimals, asset_info_decimals) . unwrap ( ) ;
641645 let remote_address = "eth-mainnet0x1235" ;
642646 let mut env = mock_env ( ) ;
643647 env. contract . address = Addr :: unchecked ( "addr" ) ;
@@ -714,8 +718,8 @@ mod test {
714718 local_channel_id : "mars-channel" . to_string ( ) ,
715719 denom : "trx-mainnet" . to_string ( ) ,
716720 asset_info : receiver_asset_info. clone ( ) ,
717- remote_decimals : 18 ,
718- asset_info_decimals : 18 ,
721+ remote_decimals,
722+ asset_info_decimals,
719723 } ;
720724
721725 // works with proper funds
@@ -731,7 +735,7 @@ mod test {
731735 deps. as_mut ( ) . storage ,
732736 receive_channel,
733737 pair_mapping_key. as_str ( ) ,
734- amount . clone ( ) ,
738+ remote_amount . clone ( ) ,
735739 false ,
736740 )
737741 . unwrap ( ) ;
@@ -755,7 +759,7 @@ mod test {
755759 CosmosMsg :: Ibc ( IbcMsg :: SendPacket {
756760 channel_id: receive_channel. to_string( ) ,
757761 data: to_binary( & Ics20Packet :: new(
758- amount . clone( ) ,
762+ remote_amount . clone( ) ,
759763 pair_mapping_key. clone( ) ,
760764 env. contract. address. as_str( ) ,
761765 & remote_address,
@@ -766,9 +770,11 @@ mod test {
766770 } )
767771 ) ;
768772 let reply_args = SINGLE_STEP_REPLY_ARGS . load ( deps. as_mut ( ) . storage ) . unwrap ( ) ;
769- assert_eq ! ( reply_args. amount, amount) ;
773+ let ibc_data = reply_args. ibc_data . unwrap ( ) ;
774+ assert_eq ! ( ibc_data. remote_amount, remote_amount) ;
775+ assert_eq ! ( reply_args. local_amount, amount) ;
770776 assert_eq ! ( reply_args. channel, receive_channel) ;
771- assert_eq ! ( reply_args . ibc_denom, Some ( pair_mapping_key) ) ;
777+ assert_eq ! ( ibc_data . ibc_denom, pair_mapping_key) ;
772778 assert_eq ! ( reply_args. receiver, local_receiver. to_string( ) ) ;
773779 assert_eq ! ( reply_args. refund_asset_info, receiver_asset_info)
774780 }
@@ -866,8 +872,8 @@ mod test {
866872 let mut single_step_reply_args = SingleStepReplyArgs {
867873 channel : local_channel_id. to_string ( ) ,
868874 refund_asset_info : refund_asset_info. clone ( ) ,
869- ibc_denom : None ,
870- amount : amount. clone ( ) ,
875+ ibc_data : None ,
876+ local_amount : amount,
871877 receiver : receiver. to_string ( ) ,
872878 } ;
873879 let result = handle_follow_up_failure (
@@ -894,12 +900,16 @@ mod test {
894900 "attempt_refund_denom" ,
895901 single_step_reply_args. refund_asset_info. to_string( ) ,
896902 ) ,
897- attr( "attempt_refund_amount" , single_step_reply_args. amount ) ,
903+ attr( "attempt_refund_amount" , single_step_reply_args. local_amount ) ,
898904 ] )
899905 ) ;
900906
901907 let ibc_denom = "ibc_denom" ;
902- single_step_reply_args. ibc_denom = Some ( ibc_denom. to_string ( ) ) ;
908+ let remote_amount = convert_local_to_remote ( amount, 18 , 6 ) . unwrap ( ) ;
909+ single_step_reply_args. ibc_data = Some ( IbcSingleStepData {
910+ ibc_denom : ibc_denom. to_string ( ) ,
911+ remote_amount : remote_amount. clone ( ) ,
912+ } ) ;
903913 // if has ibc denom then it's evm based, need to undo reducing balance
904914 CHANNEL_REVERSE_STATE
905915 . save (
@@ -921,6 +931,6 @@ mod test {
921931 . load ( deps. as_mut ( ) . storage , ( local_channel_id, ibc_denom) )
922932 . unwrap ( ) ;
923933 // should undo reduce channel state
924- assert_eq ! ( channel_state. outstanding, amount )
934+ assert_eq ! ( channel_state. outstanding, remote_amount )
925935 }
926936}
0 commit comments