@@ -19,11 +19,11 @@ mod test {
19
19
20
20
use crate :: error:: ContractError ;
21
21
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 ,
24
24
} ;
25
25
use cw20:: { Cw20Coin , Cw20ExecuteMsg } ;
26
- use cw20_ics20_msg:: amount:: Amount ;
26
+ use cw20_ics20_msg:: amount:: { convert_local_to_remote , Amount } ;
27
27
28
28
use crate :: contract:: { execute, migrate, query_channel} ;
29
29
use crate :: msg:: { ExecuteMsg , MigrateMsg , TransferMsg , UpdatePairMsg } ;
@@ -638,6 +638,10 @@ mod test {
638
638
denom : "orai" . to_string ( ) ,
639
639
} ;
640
640
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 ( ) ;
641
645
let remote_address = "eth-mainnet0x1235" ;
642
646
let mut env = mock_env ( ) ;
643
647
env. contract . address = Addr :: unchecked ( "addr" ) ;
@@ -714,8 +718,8 @@ mod test {
714
718
local_channel_id : "mars-channel" . to_string ( ) ,
715
719
denom : "trx-mainnet" . to_string ( ) ,
716
720
asset_info : receiver_asset_info. clone ( ) ,
717
- remote_decimals : 18 ,
718
- asset_info_decimals : 18 ,
721
+ remote_decimals,
722
+ asset_info_decimals,
719
723
} ;
720
724
721
725
// works with proper funds
@@ -731,7 +735,7 @@ mod test {
731
735
deps. as_mut ( ) . storage ,
732
736
receive_channel,
733
737
pair_mapping_key. as_str ( ) ,
734
- amount . clone ( ) ,
738
+ remote_amount . clone ( ) ,
735
739
false ,
736
740
)
737
741
. unwrap ( ) ;
@@ -755,7 +759,7 @@ mod test {
755
759
CosmosMsg :: Ibc ( IbcMsg :: SendPacket {
756
760
channel_id: receive_channel. to_string( ) ,
757
761
data: to_binary( & Ics20Packet :: new(
758
- amount . clone( ) ,
762
+ remote_amount . clone( ) ,
759
763
pair_mapping_key. clone( ) ,
760
764
env. contract. address. as_str( ) ,
761
765
& remote_address,
@@ -766,9 +770,11 @@ mod test {
766
770
} )
767
771
) ;
768
772
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) ;
770
776
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) ;
772
778
assert_eq ! ( reply_args. receiver, local_receiver. to_string( ) ) ;
773
779
assert_eq ! ( reply_args. refund_asset_info, receiver_asset_info)
774
780
}
@@ -866,8 +872,8 @@ mod test {
866
872
let mut single_step_reply_args = SingleStepReplyArgs {
867
873
channel : local_channel_id. to_string ( ) ,
868
874
refund_asset_info : refund_asset_info. clone ( ) ,
869
- ibc_denom : None ,
870
- amount : amount. clone ( ) ,
875
+ ibc_data : None ,
876
+ local_amount : amount,
871
877
receiver : receiver. to_string ( ) ,
872
878
} ;
873
879
let result = handle_follow_up_failure (
@@ -894,12 +900,16 @@ mod test {
894
900
"attempt_refund_denom" ,
895
901
single_step_reply_args. refund_asset_info. to_string( ) ,
896
902
) ,
897
- attr( "attempt_refund_amount" , single_step_reply_args. amount ) ,
903
+ attr( "attempt_refund_amount" , single_step_reply_args. local_amount ) ,
898
904
] )
899
905
) ;
900
906
901
907
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
+ } ) ;
903
913
// if has ibc denom then it's evm based, need to undo reducing balance
904
914
CHANNEL_REVERSE_STATE
905
915
. save (
@@ -921,6 +931,6 @@ mod test {
921
931
. load ( deps. as_mut ( ) . storage , ( local_channel_id, ibc_denom) )
922
932
. unwrap ( ) ;
923
933
// should undo reduce channel state
924
- assert_eq ! ( channel_state. outstanding, amount )
934
+ assert_eq ! ( channel_state. outstanding, remote_amount )
925
935
}
926
936
}
0 commit comments