Skip to content

Commit 5486006

Browse files
Progress bitshares#1604: Do not allow sooner expiration
Updating an order's expiration must make it expire later than before, not the same or sooner.
1 parent 5287b24 commit 5486006

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

libraries/chain/market_evaluator.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ void_result limit_order_update_evaluator::do_evaluate(const limit_order_update_o
177177

178178
// Check expiration is in the future
179179
if (o.new_expiration)
180-
FC_ASSERT(*o.new_expiration >= d.head_block_time(),
181-
"Cannot update limit order with past expiration");
180+
FC_ASSERT(*o.new_expiration > _order->expiration,
181+
"Cannot update limit order to expire sooner; new expiration must be later than old one.");
182182

183183
return {};
184184
} FC_CAPTURE_AND_RETHROW((o)) }

tests/tests/operation_tests.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ BOOST_AUTO_TEST_CASE(limit_order_update_test)
148148
expiration += 50;
149149
update_limit_order(order_id, {}, {}, expiration);
150150
BOOST_REQUIRE_EQUAL(order_id(db).expiration.sec_since_epoch(), expiration.sec_since_epoch());
151-
expiration -= 100;
152-
update_limit_order(order_id, {}, {}, expiration);
153-
BOOST_REQUIRE_EQUAL(order_id(db).expiration.sec_since_epoch(), expiration.sec_since_epoch());
151+
// Cannot make expiration same as before
152+
GRAPHENE_REQUIRE_THROW(update_limit_order(order_id, {}, {}, expiration), fc::assert_exception);
153+
// Cannot make expiration sooner; only later
154+
GRAPHENE_REQUIRE_THROW(update_limit_order(order_id, {}, {}, expiration - 100), fc::assert_exception);
155+
GRAPHENE_REQUIRE_THROW(update_limit_order(order_id, {}, {}, expiration - 1), fc::assert_exception);
154156

155157
// Try adding funds
156158
update_limit_order(order_id, {}, asset(50));

0 commit comments

Comments
 (0)