@@ -399,6 +399,106 @@ mod cancel_bid_tests {
399399 . is_err( ) ) ;
400400 }
401401
402+ #[ test]
403+ fn cancel_bid_with_fees_eq_zero_valid ( ) {
404+ let mut deps = mock_dependencies ( & [ ] ) ;
405+ setup_test_base (
406+ & mut deps. storage ,
407+ & ContractInfoV3 {
408+ name : "contract_name" . into ( ) ,
409+ bind_name : "contract_bind_name" . into ( ) ,
410+ base_denom : "base_denom" . into ( ) ,
411+ convertible_base_denoms : vec ! [ "con_base_1" . into( ) , "con_base_2" . into( ) ] ,
412+ supported_quote_denoms : vec ! [ "quote_1" . into( ) , "quote_2" . into( ) ] ,
413+ approvers : vec ! [ Addr :: unchecked( "exec_1" ) , Addr :: unchecked( "exec_2" ) ] ,
414+ executors : vec ! [ Addr :: unchecked( "exec_1" ) , Addr :: unchecked( "exec_2" ) ] ,
415+ ask_fee_info : None ,
416+ bid_fee_info : Some ( FeeInfo {
417+ account : Addr :: unchecked ( "bid_fee_account" ) ,
418+ rate : "0.1" . to_string ( ) ,
419+ } ) ,
420+ ask_required_attributes : vec ! [ "ask_tag_1" . into( ) , "ask_tag_2" . into( ) ] ,
421+ bid_required_attributes : vec ! [ "bid_tag_1" . into( ) , "bid_tag_2" . into( ) ] ,
422+ price_precision : Uint128 :: new ( 0 ) ,
423+ size_increment : Uint128 :: new ( 1 ) ,
424+ } ,
425+ ) ;
426+
427+ // create bid data
428+ store_test_bid (
429+ & mut deps. storage ,
430+ & BidOrderV2 {
431+ base : Coin {
432+ amount : Uint128 :: new ( 100 ) ,
433+ denom : "base_1" . into ( ) ,
434+ } ,
435+ events : vec ! [ ] ,
436+ fee : Some ( Coin {
437+ denom : "quote_1" . to_string ( ) ,
438+ amount : Uint128 :: new ( 0 ) ,
439+ } ) ,
440+ id : "c13f8888-ca43-4a64-ab1b-1ca8d60aa49b" . into ( ) ,
441+ owner : Addr :: unchecked ( "bidder" ) ,
442+ price : "2" . into ( ) ,
443+ quote : Coin {
444+ amount : Uint128 :: new ( 200 ) ,
445+ denom : "quote_1" . into ( ) ,
446+ } ,
447+ } ,
448+ ) ;
449+
450+ // cancel bid order
451+ let bidder_info = mock_info ( "bidder" , & [ ] ) ;
452+
453+ let cancel_bid_msg = ExecuteMsg :: CancelBid {
454+ id : "c13f8888-ca43-4a64-ab1b-1ca8d60aa49b" . to_string ( ) ,
455+ } ;
456+
457+ let cancel_bid_response = execute (
458+ deps. as_mut ( ) ,
459+ mock_env ( ) ,
460+ bidder_info. clone ( ) ,
461+ cancel_bid_msg,
462+ ) ;
463+
464+ match cancel_bid_response {
465+ Ok ( cancel_bid_response) => {
466+ assert_eq ! ( cancel_bid_response. attributes. len( ) , 4 ) ;
467+ assert_eq ! (
468+ cancel_bid_response. attributes[ 0 ] ,
469+ attr( "action" , "cancel_bid" )
470+ ) ;
471+ assert_eq ! (
472+ cancel_bid_response. attributes[ 1 ] ,
473+ attr( "id" , "c13f8888-ca43-4a64-ab1b-1ca8d60aa49b" )
474+ ) ;
475+ assert_eq ! (
476+ cancel_bid_response. attributes[ 2 ] ,
477+ attr( "reverse_size" , "100" )
478+ ) ;
479+ assert_eq ! (
480+ cancel_bid_response. attributes[ 3 ] ,
481+ attr( "order_open" , "false" )
482+ ) ;
483+ assert_eq ! ( cancel_bid_response. messages. len( ) , 1 ) ;
484+ assert_eq ! (
485+ cancel_bid_response. messages[ 0 ] . msg,
486+ CosmosMsg :: Bank ( BankMsg :: Send {
487+ to_address: bidder_info. sender. to_string( ) ,
488+ amount: coins( 200 , "quote_1" ) ,
489+ } )
490+ ) ;
491+ }
492+ Err ( error) => panic ! ( "unexpected error: {:?}" , error) ,
493+ }
494+
495+ // verify bid order removed from storage
496+ let bid_storage = get_bid_storage_read ( & deps. storage ) ;
497+ assert ! ( bid_storage
498+ . load( "c13f8888-ca43-4a64-ab1b-1ca8d60aa49b" . as_bytes( ) )
499+ . is_err( ) ) ;
500+ }
501+
402502 #[ test]
403503 fn cancel_bid_restricted_marker_with_fees ( ) {
404504 let mut deps = mock_dependencies ( & [ ] ) ;
0 commit comments