Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbfleming committed Apr 17, 2019
1 parent 4b2b757 commit 6c1a7ab
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
28 changes: 22 additions & 6 deletions unittests/api_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,10 @@ BOOST_FIXTURE_TEST_CASE(transaction_tests, TESTER) { try {
{
produce_blocks(10);
transaction_trace_ptr trace;
auto c = control->applied_transaction.connect([&]( const transaction_trace_ptr& t) { if (t && t->receipt && t->receipt->status != transaction_receipt::executed) { trace = t; } } );
auto c = control->applied_transaction.connect([&](std::tuple<const transaction_trace_ptr&, const signed_transaction&> x) {
auto& t = std::get<0>(x);
if (t && t->receipt && t->receipt->status != transaction_receipt::executed) { trace = t; }
} );

// test error handling on deferred transaction failure
CALL_TEST_FUNCTION(*this, "test_transaction", "send_transaction_trigger_error_handler", {});
Expand Down Expand Up @@ -1128,7 +1131,10 @@ BOOST_FIXTURE_TEST_CASE(deferred_transaction_tests, TESTER) { try {
//schedule
{
transaction_trace_ptr trace;
auto c = control->applied_transaction.connect([&]( const transaction_trace_ptr& t) { if (t->scheduled) { trace = t; } } );
auto c = control->applied_transaction.connect([&](std::tuple<const transaction_trace_ptr&, const signed_transaction&> x) {
auto& t = std::get<0>(x);
if (t->scheduled) { trace = t; }
} );
CALL_TEST_FUNCTION(*this, "test_transaction", "send_deferred_transaction", {} );
BOOST_CHECK(!trace);
produce_block( fc::seconds(2) );
Expand All @@ -1148,7 +1154,10 @@ BOOST_FIXTURE_TEST_CASE(deferred_transaction_tests, TESTER) { try {
{
transaction_trace_ptr trace;
uint32_t count = 0;
auto c = control->applied_transaction.connect([&]( const transaction_trace_ptr& t) { if (t && t->scheduled) { trace = t; ++count; } } );
auto c = control->applied_transaction.connect([&](std::tuple<const transaction_trace_ptr&, const signed_transaction&> x) {
auto& t = std::get<0>(x);
if (t && t->scheduled) { trace = t; ++count; }
} );
CALL_TEST_FUNCTION(*this, "test_transaction", "send_deferred_transaction", {});
BOOST_CHECK_THROW(CALL_TEST_FUNCTION(*this, "test_transaction", "send_deferred_transaction", {}), deferred_tx_duplicate);
produce_blocks( 3 );
Expand All @@ -1171,7 +1180,10 @@ BOOST_FIXTURE_TEST_CASE(deferred_transaction_tests, TESTER) { try {
{
transaction_trace_ptr trace;
uint32_t count = 0;
auto c = control->applied_transaction.connect([&]( const transaction_trace_ptr& t) { if (t && t->scheduled) { trace = t; ++count; } } );
auto c = control->applied_transaction.connect([&](std::tuple<const transaction_trace_ptr&, const signed_transaction&> x) {
auto& t = std::get<0>(x);
if (t && t->scheduled) { trace = t; ++count; }
} );
CALL_TEST_FUNCTION(*this, "test_transaction", "send_deferred_transaction_replace", {});
CALL_TEST_FUNCTION(*this, "test_transaction", "send_deferred_transaction_replace", {});
produce_blocks( 3 );
Expand All @@ -1193,7 +1205,10 @@ BOOST_FIXTURE_TEST_CASE(deferred_transaction_tests, TESTER) { try {
//schedule and cancel
{
transaction_trace_ptr trace;
auto c = control->applied_transaction.connect([&]( const transaction_trace_ptr& t) { if (t && t->scheduled) { trace = t; } } );
auto c = control->applied_transaction.connect([&](std::tuple<const transaction_trace_ptr&, const signed_transaction&> x) {
auto& t = std::get<0>(x);
if (t && t->scheduled) { trace = t; }
} );
CALL_TEST_FUNCTION(*this, "test_transaction", "send_deferred_transaction", {});
CALL_TEST_FUNCTION(*this, "test_transaction", "cancel_deferred_transaction_success", {});
produce_block( fc::seconds(2) );
Expand All @@ -1213,7 +1228,8 @@ BOOST_FIXTURE_TEST_CASE(deferred_transaction_tests, TESTER) { try {
//repeated deferred transactions
{
vector<transaction_trace_ptr> traces;
auto c = control->applied_transaction.connect([&]( const transaction_trace_ptr& t) {
auto c = control->applied_transaction.connect([&](std::tuple<const transaction_trace_ptr&, const signed_transaction&> x) {
auto& t = std::get<0>(x);
if (t && t->scheduled) {
traces.push_back( t );
}
Expand Down
3 changes: 2 additions & 1 deletion unittests/protocol_feature_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ BOOST_AUTO_TEST_CASE( no_duplicate_deferred_id_test ) try {
c2.produce_empty_block( fc::minutes(10) );

transaction_trace_ptr trace0;
auto h = c2.control->applied_transaction.connect( [&]( const transaction_trace_ptr& t) {
auto h = c2.control->applied_transaction.connect( [&](std::tuple<const transaction_trace_ptr&, const signed_transaction&> x) {
auto& t = std::get<0>(x);
if( t && t->receipt && t->receipt->status == transaction_receipt::expired) {
trace0 = t;
}
Expand Down
3 changes: 2 additions & 1 deletion unittests/whitelist_blacklist_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ BOOST_AUTO_TEST_CASE( actor_blacklist_inline_deferred ) { try {
tester2.chain->push_block( b );
}

auto log_trxs = [&]( const transaction_trace_ptr& t) {
auto log_trxs = [&](std::tuple<const transaction_trace_ptr&, const signed_transaction&> x) {
auto& t = std::get<0>(x);
if( !t || t->action_traces.size() == 0 ) return;

const auto& act = t->action_traces[0].act;
Expand Down

0 comments on commit 6c1a7ab

Please sign in to comment.