Skip to content

Commit

Permalink
allow setting a schedule in the past or msigs will break
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan James committed May 10, 2024
1 parent ff27f8c commit 4239d20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion contracts/eosio.system/src/eosio.system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ namespace eosiosystem {

check(continuous_rate >= 0, "continuous_rate can't be negative");
check(continuous_rate <= 1, "continuous_rate can't be over 100%");
check(start_time.sec_since_epoch() >= current_time_point().sec_since_epoch(), "start_time cannot be in the past");

auto itr = _schedules.find( start_time.sec_since_epoch() );

Expand Down
7 changes: 3 additions & 4 deletions tests/eosio.system_schedules_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,23 @@ BOOST_FIXTURE_TEST_CASE(set_schedules, eosio_system_tester) try {
time_point_sec start_time = time_point_sec(initial_start_time);


BOOST_REQUIRE_EQUAL( wasm_assert_msg("continuous_rate can't be over 100%"), setschedule(time_point_sec(0), 1.00001) );
BOOST_REQUIRE_EQUAL( wasm_assert_msg("continuous_rate can't be over 100%"), setschedule(start_time, 1.00001) );
BOOST_REQUIRE_EQUAL( wasm_assert_msg("continuous_rate can't be negative"), setschedule(start_time, -1) );
BOOST_REQUIRE_EQUAL( wasm_assert_msg("schedule not found"), delschedule(start_time) );

// action validation
BOOST_REQUIRE_EQUAL( success(), setschedule(time_point_sec(0), 0.05) );
BOOST_REQUIRE_EQUAL( success(), setschedule(start_time, 0.05) );
check_schedule(start_time, 0.05);

// allow override existing schedules
BOOST_REQUIRE_EQUAL( success(), setschedule(start_time, 0.02) );
check_schedule(start_time, 0.02);

// You should no longer be able to modify something that has passed the
// execution date, or add new schedules in the past
BOOST_REQUIRE_EQUAL( wasm_assert_msg("start_time cannot be in the past"), setschedule(start_time, 0.05) );

// Should be able to delete schedules, even in the past
BOOST_REQUIRE_EQUAL( success(), delschedule(start_time) );
BOOST_REQUIRE_EQUAL( success(), delschedule(time_point_sec(0)) );
BOOST_REQUIRE_EQUAL( wasm_assert_msg("schedule not found"), delschedule(start_time) );

// Resetting timers to make math clean
Expand Down

0 comments on commit 4239d20

Please sign in to comment.