Skip to content

Commit

Permalink
GH-1354 Add test case for deferred trx id before/after protocol featu…
Browse files Browse the repository at this point in the history
…re replace_deferred
  • Loading branch information
heifner committed Jul 7, 2023
1 parent c456d17 commit 97aa4b8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions unittests/protocol_feature_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,14 @@ BOOST_AUTO_TEST_CASE( replace_deferred_test ) try {
cfg.disable_all_subjective_mitigations = true;
c.init( cfg );

transaction_trace_ptr trace;
auto h = c.control->applied_transaction.connect( [&](std::tuple<const transaction_trace_ptr&, const packed_transaction_ptr&> x) {
auto& t = std::get<0>(x);
if( t && !eosio::chain::is_onblock(*t)) {
trace = t;
}
} );

BOOST_CHECK_EQUAL( c.control->get_resource_limits_manager().get_account_ram_usage( "alice"_n ), alice_ram_usage0 );

c.push_action( "test"_n, "defercall"_n, "alice"_n, fc::mutable_variant_object()
Expand Down Expand Up @@ -448,6 +456,8 @@ BOOST_AUTO_TEST_CASE( replace_deferred_test ) try {

dtrxs = c.get_scheduled_transactions();
BOOST_CHECK_EQUAL( dtrxs.size(), 0 );
// must be equal before builtin_protocol_feature_t::replace_deferred to support replay of blocks before activation
BOOST_CHECK( first_dtrx_id.str() == trace->id.str() );

c.produce_block();

Expand Down Expand Up @@ -507,6 +517,13 @@ BOOST_AUTO_TEST_CASE( replace_deferred_test ) try {
BOOST_CHECK_EQUAL( dtrxs.size(), 1 );
BOOST_CHECK_EQUAL( first_dtrx_id2, dtrxs[0] );

c.produce_block();

dtrxs = c.get_scheduled_transactions();
BOOST_CHECK_EQUAL( dtrxs.size(), 0 );
// Not equal after builtin_protocol_feature_t::replace_deferred activated
BOOST_CHECK( first_dtrx_id2.str() != trace->id.str() );

} FC_LOG_AND_RETHROW()

BOOST_AUTO_TEST_CASE( no_duplicate_deferred_id_test ) try {
Expand Down

0 comments on commit 97aa4b8

Please sign in to comment.