From 616a7cf4d745e057ff4b0161c443874ee0d7797a Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Wed, 17 Jun 2015 20:04:47 -0400 Subject: [PATCH] tests: Use new macros Generated by applying these commands to parent commit: sed -i -e 's/\([a-z0-9]\+\).push_transaction[(]\([^()]*\)[)]/PUSH_TX( \1, \2 )/' tests/tests/*.cpp sed -i -e 's/\([a-z0-9]\+\).push_block[(]\([^()]*\)[)]/PUSH_BLOCK( \1, \2 )/' tests/tests/*.cpp --- tests/tests/authority_tests.cpp | 140 +++++++++++++++---------------- tests/tests/block_tests.cpp | 66 +++++++-------- tests/tests/fee_tests.cpp | 2 +- tests/tests/operation_tests.cpp | 94 ++++++++++----------- tests/tests/operation_tests2.cpp | 66 +++++++-------- tests/tests/uia_tests.cpp | 34 ++++---- 6 files changed, 201 insertions(+), 201 deletions(-) diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index f6bee06f..cad13bb7 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE( simple_single_signature ) transfer_operation op = {asset(),nathan.id, account_id_type(), core.amount(500)}; trx.operations.push_back(op); sign(trx, key.id, nathan_key); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); BOOST_CHECK_EQUAL(get_balance(nathan, core), old_balance - 500); } catch (fc::exception& e) { @@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE( any_two_of_three ) op.owner = *op.active; trx.operations.push_back(op); sign(trx, key1.id,nathan_key1); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); trx.operations.clear(); trx.signatures.clear(); } FC_CAPTURE_AND_RETHROW ((nathan.active)(key1)) @@ -88,27 +88,27 @@ BOOST_AUTO_TEST_CASE( any_two_of_three ) transfer_operation op = {asset(), nathan.id, account_id_type(), core.amount(500)}; trx.operations.push_back(op); sign(trx, key1.id,nathan_key1); - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); sign(trx, key2.id,nathan_key2); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); BOOST_CHECK_EQUAL(get_balance(nathan, core), old_balance - 500); trx.signatures.clear(); sign(trx, key2.id,nathan_key2); sign(trx, key3.id,nathan_key3); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); BOOST_CHECK_EQUAL(get_balance(nathan, core), old_balance - 1000); trx.signatures.clear(); sign(trx, key1.id,nathan_key1); sign(trx, key3.id,nathan_key3); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); BOOST_CHECK_EQUAL(get_balance(nathan, core), old_balance - 1500); trx.signatures.clear(); //sign(trx, fc::ecc::private_key::generate()); sign(trx, key3.id,nathan_key3); - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); BOOST_CHECK_EQUAL(get_balance(nathan, core), old_balance - 1500); } catch (fc::exception& e) { edump((e.to_detail_string())); @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE( recursive_accounts ) make_child_op.owner = authority(2, account_id_type(parent1.id), 1, account_id_type(parent2.id), 1); make_child_op.active = authority(2, account_id_type(parent1.id), 1, account_id_type(parent2.id), 1); trx.operations.push_back(make_child_op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.operations.clear(); } @@ -142,17 +142,17 @@ BOOST_AUTO_TEST_CASE( recursive_accounts ) transfer_operation op = {asset(), child.id, account_id_type(), core.amount(500)}; trx.operations.push_back(op); - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); sign(trx, key1.id,parent1_key); sign(trx, key1.id,parent1_key); sign(trx, key1.id,parent1_key); sign(trx, key1.id,parent1_key); - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); trx.signatures.clear(); sign(trx, key2.id,parent2_key); - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); sign(trx, key1.id,parent1_key); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); BOOST_CHECK_EQUAL(get_balance(child, core), old_balance - 500); trx.operations.clear(); trx.signatures.clear(); @@ -167,7 +167,7 @@ BOOST_AUTO_TEST_CASE( recursive_accounts ) trx.operations.push_back(op); sign(trx, key1.id,parent1_key); sign(trx, key2.id,parent2_key); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); BOOST_REQUIRE_EQUAL(child.active.auths.size(), 3); trx.operations.clear(); trx.signatures.clear(); @@ -175,18 +175,18 @@ BOOST_AUTO_TEST_CASE( recursive_accounts ) op = {asset(),child.id, account_id_type(), core.amount(500)}; trx.operations.push_back(op); - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); sign(trx, key1.id,parent1_key); - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); trx.signatures.clear(); sign(trx, key2.id,parent2_key); - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); sign(trx, key1.id, parent1_key); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); BOOST_CHECK_EQUAL(get_balance(child, core), old_balance - 1000); trx.signatures.clear(); sign(trx, child_key_obj.id, child_key); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); BOOST_CHECK_EQUAL(get_balance(child, core), old_balance - 1500); trx.operations.clear(); trx.signatures.clear(); @@ -204,7 +204,7 @@ BOOST_AUTO_TEST_CASE( recursive_accounts ) op.active = authority(1, grandparent_key_obj.get_id(), 1); op.owner = *op.active; trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.operations.clear(); trx.signatures.clear(); } @@ -212,9 +212,9 @@ BOOST_AUTO_TEST_CASE( recursive_accounts ) trx.operations.push_back(op); sign(trx, key1.id, parent1_key); sign(trx, key2.id, parent2_key); - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); sign(trx, grandparent_key_obj.id, grandparent_key); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); BOOST_CHECK_EQUAL(get_balance(child, core), old_balance - 2000); trx.operations.clear(); trx.signatures.clear(); @@ -225,7 +225,7 @@ BOOST_AUTO_TEST_CASE( recursive_accounts ) op.active = authority(1, account_id_type(), 1); op.owner = *op.active; trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.operations.clear(); trx.signatures.clear(); } @@ -235,9 +235,9 @@ BOOST_AUTO_TEST_CASE( recursive_accounts ) sign(trx, grandparent_key_obj.id,grandparent_key); sign(trx, key_id_type(), generate_private_key("genesis")); //Fails due to recursion depth. - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); sign(trx, child_key_obj.id, child_key); - db.push_transaction(trx, database::skip_transaction_dupe_check); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); BOOST_CHECK_EQUAL(get_balance(child, core), old_balance - 2500); trx.operations.clear(); trx.signatures.clear(); @@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE( recursive_accounts ) op.active = authority(1, account_id_type(child.id), 1); op.owner = *op.active; trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.operations.clear(); trx.signatures.clear(); } @@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE( recursive_accounts ) trx.operations.push_back(op); sign(trx, key2.id, parent2_key); //Fails due to recursion depth. - BOOST_CHECK_THROW(db.push_transaction(trx, database::skip_transaction_dupe_check), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); } catch (fc::exception& e) { edump((e.to_detail_string())); throw; @@ -301,7 +301,7 @@ BOOST_AUTO_TEST_CASE( proposed_single_account ) trx.operations.push_back(op); trx.set_expiration(db.head_block_id()); sign(trx, this->genesis_key, genesis_key); - const proposal_object& proposal = db.get(db.push_transaction(trx).operation_results.front().get()); + const proposal_object& proposal = db.get(PUSH_TX( db, trx ).operation_results.front().get()); BOOST_CHECK_EQUAL(proposal.required_active_approvals.size(), 1); BOOST_CHECK_EQUAL(proposal.available_active_approvals.size(), 0); @@ -312,11 +312,11 @@ BOOST_AUTO_TEST_CASE( proposed_single_account ) trx.operations = {proposal_update_operation{account_id_type(), asset(), proposal.id,{nathan.id},flat_set{},flat_set{},flat_set{},flat_set{},flat_set{}}}; trx.sign( this->genesis_key, genesis_key ); //Genesis may not add nathan's approval. - BOOST_CHECK_THROW(db.push_transaction(trx), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); trx.operations = {proposal_update_operation{account_id_type(), asset(), proposal.id,{account_id_type()},flat_set{},flat_set{},flat_set{},flat_set{},flat_set{}}}; trx.sign( key_id_type(), genesis_key ); //Genesis has no stake in the transaction. - BOOST_CHECK_THROW(db.push_transaction(trx), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); trx.signatures.clear(); trx.operations = {proposal_update_operation{nathan.id, asset(), proposal.id,{nathan.id},flat_set{},flat_set{},flat_set{},flat_set{},flat_set{}}}; @@ -326,7 +326,7 @@ BOOST_AUTO_TEST_CASE( proposed_single_account ) //trx.signatures = {nathan_key3.sign_compact(trx.digest()), nathan_key2.sign_compact(trx.digest())}; BOOST_CHECK_EQUAL(get_balance(nathan, core), nathan_start_balance.amount.value); - db.push_transaction(trx); + PUSH_TX( db, trx ); BOOST_CHECK_EQUAL(get_balance(nathan, core), nathan_start_balance.amount.value - 100); } catch (fc::exception& e) { edump((e.to_detail_string())); @@ -354,7 +354,7 @@ BOOST_AUTO_TEST_CASE( genesis_authority ) trx.operations.push_back(transfer_operation({asset(), account_id_type(), nathan.id, asset(100000)})); sign(trx, key_id_type(), genesis_key); - BOOST_CHECK_THROW(db.push_transaction(trx), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); auto sign = [&] { trx.signatures.clear(); trx.sign(nathan_key_id,nathan_key); }; @@ -366,16 +366,16 @@ BOOST_AUTO_TEST_CASE( genesis_authority ) sign(); // The review period isn't set yet. Make sure it throws. - BOOST_REQUIRE_THROW( db.push_transaction(trx), fc::exception ); + BOOST_REQUIRE_THROW( PUSH_TX( db, trx ), fc::exception ); pop.review_period_seconds = global_params.genesis_proposal_review_period / 2; trx.operations.back() = pop; sign(); // The review period is too short. Make sure it throws. - BOOST_REQUIRE_THROW( db.push_transaction(trx), fc::exception ); + BOOST_REQUIRE_THROW( PUSH_TX( db, trx ), fc::exception ); pop.review_period_seconds = global_params.genesis_proposal_review_period; trx.operations.back() = pop; sign(); - proposal_object prop = db.get(db.push_transaction(trx).operation_results.front().get()); + proposal_object prop = db.get(PUSH_TX( db, trx ).operation_results.front().get()); BOOST_REQUIRE(db.find_object(prop.id)); BOOST_CHECK(prop.expiration_time == pop.expiration_time); @@ -396,7 +396,7 @@ BOOST_AUTO_TEST_CASE( genesis_authority ) uop.key_approvals_to_add.emplace(); trx.operations.push_back(uop); trx.sign(key_id_type(), genesis_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 0); BOOST_CHECK(db.get(prop.id).is_authorized_to_execute(&db)); @@ -406,7 +406,7 @@ BOOST_AUTO_TEST_CASE( genesis_authority ) trx.operations.back() = uop; trx.sign(key_id_type(), genesis_key); // Should throw because the transaction is now in review. - BOOST_CHECK_THROW(db.push_transaction(trx), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); generate_blocks(prop.expiration_time); BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000); @@ -445,7 +445,7 @@ BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture ) pop.proposed_ops.emplace_back(transfer_operation({asset(),account_id_type(), nathan->id, asset(100000)})); trx.operations.push_back(pop); sign(trx, key_id_type(), genesis_key); - const proposal_object& prop = db.get(db.push_transaction(trx).operation_results.front().get()); + const proposal_object& prop = db.get(PUSH_TX( db, trx ).operation_results.front().get()); proposal_id_type pid = prop.id; BOOST_CHECK(!prop.is_authorized_to_execute(&db)); @@ -456,7 +456,7 @@ BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture ) uop.key_approvals_to_add.emplace(); trx.operations.back() = uop; trx.sign(key_id_type(), genesis_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); BOOST_CHECK(prop.is_authorized_to_execute(&db)); //Time passes... the proposal is now in its review period. @@ -478,7 +478,7 @@ BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture ) op.new_options->votes = delegates; trx.operations.push_back(op); trx.set_expiration(db.head_block_time() + GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.operations.clear(); } @@ -524,7 +524,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_two_accounts, database_fixture ) pop.expiration_time = db.head_block_time() + fc::days(1); trx.operations.push_back(pop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); } @@ -541,7 +541,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_two_accounts, database_fixture ) uop.fee_paying_account = nathan.get_id(); trx.operations.push_back(uop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK(db.find_object(pid) != nullptr); @@ -550,9 +550,9 @@ BOOST_FIXTURE_TEST_CASE( proposal_two_accounts, database_fixture ) uop.active_approvals_to_add = {dan.get_id()}; trx.operations.push_back(uop); trx.sign(nathan_key_obj.id,nathan_key); - BOOST_REQUIRE_THROW(db.push_transaction(trx), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx ), fc::exception); trx.sign(dan_key_obj.id,dan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); BOOST_CHECK(db.find_object(pid) == nullptr); } @@ -588,7 +588,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_delete, database_fixture ) pop.expiration_time = db.head_block_time() + fc::days(1); trx.operations.push_back(pop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); } @@ -604,7 +604,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_delete, database_fixture ) uop.active_approvals_to_add.insert(nathan.get_id()); trx.operations.push_back(uop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK(!prop.is_authorized_to_execute(&db)); BOOST_CHECK_EQUAL(prop.available_active_approvals.size(), 1); @@ -612,7 +612,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_delete, database_fixture ) std::swap(uop.active_approvals_to_add, uop.active_approvals_to_remove); trx.operations.push_back(uop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK(!prop.is_authorized_to_execute(&db)); BOOST_CHECK_EQUAL(prop.available_active_approvals.size(), 0); @@ -625,7 +625,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_delete, database_fixture ) dop.proposal = pid; trx.operations.push_back(dop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); BOOST_CHECK(db.find_object(pid) == nullptr); BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000); } @@ -666,7 +666,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_delete, database_fixture ) pop.expiration_time = db.head_block_time() + fc::days(1); trx.operations.push_back(pop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); } @@ -682,7 +682,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_delete, database_fixture ) uop.owner_approvals_to_add.insert(nathan.get_id()); trx.operations.push_back(uop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK(!prop.is_authorized_to_execute(&db)); BOOST_CHECK_EQUAL(prop.available_owner_approvals.size(), 1); @@ -690,7 +690,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_delete, database_fixture ) std::swap(uop.owner_approvals_to_add, uop.owner_approvals_to_remove); trx.operations.push_back(uop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK(!prop.is_authorized_to_execute(&db)); BOOST_CHECK_EQUAL(prop.available_owner_approvals.size(), 0); @@ -704,7 +704,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_delete, database_fixture ) dop.using_owner_authority = true; trx.operations.push_back(dop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); BOOST_CHECK(db.find_object(pid) == nullptr); BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000); } @@ -745,7 +745,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture ) pop.expiration_time = db.head_block_time() + fc::days(1); trx.operations.push_back(pop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); } @@ -763,7 +763,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture ) trx.operations.push_back(uop); trx.sign(nathan_key_obj.id,nathan_key); trx.sign(dan_key_obj.id,dan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK(!prop.is_authorized_to_execute(&db)); BOOST_CHECK_EQUAL(prop.available_key_approvals.size(), 1); @@ -772,7 +772,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture ) trx.operations.push_back(uop); trx.sign(nathan_key_obj.id,nathan_key); trx.sign(dan_key_obj.id,dan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK(!prop.is_authorized_to_execute(&db)); BOOST_CHECK_EQUAL(prop.available_key_approvals.size(), 0); @@ -783,7 +783,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture ) trx.operations.push_back(uop); trx.sign(nathan_key_obj.id,nathan_key); trx.sign(dan_key_obj.id,dan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK(!prop.is_authorized_to_execute(&db)); BOOST_CHECK_EQUAL(prop.available_key_approvals.size(), 1); @@ -792,7 +792,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture ) uop.owner_approvals_to_add.insert(nathan.get_id()); trx.operations.push_back(uop); trx.sign(nathan_key_obj.id,nathan_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK(db.find_object(pid) == nullptr); } @@ -842,7 +842,7 @@ BOOST_FIXTURE_TEST_CASE( max_authority_membership, database_fixture ) kc_op.key_data = public_key_type( privkey.get_public_key() ); tx.operations.push_back( kc_op ); } - ptx = db.push_transaction(tx, ~0); + ptx = PUSH_TX( db, tx, ~0 ); vector key_ids; @@ -882,11 +882,11 @@ BOOST_FIXTURE_TEST_CASE( max_authority_membership, database_fixture ) if( num_keys > max_authority_membership ) { - BOOST_REQUIRE_THROW(db.push_transaction(tx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, tx, ~0 ), fc::exception); } else { - db.push_transaction(tx, ~0); + PUSH_TX( db, tx, ~0 ); } return; }; @@ -943,38 +943,38 @@ BOOST_FIXTURE_TEST_CASE( bogus_signature, database_fixture ) wdump( (active_set)(owner_set)(alice_key_id) (alice_account_object) ); - db.push_transaction( trx, skip ); + PUSH_TX( db, trx, skip ); trx.operations.push_back( xfer_op ); // Alice's signature is now invalid edump((trx)); - BOOST_REQUIRE_THROW( db.push_transaction( trx, skip ), fc::exception ); + BOOST_REQUIRE_THROW( PUSH_TX( db, trx, skip ), fc::exception ); // Re-sign, now OK (sig is replaced) trx.sign( alice_key_id, alice_key ); - db.push_transaction( trx, skip ); + PUSH_TX( db, trx, skip ); trx.signatures.clear(); trx.sign( charlie_key_id, alice_key ); // Sign with Alice's key (valid) claiming to be Charlie - BOOST_REQUIRE_THROW( db.push_transaction( trx, skip ), fc::exception ); + BOOST_REQUIRE_THROW( PUSH_TX( db, trx, skip ), fc::exception ); // and with Charlie's key (invalid) claiming to be Alice trx.sign( charlie_key_id, alice_key ); - BOOST_REQUIRE_THROW( db.push_transaction( trx, skip ), fc::exception ); + BOOST_REQUIRE_THROW( PUSH_TX( db, trx, skip ), fc::exception ); trx.signatures.clear(); // okay, now sign ONLY with Charlie's key claiming to be Alice trx.sign( charlie_key_id, alice_key ); - BOOST_REQUIRE_THROW( db.push_transaction( trx, skip ), fc::exception ); + BOOST_REQUIRE_THROW( PUSH_TX( db, trx, skip ), fc::exception ); trx.signatures.clear(); trx.operations.pop_back(); trx.sign( alice_key_id, alice_key ); trx.sign( charlie_key_id, charlie_key ); // Signed by third-party Charlie (irrelevant key, not in authority) - db.push_transaction( trx, skip ); + PUSH_TX( db, trx, skip ); trx.operations.push_back( xfer_op ); trx.sign( alice_key_id, alice_key ); // Alice's sig is valid but Charlie's is invalid - BOOST_REQUIRE_THROW( db.push_transaction( trx, skip ), fc::exception ); + BOOST_REQUIRE_THROW( PUSH_TX( db, trx, skip ), fc::exception ); } FC_LOG_AND_RETHROW() } @@ -1001,7 +1001,7 @@ BOOST_FIXTURE_TEST_CASE( voting_account, database_fixture ) op.new_options->num_committee = 1; trx.operations.push_back(op); trx.sign(nathan_key_id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); } { @@ -1013,11 +1013,11 @@ BOOST_FIXTURE_TEST_CASE( voting_account, database_fixture ) trx.operations.push_back(op); trx.sign(vikram_key_id, vikram_private_key); // Fails because num_committee is larger than the cardinality of committee members being voted for - BOOST_CHECK_THROW(db.push_transaction(trx), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); op.new_options->num_committee = 3; trx.operations = {op}; trx.sign(vikram_key_id, vikram_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); } diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index 0fed7963..f0d5afdb 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -214,7 +214,7 @@ BOOST_AUTO_TEST_CASE( fork_blocks ) now += db1.block_interval(); auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, delegate_priv_key); try { - db2.push_block(b); + PUSH_BLOCK( db2, b ); } FC_CAPTURE_AND_RETHROW( ("db2") ); } for( uint32_t i = 10; i < 13; ++i ) @@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE( fork_blocks ) auto b = db2.generate_block(now, db2.get_scheduled_witness(db2.get_slot_at_time(now)).first, delegate_priv_key); // notify both databases of the new block. // only db2 should switch to the new fork, db1 should not - db1.push_block(b); + PUSH_BLOCK( db1, b ); BOOST_CHECK_EQUAL(db1.head_block_id().str(), db1_tip); BOOST_CHECK_EQUAL(db2.head_block_id().str(), b.id().str()); } @@ -247,14 +247,14 @@ BOOST_AUTO_TEST_CASE( fork_blocks ) b.transactions.back().operations.emplace_back(transfer_operation()); b.sign(delegate_priv_key); BOOST_CHECK_EQUAL(b.block_num(), 14); - BOOST_CHECK_THROW(db1.push_block(b), fc::exception); + BOOST_CHECK_THROW(PUSH_BLOCK( db1, b ), fc::exception); } BOOST_CHECK_EQUAL(db1.head_block_num(), 13); BOOST_CHECK_EQUAL(db1.head_block_id().str(), db1_tip); // assert that db1 switches to new fork with good block BOOST_CHECK_EQUAL(db2.head_block_num(), 14); - db1.push_block(good_block); + PUSH_BLOCK( db1, good_block ); BOOST_CHECK_EQUAL(db1.head_block_id().str(), db2.head_block_id().str()); } catch (fc::exception& e) { edump((e.to_detail_string())); @@ -278,7 +278,7 @@ BOOST_AUTO_TEST_CASE( undo_pending ) signed_transaction trx; trx.set_expiration(db.head_block_time() + fc::minutes(1)); trx.operations.push_back(transfer_operation({asset(), account_id_type(), account_id_type(1), asset(10000000)})); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); now += db.block_interval(); auto b = db.generate_block( now, db.get_scheduled_witness( 1 ).first, delegate_priv_key, ~0 ); @@ -293,7 +293,7 @@ BOOST_AUTO_TEST_CASE( undo_pending ) cop.owner = authority(1, key_id_type(), 1); trx.operations.push_back(cop); trx.sign( key_id_type(), delegate_priv_key ); - db.push_transaction(trx); + PUSH_TX( db, trx ); now += db.block_interval(); auto b = db.generate_block( now, db.get_scheduled_witness( 1 ).first, delegate_priv_key ); @@ -304,12 +304,12 @@ BOOST_AUTO_TEST_CASE( undo_pending ) trx.set_expiration(db.head_block_time() + db.get_global_properties().parameters.maximum_time_until_expiration-1); trx.operations.push_back(transfer_operation({asset(1),account_id_type(1), nathan_id, asset(5000)})); trx.sign( key_id_type(), delegate_priv_key ); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); trx.set_expiration(db.head_block_time() + db.get_global_properties().parameters.maximum_time_until_expiration-2); trx.operations.push_back(transfer_operation({asset(1),account_id_type(1), nathan_id, asset(5000)})); trx.sign( key_id_type(), delegate_priv_key ); - db.push_transaction(trx); + PUSH_TX( db, trx ); BOOST_CHECK(db.get_balance(nathan_id, asset_id_type()).amount == 10000); db.clear_pending(); @@ -344,7 +344,7 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create ) cop.owner = authority(1, key_id_type(), 1); trx.operations.push_back(cop); trx.sign( key_id_type(), delegate_priv_key ); - db1.push_transaction(trx); + PUSH_TX( db1, trx ); auto aw = db1.get_global_properties().active_witnesses; now += db1.block_interval(); @@ -355,20 +355,20 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create ) now = fc::time_point_sec( GRAPHENE_GENESIS_TIMESTAMP ); now += db2.block_interval(); b = db2.generate_block( now, db2.get_scheduled_witness( 1 ).first, delegate_priv_key ); - db1.push_block(b); + PUSH_BLOCK( db1, b ); aw = db2.get_global_properties().active_witnesses; now += db2.block_interval(); b = db2.generate_block( now, db2.get_scheduled_witness( 1 ).first, delegate_priv_key ); - db1.push_block(b); + PUSH_BLOCK( db1, b ); BOOST_CHECK_THROW(nathan_id(db1), fc::exception); - db2.push_transaction(trx); + PUSH_TX( db2, trx ); aw = db2.get_global_properties().active_witnesses; now += db2.block_interval(); b = db2.generate_block( now, db2.get_scheduled_witness( 1 ).first, delegate_priv_key ); - db1.push_block(b); + PUSH_BLOCK( db1, b ); BOOST_CHECK(nathan_id(db1).name == "nathan"); BOOST_CHECK(nathan_id(db2).name == "nathan"); @@ -402,22 +402,22 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions ) cop.owner = authority(1, key_id_type(), 1); trx.operations.push_back(cop); trx.sign( key_id_type(), delegate_priv_key ); - db1.push_transaction(trx, skip_sigs); + PUSH_TX( db1, trx, skip_sigs ); trx = decltype(trx)(); trx.set_expiration(db1.head_block_time() + fc::minutes(1)); trx.operations.push_back(transfer_operation({asset(), account_id_type(), nathan_id, asset(500)})); trx.sign( key_id_type(), delegate_priv_key ); - db1.push_transaction(trx, skip_sigs); + PUSH_TX( db1, trx, skip_sigs ); - BOOST_CHECK_THROW(db1.push_transaction(trx, skip_sigs), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db1, trx, skip_sigs ), fc::exception); now += db1.block_interval(); auto b = db1.generate_block( now, db1.get_scheduled_witness( 1 ).first, delegate_priv_key, skip_sigs ); - db2.push_block(b, skip_sigs); + PUSH_BLOCK( db2, b, skip_sigs ); - BOOST_CHECK_THROW(db1.push_transaction(trx, skip_sigs), fc::exception); - BOOST_CHECK_THROW(db2.push_transaction(trx, skip_sigs), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db1, trx, skip_sigs ), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db2, trx, skip_sigs ), fc::exception); BOOST_CHECK_EQUAL(db1.get_balance(nathan_id, asset_id_type()).amount.value, 500); BOOST_CHECK_EQUAL(db2.get_balance(nathan_id, asset_id_type()).amount.value, 500); } catch (fc::exception& e) { @@ -459,7 +459,7 @@ BOOST_AUTO_TEST_CASE( tapos ) trx.signatures.clear(); trx.sign( key_id_type(), delegate_priv_key ); - db1.push_transaction(trx); + PUSH_TX( db1, trx ); now += db1.block_interval(); b = db1.generate_block( now, db1.get_scheduled_witness( 1 ).first, delegate_priv_key ); @@ -469,11 +469,11 @@ BOOST_AUTO_TEST_CASE( tapos ) trx.operations.push_back(transfer_operation({asset(), account_id_type(), nathan_id, asset(50)})); trx.sign( key_id_type(), delegate_priv_key ); //relative_expiration is 1, but ref block is 2 blocks old, so this should fail. - BOOST_REQUIRE_THROW(db1.push_transaction(trx, database::skip_transaction_signatures | database::skip_authority_check), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db1, trx, database::skip_transaction_signatures | database::skip_authority_check ), fc::exception); trx.set_expiration(db1.head_block_id(), 2); trx.signatures.clear(); trx.sign( key_id_type(), delegate_priv_key ); - db1.push_transaction(trx, database::skip_transaction_signatures | database::skip_authority_check); + PUSH_TX( db1, trx, database::skip_transaction_signatures | database::skip_authority_check ); } catch (fc::exception& e) { edump((e.to_detail_string())); throw; @@ -498,7 +498,7 @@ BOOST_FIXTURE_TEST_CASE( maintenance_interval, database_fixture ) op.new_options = nathan.options; op.new_options->votes.insert(nathans_delegate.vote_id); trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.operations.clear(); } transfer(account_id_type()(db), nathan, asset(5000)); @@ -555,7 +555,7 @@ BOOST_FIXTURE_TEST_CASE( short_order_expiration, database_fixture ) op.collateral = core->amount(500); op.expiration = db.head_block_time() + fc::seconds(10); trx.operations.push_back(op); - auto ptrx = db.push_transaction(trx, ~0); + auto ptrx = PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL( get_balance(*nathan, *core), 49500 ); @@ -598,7 +598,7 @@ BOOST_FIXTURE_TEST_CASE( limit_order_expiration, database_fixture ) op.min_to_receive = test->amount(500); op.expiration = db.head_block_time() + fc::seconds(10); trx.operations.push_back(op); - auto ptrx = db.push_transaction(trx, ~0); + auto ptrx = PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL( get_balance(*nathan, *core), 49500 ); @@ -638,7 +638,7 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture ) cop.proposed_ops.emplace_back(uop); trx.operations.push_back(cop); trx.sign(key_id_type(),generate_private_key("genesis")); - db.push_transaction(trx); + PUSH_TX( db, trx ); } { proposal_update_operation uop; @@ -647,7 +647,7 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture ) account_id_type(5), account_id_type(6), account_id_type(7), account_id_type(8)}; trx.operations.push_back(uop); trx.sign(key_id_type(),generate_private_key("genesis")); - db.push_transaction(trx); + PUSH_TX( db, trx ); BOOST_CHECK(proposal_id_type()(db).is_authorized_to_execute(&db)); } @@ -690,7 +690,7 @@ BOOST_FIXTURE_TEST_CASE( force_settlement, database_fixture ) op.new_options.maximum_force_settlement_volume = 9000; trx.clear(); trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.clear(); } generate_block(); @@ -731,7 +731,7 @@ BOOST_FIXTURE_TEST_CASE( force_settlement, database_fixture ) trx.operations.push_back(pop); } trx.sign(key_id_type(),private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); asset_settle_operation sop; @@ -743,7 +743,7 @@ BOOST_FIXTURE_TEST_CASE( force_settlement, database_fixture ) trx.sign(key_id_type(),private_key); //Partially settle a call - force_settlement_id_type settle_id = db.push_transaction(trx).operation_results.front().get(); + force_settlement_id_type settle_id = PUSH_TX( db, trx ).operation_results.front().get(); trx.clear(); call_order_id_type call_id = db.get_index_type().indices().get().begin()->id; BOOST_CHECK_EQUAL(settle_id(db).balance.amount.value, 50); @@ -761,10 +761,10 @@ BOOST_FIXTURE_TEST_CASE( force_settlement, database_fixture ) trx.operations.push_back(sop); trx.sign(key_id_type(),private_key); //Trx has expired by now. Make sure it throws. - BOOST_CHECK_THROW(settle_id = db.push_transaction(trx).operation_results.front().get(), fc::exception); + BOOST_CHECK_THROW(settle_id = PUSH_TX( db, trx ).operation_results.front().get(), fc::exception); trx.set_expiration(db.head_block_time() + fc::minutes(1)); trx.sign(key_id_type(),private_key); - settle_id = db.push_transaction(trx).operation_results.front().get(); + settle_id = PUSH_TX( db, trx ).operation_results.front().get(); trx.clear(); generate_blocks(settle_id(db).settlement_date); @@ -777,7 +777,7 @@ BOOST_FIXTURE_TEST_CASE( force_settlement, database_fixture ) sop.amount = db.get_balance(nathan_id, bit_usd); trx.operations.push_back(sop); trx.sign(key_id_type(),private_key); - settle_id = db.push_transaction(trx).operation_results.front().get(); + settle_id = PUSH_TX( db, trx ).operation_results.front().get(); trx.clear(); generate_blocks(settle_id(db).settlement_date); diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index f5b429d7..b98c9930 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE( cashback_test ) op.fee = op.calculate_fee(fees); \ trx.operations = {op}; \ trx.sign(registrar_name ## _key_id, registrar_name ## _private_key); \ - actor_name ## _id = db.push_transaction(trx).operation_results.front().get(); \ + actor_name ## _id = PUSH_TX( db, trx ).operation_results.front().get(); \ trx.clear(); \ } diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index f2c503be..71f34b2b 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -64,17 +64,17 @@ BOOST_AUTO_TEST_CASE( create_account_test ) op.owner.add_authority(account_id_type(9999999999), 10); trx.operations.back() = op; op.owner = auth_bak; - BOOST_REQUIRE_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); op.owner = auth_bak; op.owner.add_authority(key_id_type(9999999999), 10); trx.operations.back() = op; - BOOST_REQUIRE_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); op.owner = auth_bak; trx.operations.back() = op; trx.sign( key_id_type(), fc::ecc::private_key::regenerate(fc::sha256::hash(string("genesis"))) ); trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); const account_object& nathan_account = *db.get_index_type().indices().get().find("nathan"); BOOST_CHECK(nathan_account.id.space() == protocol_ids); @@ -124,15 +124,15 @@ BOOST_AUTO_TEST_CASE( child_account ) trx.operations.emplace_back(op); sign(trx, key_id_type(), fc::ecc::private_key::regenerate(fc::sha256::hash(string("genesis")))); - BOOST_REQUIRE_THROW(db.push_transaction(trx), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx ), fc::exception); sign(trx, nathan_key.id,nathan_private_key); - BOOST_REQUIRE_THROW(db.push_transaction(trx), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx ), fc::exception); trx.signatures.clear(); op.owner = authority(1, account_id_type(nathan.id), 1); trx.operations = {op}; sign(trx, key_id_type(), fc::ecc::private_key::regenerate(fc::sha256::hash(string("genesis")))); sign(trx, nathan_key.id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); BOOST_CHECK( get_account("nathan/child").active.auths == op.active.auths ); } catch (fc::exception& e) { @@ -153,7 +153,7 @@ BOOST_AUTO_TEST_CASE( update_account ) transfer(account_id_type()(db), nathan, asset(30000)); trx.operations.emplace_back(key_create_operation({asset(),nathan.id,address(nathan_new_key.get_public_key())})); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); account_update_operation op; op.account = nathan.id; @@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE( update_account ) op.new_options->votes = flat_set({active_delegates[0](db).vote_id, active_delegates[5](db).vote_id}); op.new_options->num_committee = 2; trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK(nathan.options.memo_key == key_id_type()); BOOST_CHECK(nathan.active.weight_threshold == 2); @@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE( update_account ) op.upgrade_to_lifetime_member = true; op.fee = op.calculate_fee(db.get_global_properties().parameters.current_fees); trx.operations = {op}; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); } BOOST_CHECK( nathan.is_lifetime_member() ); @@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE( transfer_core_asset ) asset fee = trx.operations.front().get().fee; trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(account_id_type()(db), asset_id_type()(db)), (genesis_balance.amount - 10000 - fee.amount).value); @@ -240,7 +240,7 @@ BOOST_AUTO_TEST_CASE( transfer_core_asset ) fee = trx.operations.front().get().fee; trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 8000 - fee.amount.value); BOOST_CHECK_EQUAL(get_balance(account_id_type()(db), asset_id_type()(db)), genesis_balance.amount.value + 2000); @@ -264,7 +264,7 @@ BOOST_AUTO_TEST_CASE( create_delegate ) trx.operations.back() = op; delegate_id_type delegate_id = db.get_index_type>>().get_next_id(); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); const delegate_object& d = delegate_id(db); BOOST_CHECK(d.delegate_account == account_id_type()); @@ -302,11 +302,11 @@ BOOST_AUTO_TEST_CASE( update_mia ) trx.operations.emplace_back(op); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); std::swap(op.new_options.flags, op.new_options.issuer_permissions); op.new_issuer = account_id_type(); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); { asset_publish_feed_operation pop; @@ -327,7 +327,7 @@ BOOST_AUTO_TEST_CASE( update_mia ) REQUIRE_THROW_WITH_VALUE(pop, feed.required_maintenance_collateral, 0); REQUIRE_THROW_WITH_VALUE(pop, feed.required_initial_collateral, 500); trx.operations.back() = pop; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); } trx.operations.clear(); @@ -335,13 +335,13 @@ BOOST_AUTO_TEST_CASE( update_mia ) op.issuer = account_id_type(); op.new_issuer = nathan.id; trx.operations.emplace_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK(bit_usd.issuer == nathan.id); op.issuer = nathan.id; op.new_issuer = account_id_type(); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK(bit_usd.issuer == account_id_type()); } catch ( const fc::exception& e ) { elog( "${e}", ("e", e.to_detail_string() ) ); @@ -488,7 +488,7 @@ BOOST_AUTO_TEST_CASE( create_uia ) creator.common_options.flags = charge_market_fee; creator.common_options.core_exchange_rate = price({asset(2),asset(1,1)}); trx.operations.push_back(std::move(creator)); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); const asset_object& test_asset = test_asset_id(db); BOOST_CHECK(test_asset.symbol == "TEST"); @@ -497,7 +497,7 @@ BOOST_AUTO_TEST_CASE( create_uia ) BOOST_CHECK(test_asset.options.max_supply == 100000000); BOOST_CHECK(!test_asset.bitasset_data_id.valid()); BOOST_CHECK(test_asset.options.market_fee_percent == GRAPHENE_MAX_MARKET_FEE_PERCENT/100); - BOOST_REQUIRE_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); const asset_dynamic_data_object& test_asset_dynamic_data = test_asset.dynamic_asset_data_id(db); BOOST_CHECK(test_asset_dynamic_data.current_supply == 0); @@ -547,22 +547,22 @@ BOOST_AUTO_TEST_CASE( update_uia ) op.new_options.core_exchange_rate = price(asset(3), test.amount(5)); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); REQUIRE_THROW_WITH_VALUE(op, new_options.core_exchange_rate, price()); op.new_options.core_exchange_rate = test.options.core_exchange_rate; op.new_issuer = nathan.id; trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); op.issuer = nathan.id; op.new_issuer.reset(); op.new_options.flags = transfer_restricted | white_list; trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); REQUIRE_THROW_WITH_VALUE(op, new_options.issuer_permissions, test.options.issuer_permissions & ~white_list); op.new_options.issuer_permissions = test.options.issuer_permissions & ~white_list; op.new_options.flags = 0; trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); op.new_options.issuer_permissions = test.options.issuer_permissions; op.new_options.flags = test.options.flags; BOOST_CHECK(!(test.options.issuer_permissions & white_list)); @@ -570,9 +570,9 @@ BOOST_AUTO_TEST_CASE( update_uia ) REQUIRE_THROW_WITH_VALUE(op, new_options.flags, white_list); op.new_issuer = account_id_type(); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); op.issuer = account_id_type(); - BOOST_REQUIRE_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); op.new_issuer.reset(); } catch(fc::exception& e) { edump((e.to_detail_string())); @@ -597,7 +597,7 @@ BOOST_AUTO_TEST_CASE( issue_uia ) REQUIRE_THROW_WITH_VALUE(op, issue_to_account, account_id_type(999999999)); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); const asset_dynamic_data_object& test_dynamic_data = test_asset.dynamic_asset_data_id(db); BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset), 5000000); @@ -605,7 +605,7 @@ BOOST_AUTO_TEST_CASE( issue_uia ) BOOST_CHECK(test_dynamic_data.accumulated_fees == 0); BOOST_CHECK(test_dynamic_data.fee_pool == 0); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset), 10000000); BOOST_CHECK(test_dynamic_data.current_supply == 10000000); @@ -628,11 +628,11 @@ BOOST_AUTO_TEST_CASE( transfer_uia ) BOOST_CHECK_EQUAL(get_balance(nathan, uia), 10000000); trx.operations.push_back(transfer_operation({asset(),nathan.id, genesis.id, uia.amount(5000)})); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(nathan, uia), 10000000 - 5000); BOOST_CHECK_EQUAL(get_balance(genesis, uia), 5000); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(nathan, uia), 10000000 - 10000); BOOST_CHECK_EQUAL(get_balance(genesis, uia), 10000); } catch(fc::exception& e) { @@ -830,7 +830,7 @@ BOOST_AUTO_TEST_CASE( uia_fees ) BOOST_CHECK(fee.amount > 0); asset core_fee = fee*test_asset.options.core_exchange_rate; trx.operations.push_back(std::move(op)); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset), (old_balance - fee - test_asset.amount(100)).amount.value); @@ -839,7 +839,7 @@ BOOST_AUTO_TEST_CASE( uia_fees ) BOOST_CHECK(asset_dynamic.fee_pool == 1000000 - core_fee.amount); //Do it again, for good measure. - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset), (old_balance - fee - fee - test_asset.amount(200)).amount.value); BOOST_CHECK_EQUAL(get_balance(genesis_account, test_asset), 200); @@ -856,7 +856,7 @@ BOOST_AUTO_TEST_CASE( uia_fees ) BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 20); trx.operations.emplace_back(std::move(op)); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 0); BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset), @@ -903,7 +903,7 @@ BOOST_AUTO_TEST_CASE( delegate_feeds ) asset_update_operation uop(get_asset("BITUSD")); uop.new_issuer = account_id_type(); trx.operations.push_back(uop); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.clear(); } generate_block(); @@ -921,7 +921,7 @@ BOOST_AUTO_TEST_CASE( delegate_feeds ) op.feed.max_margin_period_sec = fc::days(30).to_seconds(); // Accept defaults for required collateral trx.operations.emplace_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); { //Dumb sanity check of some operators. Only here to improve code coverage. :D @@ -948,7 +948,7 @@ BOOST_AUTO_TEST_CASE( delegate_feeds ) op.feed.short_limit = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(20)); op.feed.max_margin_period_sec = fc::days(10).to_seconds(); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(bitasset.current_feed.call_limit.to_real(), GRAPHENE_BLOCKCHAIN_PRECISION / 25.0); BOOST_CHECK_EQUAL(bitasset.current_feed.short_limit.to_real(), 20.0 / GRAPHENE_BLOCKCHAIN_PRECISION); @@ -964,7 +964,7 @@ BOOST_AUTO_TEST_CASE( delegate_feeds ) op.feed.required_initial_collateral = 1001; op.feed.required_maintenance_collateral = 1000; trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(bitasset.current_feed.call_limit.to_real(), GRAPHENE_BLOCKCHAIN_PRECISION / 30.0); BOOST_CHECK_EQUAL(bitasset.current_feed.short_limit.to_real(), 10.0 / GRAPHENE_BLOCKCHAIN_PRECISION); @@ -1235,7 +1235,7 @@ BOOST_AUTO_TEST_CASE( full_cover_test ) REQUIRE_THROW_WITH_VALUE(op, collateral_to_add, bit_usd.amount(20)); REQUIRE_THROW_WITH_VALUE(op, maintenance_collateral_ratio, 2); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(debt_holder, bit_usd), 0); BOOST_CHECK(index.find(boost::make_tuple(debt_holder.id, bit_usd.id)) == index.end()); @@ -1269,7 +1269,7 @@ BOOST_AUTO_TEST_CASE( partial_cover_test ) op.collateral_to_add = core.amount(0); op.amount_to_cover = bit_usd.amount(50); trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(debt_holder, bit_usd), 0); BOOST_CHECK(index.find(boost::make_tuple(debt_holder.id, bit_usd.id)) != index.end()); @@ -1280,7 +1280,7 @@ BOOST_AUTO_TEST_CASE( partial_cover_test ) op.collateral_to_add = core.amount(52); op.amount_to_cover = bit_usd.amount(0); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); ilog("..." ); BOOST_CHECK(debt.call_price == price(core.amount(339), bit_usd.amount(50))); @@ -1292,7 +1292,7 @@ BOOST_AUTO_TEST_CASE( partial_cover_test ) REQUIRE_THROW_WITH_VALUE(op, maintenance_collateral_ratio, 2500); op.collateral_to_add = core.amount(8); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK(debt.call_price == price(core.amount(368), bit_usd.amount(50))); @@ -1300,7 +1300,7 @@ BOOST_AUTO_TEST_CASE( partial_cover_test ) op.collateral_to_add.amount = 0; trx.operations.back() = op; BOOST_CHECK_EQUAL(get_balance(debt_holder, bit_usd), 0); - BOOST_CHECK_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); trx.operations.clear(); ilog("..." ); @@ -1310,7 +1310,7 @@ BOOST_AUTO_TEST_CASE( partial_cover_test ) op.validate(); ilog("..." ); trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK(index.find(boost::make_tuple(debt_holder.id, bit_usd.id)) == index.end()); } catch( fc::exception& e) { @@ -1831,10 +1831,10 @@ BOOST_AUTO_TEST_CASE( limit_order_fill_or_kill ) trx.operations.clear(); trx.operations.push_back(op); - BOOST_CHECK_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); op.fill_or_kill = false; trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); } FC_LOG_AND_RETHROW() } /// Shameless code coverage plugging. Otherwise, these calls never happen. @@ -1882,7 +1882,7 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test ) trx.visit(operation_set_fee(db.current_fee_schedule())); trx.validate(); trx.sign(key_id_type(),generate_private_key("genesis")); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK_EQUAL(get_balance(*nathan, *core), 8950000000); @@ -1961,7 +1961,7 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test ) trx.visit(operation_set_fee(db.current_fee_schedule())); trx.validate(); trx.sign(key_id_type(),generate_private_key("genesis")); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); BOOST_CHECK_EQUAL(get_balance(witness->witness_account(db), *core), witness_ppb - 1/*fee*/); @@ -2245,7 +2245,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test ) create_op.vesting_seconds = vesting_seconds; tx.operations.push_back( create_op ); - processed_transaction ptx = db.push_transaction( tx, ~0 ); + processed_transaction ptx = PUSH_TX( db, tx, ~0 ); const vesting_balance_object& vbo = vesting_balance_id_type( ptx.operation_results[0].get())(db); diff --git a/tests/tests/operation_tests2.cpp b/tests/tests/operation_tests2.cpp index aaebbdc1..1dd13d6c 100644 --- a/tests/tests/operation_tests2.cpp +++ b/tests/tests/operation_tests2.cpp @@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_create ) } trx.sign(nathan_key_id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); } FC_LOG_AND_RETHROW() } @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test ) op.amount_to_withdraw = asset(1); trx.operations.push_back(op); //Throws because we haven't entered the first withdrawal period yet. - BOOST_REQUIRE_THROW(db.push_transaction(trx), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx ), fc::exception); //Get to the actual withdrawal period generate_blocks(permit(db).period_start_time); @@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test ) trx.clear(); trx.operations.push_back(op); trx.sign(dan_key_id, dan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); // would be legal on its own, but doesn't work because trx already withdrew REQUIRE_THROW_WITH_VALUE(op, amount_to_withdraw, asset(5)); @@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test ) trx.operations.back() = op; // withdraw 1 trx.ref_block_prefix++; // make it different from previous trx so it's non-duplicate trx.sign(dan_key_id, dan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); } @@ -162,11 +162,11 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test ) trx.operations.push_back(op); trx.sign(dan_key_id, dan_private_key); //Throws because nathan doesn't have the money - BOOST_CHECK_THROW(db.push_transaction(trx), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); op.amount_to_withdraw = asset(1); trx.operations.back() = op; trx.sign(dan_key_id, dan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); } BOOST_CHECK_EQUAL(get_balance(nathan_id, asset_id_type()), 0); @@ -196,7 +196,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test ) trx.operations.push_back(op); trx.sign(dan_key_id, dan_private_key); //Throws because the permission has expired - BOOST_CHECK_THROW(db.push_transaction(trx), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); } } FC_LOG_AND_RETHROW() } @@ -226,7 +226,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_nominal_case ) // so tx's have different txid's trx.ref_block_prefix++; trx.sign(dan_key_id, dan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); // tx's involving withdraw_permissions can't delete it even // if no further withdrawals are possible BOOST_CHECK(db.find_object(permit) != nullptr); @@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_update ) REQUIRE_THROW_WITH_VALUE(op, period_start_time, db.head_block_time() - 50); trx.operations.back() = op; trx.sign(nathan_key_id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); } { @@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_delete ) trx.set_expiration(db.head_block_id()); trx.operations.push_back(op); trx.sign(get_account("nathan").active.auths.begin()->first, generate_private_key("nathan")); - db.push_transaction(trx); + PUSH_TX( db, trx ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( mia_feeds ) @@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) op.new_issuer = nathan_id; op.new_options = obj.options; trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); generate_block(); trx.clear(); } @@ -324,7 +324,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) op.new_feed_producers = {dan_id, ben_id, vikram_id}; trx.operations.push_back(op); trx.sign(nathan_key_id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); generate_block(database::skip_nothing); } { @@ -342,7 +342,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) op.feed.max_margin_period_sec = fc::days(30).to_seconds(); // Accept defaults for required collateral trx.operations.emplace_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); const asset_bitasset_data_object& bitasset = bit_usd.bitasset_data(db); BOOST_CHECK(bitasset.current_feed.call_limit.to_real() == GRAPHENE_BLOCKCHAIN_PRECISION / 30.0); @@ -356,7 +356,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) op.feed.short_limit = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(20)); op.feed.max_margin_period_sec = fc::days(10).to_seconds(); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(bitasset.current_feed.call_limit.to_real(), GRAPHENE_BLOCKCHAIN_PRECISION / 25.0); BOOST_CHECK_EQUAL(bitasset.current_feed.short_limit.to_real(), 20.0 / GRAPHENE_BLOCKCHAIN_PRECISION); @@ -371,7 +371,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) op.feed.required_initial_collateral = 1001; op.feed.required_maintenance_collateral = 1000; trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(bitasset.current_feed.call_limit.to_real(), GRAPHENE_BLOCKCHAIN_PRECISION / 30.0); BOOST_CHECK_EQUAL(bitasset.current_feed.short_limit.to_real(), 10.0 / GRAPHENE_BLOCKCHAIN_PRECISION); @@ -381,7 +381,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) op.publisher = nathan_id; trx.operations.back() = op; - BOOST_CHECK_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); } } FC_LOG_AND_RETHROW() } @@ -407,7 +407,7 @@ BOOST_AUTO_TEST_CASE( witness_create ) [](vote_id_type id) { return id.type() == vote_id_type::committee; }); trx.operations.push_back(op); trx.sign(nathan_key_id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); } @@ -482,7 +482,7 @@ BOOST_AUTO_TEST_CASE( global_settle_test ) REQUIRE_THROW_WITH_VALUE(op, issuer, account_id_type(2)); trx.operations.back() = op; trx.sign(nathan_key_id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); } BOOST_CHECK_EQUAL(get_balance(valentine_id, bit_usd_id), 0); @@ -515,7 +515,7 @@ BOOST_AUTO_TEST_CASE( worker_create_test ) REQUIRE_THROW_WITH_VALUE(op, work_end_date, op.work_begin_date); trx.operations.back() = op; trx.sign(nathan_key_id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); } const worker_object& worker = worker_id_type()(db); @@ -545,7 +545,7 @@ BOOST_AUTO_TEST_CASE( worker_pay_test ) op.new_options = nathan_id(db).options; op.new_options->votes.insert(worker_id_type()(db).vote_for); trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.clear(); } { @@ -553,7 +553,7 @@ BOOST_AUTO_TEST_CASE( worker_pay_test ) op.payer = account_id_type(); op.amount_to_burn = asset(GRAPHENE_INITIAL_SUPPLY/2); trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.clear(); } @@ -570,7 +570,7 @@ BOOST_AUTO_TEST_CASE( worker_pay_test ) trx.set_expiration(db.head_block_id()); trx.operations.push_back(op); trx.sign(nathan_key_id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.signatures.clear(); REQUIRE_THROW_WITH_VALUE(op, amount, asset(1)); trx.clear(); @@ -585,7 +585,7 @@ BOOST_AUTO_TEST_CASE( worker_pay_test ) op.new_options = nathan_id(db).options; op.new_options->votes.erase(worker_id_type()(db).vote_for); trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.clear(); } @@ -605,7 +605,7 @@ BOOST_AUTO_TEST_CASE( worker_pay_test ) REQUIRE_THROW_WITH_VALUE(op, amount, asset(501)); trx.operations.back() = op; trx.sign(nathan_key_id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.signatures.clear(); trx.clear(); } @@ -638,7 +638,7 @@ BOOST_AUTO_TEST_CASE( refund_worker_test ) REQUIRE_THROW_WITH_VALUE(op, work_end_date, op.work_begin_date); trx.operations.back() = op; trx.sign(nathan_key_id, nathan_private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); } @@ -658,7 +658,7 @@ BOOST_AUTO_TEST_CASE( refund_worker_test ) op.new_options = nathan_id(db).options; op.new_options->votes.insert(worker_id_type()(db).vote_for); trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.clear(); } { @@ -666,7 +666,7 @@ BOOST_AUTO_TEST_CASE( refund_worker_test ) op.payer = account_id_type(); op.amount_to_burn = asset(GRAPHENE_INITIAL_SUPPLY/2); trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.clear(); } @@ -704,7 +704,7 @@ BOOST_AUTO_TEST_CASE( force_settlement_unavailable ) op.new_options.maximum_force_settlement_volume = 9000; trx.clear(); trx.operations.push_back(op); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.clear(); } generate_block(); @@ -745,7 +745,7 @@ BOOST_AUTO_TEST_CASE( force_settlement_unavailable ) trx.operations.push_back(pop); } trx.sign(key_id_type(),private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.clear(); asset_settle_operation sop; @@ -753,7 +753,7 @@ BOOST_AUTO_TEST_CASE( force_settlement_unavailable ) sop.amount = asset(50, bit_usd); trx.operations = {sop}; //Force settlement is disabled; check that it fails - BOOST_CHECK_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_CHECK_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); { //Enable force settlement asset_update_operation op; @@ -763,7 +763,7 @@ BOOST_AUTO_TEST_CASE( force_settlement_unavailable ) op.new_options.flags &= ~disable_force_settle; trx.operations = {op}; trx.sign(key_id_type(), private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); trx.operations = {sop}; } REQUIRE_THROW_WITH_VALUE(sop, amount, asset(999999, bit_usd)); @@ -771,7 +771,7 @@ BOOST_AUTO_TEST_CASE( force_settlement_unavailable ) trx.sign(key_id_type(),private_key); //Partially settle a call - force_settlement_id_type settle_id = db.push_transaction(trx).operation_results.front().get(); + force_settlement_id_type settle_id = PUSH_TX( db, trx ).operation_results.front().get(); trx.clear(); call_order_id_type call_id = db.get_index_type().indices().get().begin()->id; BOOST_CHECK_EQUAL(settle_id(db).balance.amount.value, 50); @@ -793,7 +793,7 @@ BOOST_AUTO_TEST_CASE( force_settlement_unavailable ) trx.operations.push_back(op); trx.set_expiration(db.head_block_id()); trx.sign(key_id_type(), private_key); - db.push_transaction(trx); + PUSH_TX( db, trx ); //Check that force settlements were all canceled BOOST_CHECK(db.get_index_type().indices().empty()); BOOST_CHECK_EQUAL(get_balance(nathan_id, bit_usd), bit_usd(db).dynamic_data(db).current_supply.value); diff --git a/tests/tests/uia_tests.cpp b/tests/tests/uia_tests.cpp index c896d7fb..da3bed74 100644 --- a/tests/tests/uia_tests.cpp +++ b/tests/tests/uia_tests.cpp @@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE( create_advanced_uia ) creator.common_options.core_exchange_rate = price({asset(2),asset(1,1)}); creator.common_options.whitelist_authorities = creator.common_options.blacklist_authorities = {account_id_type()}; trx.operations.push_back(std::move(creator)); - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); const asset_object& test_asset = test_asset_id(db); BOOST_CHECK(test_asset.symbol == "ADVANCED"); @@ -82,16 +82,16 @@ BOOST_AUTO_TEST_CASE( issue_whitelist_uia ) asset_issue_operation op({asset(), advanced.issuer, advanced.amount(1000), nathan.id}); trx.operations.emplace_back(op); //Fail because nathan is not whitelisted. - BOOST_REQUIRE_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); account_whitelist_operation wop({asset(), account_id_type(), nathan.id, account_whitelist_operation::white_listed}); trx.operations.back() = wop; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK(nathan.is_authorized_asset(advanced)); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(nathan, advanced), 1000); } catch(fc::exception& e) { @@ -113,13 +113,13 @@ BOOST_AUTO_TEST_CASE( transfer_whitelist_uia ) transfer_operation op({advanced.amount(0), nathan.id, dan.id, advanced.amount(100)}); trx.operations.push_back(op); //Fail because dan is not whitelisted. - BOOST_REQUIRE_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); account_whitelist_operation wop({asset(), account_id_type(), dan.id, account_whitelist_operation::white_listed}); trx.operations.back() = wop; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(nathan, advanced), 900); BOOST_CHECK_EQUAL(get_balance(dan, advanced), 100); @@ -127,16 +127,16 @@ BOOST_AUTO_TEST_CASE( transfer_whitelist_uia ) wop.new_listing |= account_whitelist_operation::black_listed; wop.account_to_list = nathan.id; trx.operations.back() = wop; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); op.amount = advanced.amount(50); trx.operations.back() = op; //Fail because nathan is blacklisted - BOOST_REQUIRE_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); std::swap(op.from, op.to); trx.operations.back() = op; //Fail because nathan is blacklisted - BOOST_REQUIRE_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); { asset_update_operation op; @@ -145,12 +145,12 @@ BOOST_AUTO_TEST_CASE( transfer_whitelist_uia ) op.new_options.blacklist_authorities.clear(); op.new_options.blacklist_authorities.insert(dan.id); trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK(advanced.options.blacklist_authorities.find(dan.id) != advanced.options.blacklist_authorities.end()); } trx.operations.back() = op; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); BOOST_CHECK_EQUAL(get_balance(nathan, advanced), 950); BOOST_CHECK_EQUAL(get_balance(dan, advanced), 50); @@ -158,29 +158,29 @@ BOOST_AUTO_TEST_CASE( transfer_whitelist_uia ) wop.account_to_list = nathan.id; wop.new_listing = account_whitelist_operation::black_listed; trx.operations.back() = wop; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.operations.back() = op; //Fail because nathan is blacklisted BOOST_CHECK(!nathan.is_authorized_asset(advanced)); - BOOST_REQUIRE_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); //Remove nathan from genesis' whitelist, add him to dan's. This should not authorize him to hold ADVANCED. wop.authorizing_account = account_id_type(); wop.account_to_list = nathan.id; wop.new_listing = account_whitelist_operation::no_listing; trx.operations.back() = wop; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); wop.authorizing_account = dan.id; wop.account_to_list = nathan.id; wop.new_listing = account_whitelist_operation::white_listed; trx.operations.back() = wop; - db.push_transaction(trx, ~0); + PUSH_TX( db, trx, ~0 ); trx.operations.back() = op; //Fail because nathan is not whitelisted BOOST_CHECK(!nathan.is_authorized_asset(advanced)); - BOOST_REQUIRE_THROW(db.push_transaction(trx, ~0), fc::exception); + BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); } catch(fc::exception& e) { edump((e.to_detail_string())); throw;