@@ -733,6 +733,7 @@ BOOST_AUTO_TEST_CASE( fee_refund_test )
733
733
issue_uia ( bob_id, asset ( bob_b0, usd_id ) );
734
734
735
735
int64_t order_create_fee = 537 ;
736
+ int64_t order_update_fee = 437 ;
736
737
int64_t order_cancel_fee = 129 ;
737
738
738
739
uint32_t skip = database::skip_witness_signature
@@ -745,13 +746,19 @@ BOOST_AUTO_TEST_CASE( fee_refund_test )
745
746
746
747
generate_block ( skip );
747
748
748
- for ( int i=0 ; i<2 ; i++ )
749
+ for ( int i=0 ; i<5 ; i++ )
749
750
{
750
751
if ( i == 1 )
751
752
{
752
753
generate_blocks ( HARDFORK_445_TIME, true , skip );
753
754
generate_block ( skip );
754
755
}
756
+ else if ( i == 2 )
757
+ {
758
+ generate_blocks ( HARDFORK_CORE_1604_TIME, true , skip );
759
+ generate_block ( skip );
760
+ }
761
+
755
762
756
763
// enable_fees() and change_fees() modifies DB directly, and results will be overwritten by block generation
757
764
// so we have to do it every time we stop generating/popping blocks and start doing tx's
@@ -771,6 +778,11 @@ BOOST_AUTO_TEST_CASE( fee_refund_test )
771
778
create_fee_params.fee = order_create_fee;
772
779
new_fees.insert ( create_fee_params );
773
780
}
781
+ {
782
+ limit_order_update_operation::fee_params_t update_fee_params;
783
+ update_fee_params.fee = order_update_fee;
784
+ new_fees.insert ( update_fee_params );
785
+ }
774
786
{
775
787
limit_order_cancel_operation::fee_params_t cancel_fee_params;
776
788
cancel_fee_params.fee = order_cancel_fee;
@@ -795,6 +807,21 @@ BOOST_AUTO_TEST_CASE( fee_refund_test )
795
807
BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - order_create_fee );
796
808
BOOST_CHECK_EQUAL ( get_balance ( bob_id, usd_id ), bob_b0 - 500 );
797
809
810
+ int64_t update_net_fee = order_cancel_fee * order_update_fee / order_create_fee ;
811
+ int64_t bob_update_fees = 0 ;
812
+ if ( i == 2 )
813
+ {
814
+ // Bob updates order
815
+ update_limit_order ( bo1_id, {}, asset (100 , usd_id) );
816
+
817
+ bob_update_fees += update_net_fee;
818
+
819
+ BOOST_CHECK_EQUAL ( get_balance ( alice_id, core_id ), alice_b0 - 1000 - order_create_fee );
820
+ BOOST_CHECK_EQUAL ( get_balance ( alice_id, usd_id ), alice_b0 );
821
+ BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - bob_update_fees - order_update_fee );
822
+ BOOST_CHECK_EQUAL ( get_balance ( bob_id, usd_id ), bob_b0 - 600 );
823
+ }
824
+
798
825
// Bob cancels order
799
826
cancel_limit_order ( bo1_id (db) );
800
827
@@ -806,35 +833,70 @@ BOOST_AUTO_TEST_CASE( fee_refund_test )
806
833
807
834
BOOST_CHECK_EQUAL ( get_balance ( alice_id, core_id ), alice_b0 - 1000 - order_create_fee );
808
835
BOOST_CHECK_EQUAL ( get_balance ( alice_id, usd_id ), alice_b0 );
809
- BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - cancel_net_fee );
836
+ BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - bob_update_fees - cancel_net_fee );
810
837
BOOST_CHECK_EQUAL ( get_balance ( bob_id, usd_id ), bob_b0 );
811
838
812
839
// Alice cancels order
813
840
cancel_limit_order ( ao1_id (db) );
814
841
815
842
BOOST_CHECK_EQUAL ( get_balance ( alice_id, core_id ), alice_b0 - cancel_net_fee );
816
843
BOOST_CHECK_EQUAL ( get_balance ( alice_id, usd_id ), alice_b0 );
817
- BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - cancel_net_fee );
844
+ BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - bob_update_fees - cancel_net_fee );
818
845
BOOST_CHECK_EQUAL ( get_balance ( bob_id, usd_id ), bob_b0 );
819
846
820
847
// Check partial fill
821
848
const limit_order_object* ao2 = create_sell_order ( alice_id, asset (1000 ), asset (200 , usd_id) );
849
+
850
+ BOOST_REQUIRE ( ao2 != nullptr );
851
+
852
+ int64_t alice_update_fees = order_create_fee;
853
+ int64_t alice_update_amounts = 0 ;
854
+ if ( i == 3 )
855
+ {
856
+ // Alice updates order
857
+ update_limit_order ( *ao2, {}, asset (100 ) );
858
+
859
+ alice_update_fees = update_net_fee + order_update_fee;
860
+ alice_update_amounts = 100 ;
861
+
862
+ BOOST_CHECK_EQUAL ( get_balance ( alice_id, core_id ), alice_b0 - cancel_net_fee - alice_update_fees
863
+ - 1000 - alice_update_amounts );
864
+ BOOST_CHECK_EQUAL ( get_balance ( alice_id, usd_id ), alice_b0 );
865
+ }
866
+
822
867
const limit_order_object* bo2 = create_sell_order ( bob_id, asset (100 , usd_id), asset (500 ) );
823
868
824
- BOOST_CHECK ( ao2 != nullptr );
825
869
BOOST_CHECK ( bo2 == nullptr );
826
870
827
- BOOST_CHECK_EQUAL ( get_balance ( alice_id, core_id ), alice_b0 - cancel_net_fee - order_create_fee - 1000 );
871
+ BOOST_CHECK_EQUAL ( get_balance ( alice_id, core_id ), alice_b0 - cancel_net_fee - alice_update_fees
872
+ - 1000 - alice_update_amounts );
828
873
BOOST_CHECK_EQUAL ( get_balance ( alice_id, usd_id ), alice_b0 + 100 );
829
- BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - cancel_net_fee - order_create_fee + 500 );
874
+ BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - bob_update_fees - cancel_net_fee
875
+ - order_create_fee + 500 );
830
876
BOOST_CHECK_EQUAL ( get_balance ( bob_id, usd_id ), bob_b0 - 100 );
831
877
878
+ if ( i == 4 )
879
+ {
880
+ // Alice updates order
881
+ update_limit_order ( *ao2, {}, asset (100 ) );
882
+
883
+ BOOST_CHECK_EQUAL ( get_balance ( alice_id, core_id ), alice_b0 - cancel_net_fee - alice_update_fees
884
+ - 1000 - alice_update_amounts
885
+ - order_update_fee - 100 );
886
+ BOOST_CHECK_EQUAL ( get_balance ( alice_id, usd_id ), alice_b0 + 100 );
887
+ BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - bob_update_fees - cancel_net_fee
888
+ - order_create_fee + 500 );
889
+ BOOST_CHECK_EQUAL ( get_balance ( bob_id, usd_id ), bob_b0 - 100 );
890
+ }
891
+
832
892
// cancel Alice order, show that entire deferred_fee was consumed by partial match
833
893
cancel_limit_order ( *ao2 );
834
894
835
- BOOST_CHECK_EQUAL ( get_balance ( alice_id, core_id ), alice_b0 - cancel_net_fee - order_create_fee - 500 - order_cancel_fee );
895
+ BOOST_CHECK_EQUAL ( get_balance ( alice_id, core_id ), alice_b0 - cancel_net_fee - alice_update_fees - 500
896
+ - order_cancel_fee );
836
897
BOOST_CHECK_EQUAL ( get_balance ( alice_id, usd_id ), alice_b0 + 100 );
837
- BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - cancel_net_fee - order_create_fee + 500 );
898
+ BOOST_CHECK_EQUAL ( get_balance ( bob_id, core_id ), bob_b0 - bob_update_fees - cancel_net_fee
899
+ - order_create_fee + 500 );
838
900
BOOST_CHECK_EQUAL ( get_balance ( bob_id, usd_id ), bob_b0 - 100 );
839
901
840
902
// TODO: Check multiple fill
0 commit comments