fix unit tests
This commit is contained in:
parent
cc7953672c
commit
a7b145002d
2 changed files with 56 additions and 56 deletions
|
|
@ -53,22 +53,22 @@ BOOST_FIXTURE_TEST_SUITE( basic_tests, database_fixture )
|
|||
*/
|
||||
BOOST_AUTO_TEST_CASE( valid_name_test )
|
||||
{
|
||||
BOOST_CHECK( !is_valid_name( "a" ) );
|
||||
BOOST_CHECK( is_valid_name( "a" ) );
|
||||
BOOST_CHECK( !is_valid_name( "A" ) );
|
||||
BOOST_CHECK( !is_valid_name( "0" ) );
|
||||
BOOST_CHECK( !is_valid_name( "." ) );
|
||||
BOOST_CHECK( !is_valid_name( "-" ) );
|
||||
|
||||
BOOST_CHECK( !is_valid_name( "aa" ) );
|
||||
BOOST_CHECK( is_valid_name( "aa" ) );
|
||||
BOOST_CHECK( !is_valid_name( "aA" ) );
|
||||
BOOST_CHECK( !is_valid_name( "a0" ) );
|
||||
BOOST_CHECK( is_valid_name( "a0" ) );
|
||||
BOOST_CHECK( !is_valid_name( "a." ) );
|
||||
BOOST_CHECK( !is_valid_name( "a-" ) );
|
||||
|
||||
BOOST_CHECK( is_valid_name( "aaa" ) );
|
||||
BOOST_CHECK( !is_valid_name( "aAa" ) );
|
||||
BOOST_CHECK( is_valid_name( "a0a" ) );
|
||||
BOOST_CHECK( !is_valid_name( "a.a" ) );
|
||||
BOOST_CHECK( is_valid_name( "a.a" ) );
|
||||
BOOST_CHECK( is_valid_name( "a-a" ) );
|
||||
|
||||
BOOST_CHECK( is_valid_name( "aa0" ) );
|
||||
|
|
@ -99,9 +99,9 @@ BOOST_AUTO_TEST_CASE( valid_name_test )
|
|||
BOOST_CHECK( is_valid_name( "aaa.bbb.ccc" ) );
|
||||
|
||||
BOOST_CHECK( is_valid_name( "aaa--bbb--ccc" ) );
|
||||
BOOST_CHECK( !is_valid_name( "xn--sandmnnchen-p8a.de" ) );
|
||||
BOOST_CHECK( is_valid_name( "xn--sandmnnchen-p8a.de" ) );
|
||||
BOOST_CHECK( is_valid_name( "xn--sandmnnchen-p8a.dex" ) );
|
||||
BOOST_CHECK( !is_valid_name( "xn-sandmnnchen-p8a.de" ) );
|
||||
BOOST_CHECK( is_valid_name( "xn-sandmnnchen-p8a.de" ) );
|
||||
BOOST_CHECK( is_valid_name( "xn-sandmnnchen-p8a.dex" ) );
|
||||
|
||||
BOOST_CHECK( is_valid_name( "this-label-has-less-than-64-char.acters-63-to-be-really-precise" ) );
|
||||
|
|
|
|||
|
|
@ -20,65 +20,65 @@ namespace
|
|||
transfer.from = from;
|
||||
transfer.to = to;
|
||||
transfer.amount = amount;
|
||||
|
||||
|
||||
return transfer;
|
||||
}
|
||||
|
||||
|
||||
committee_member_create_operation make_committee_member_create_operation(const asset& fee, const account_id_type& member, const string& url)
|
||||
{
|
||||
committee_member_create_operation member_create_operation;
|
||||
member_create_operation.fee = fee;
|
||||
member_create_operation.committee_member_account = member;
|
||||
member_create_operation.url = url;
|
||||
|
||||
|
||||
return member_create_operation;
|
||||
}
|
||||
|
||||
|
||||
void create_proposal(database_fixture& fixture, const std::vector<operation>& operations)
|
||||
{
|
||||
signed_transaction transaction;
|
||||
set_expiration(fixture.db, transaction);
|
||||
|
||||
|
||||
transaction.operations = operations;
|
||||
|
||||
|
||||
fixture.db.create<proposal_object>([&](proposal_object& proposal)
|
||||
{
|
||||
proposal.proposed_transaction = transaction;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
signed_transaction make_signed_transaction_with_proposed_operation(database_fixture& fixture, const std::vector<operation>& operations)
|
||||
{
|
||||
proposal_create_operation operation_proposal;
|
||||
|
||||
|
||||
for (auto& operation: operations)
|
||||
{
|
||||
operation_proposal.proposed_ops.push_back(op_wrapper(operation));
|
||||
}
|
||||
|
||||
|
||||
signed_transaction transaction;
|
||||
set_expiration(fixture.db, transaction);
|
||||
transaction.operations = {operation_proposal};
|
||||
|
||||
|
||||
return transaction;
|
||||
}
|
||||
|
||||
|
||||
void push_proposal(database_fixture& fixture, const account_object& fee_payer, const std::vector<operation>& operations)
|
||||
{
|
||||
proposal_create_operation operation_proposal;
|
||||
operation_proposal.fee_paying_account = fee_payer.id;
|
||||
|
||||
|
||||
for (auto& operation: operations)
|
||||
{
|
||||
operation_proposal.proposed_ops.push_back(op_wrapper(operation));
|
||||
}
|
||||
|
||||
|
||||
operation_proposal.expiration_time = fixture.db.head_block_time() + fc::days(1);
|
||||
|
||||
|
||||
signed_transaction transaction;
|
||||
transaction.operations.push_back(operation_proposal);
|
||||
set_expiration( fixture.db, transaction );
|
||||
|
||||
|
||||
fixture.sign( transaction, fixture.init_account_priv_key );
|
||||
PUSH_TX( fixture.db, transaction );
|
||||
}
|
||||
|
|
@ -91,9 +91,9 @@ BOOST_AUTO_TEST_CASE( test_exception_throwing_for_the_same_operation_proposed_tw
|
|||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
||||
BOOST_CHECK_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE( check_passes_without_duplication )
|
|||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
||||
BOOST_CHECK_NO_THROW(db.check_tansaction_for_duplicated_operations(trx));
|
||||
}
|
||||
|
|
@ -125,9 +125,9 @@ BOOST_AUTO_TEST_CASE( check_passes_for_the_same_operation_with_different_assets
|
|||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501))});
|
||||
BOOST_CHECK_NO_THROW(db.check_tansaction_for_duplicated_operations(trx));
|
||||
}
|
||||
|
|
@ -143,9 +143,9 @@ BOOST_AUTO_TEST_CASE( check_fails_for_duplication_in_transaction_with_several_op
|
|||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501)),
|
||||
make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
||||
BOOST_CHECK_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
||||
|
|
@ -162,10 +162,10 @@ BOOST_AUTO_TEST_CASE( check_fails_for_duplicated_operation_in_existed_proposal_w
|
|||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(499)),
|
||||
make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501)),
|
||||
make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
||||
BOOST_CHECK_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
||||
|
|
@ -182,10 +182,10 @@ BOOST_AUTO_TEST_CASE( check_fails_for_duplicated_operation_in_existed_proposal_w
|
|||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(499)),
|
||||
make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
||||
BOOST_CHECK_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
||||
}
|
||||
|
|
@ -201,9 +201,9 @@ BOOST_AUTO_TEST_CASE( check_passes_for_different_operations_types )
|
|||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
||||
BOOST_CHECK_NO_THROW(db.check_tansaction_for_duplicated_operations(trx));
|
||||
}
|
||||
|
|
@ -219,7 +219,7 @@ BOOST_AUTO_TEST_CASE( check_fails_for_same_member_create_operations )
|
|||
try
|
||||
{
|
||||
create_proposal(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
||||
BOOST_CHECK_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ BOOST_AUTO_TEST_CASE( check_passes_for_different_member_create_operations )
|
|||
try
|
||||
{
|
||||
create_proposal(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_committee_member_create_operation(asset(1001), account_id_type(), "test url")});
|
||||
BOOST_CHECK_NO_THROW(db.check_tansaction_for_duplicated_operations(trx));
|
||||
}
|
||||
|
|
@ -251,16 +251,16 @@ BOOST_AUTO_TEST_CASE( check_failes_for_several_operations_of_mixed_type )
|
|||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500)),
|
||||
make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
||||
|
||||
|
||||
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501)), //duplicate
|
||||
make_committee_member_create_operation(asset(1001), account_id_type(), "test url")});
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501)), //duplicate
|
||||
make_committee_member_create_operation(asset(1002), account_id_type(), "test url")});
|
||||
|
||||
|
||||
BOOST_CHECK_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
||||
}
|
||||
catch( const fc::exception& e )
|
||||
|
|
@ -275,17 +275,17 @@ BOOST_AUTO_TEST_CASE( check_failes_for_duplicates_in_pending_transactions_list )
|
|||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
fc::ecc::private_key committee_key = init_account_priv_key;
|
||||
|
||||
|
||||
const account_object& moneyman = create_account("moneyman", init_account_pub_key);
|
||||
const asset_object& core = asset_id_type()(db);
|
||||
|
||||
|
||||
transfer(account_id_type()(db), moneyman, core.amount(1000000));
|
||||
|
||||
|
||||
auto duplicate = make_transfer_operation(alice.id, moneyman.get_id(), asset(100));
|
||||
push_proposal(*this, moneyman, {duplicate});
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {duplicate});
|
||||
BOOST_CHECK_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
||||
}
|
||||
|
|
@ -301,16 +301,16 @@ BOOST_AUTO_TEST_CASE( check_passes_for_no_duplicates_in_pending_transactions_lis
|
|||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
fc::ecc::private_key committee_key = init_account_priv_key;
|
||||
|
||||
|
||||
const account_object& moneyman = create_account("moneyman", init_account_pub_key);
|
||||
const asset_object& core = asset_id_type()(db);
|
||||
|
||||
|
||||
transfer(account_id_type()(db), moneyman, core.amount(1000000));
|
||||
|
||||
|
||||
push_proposal(*this, moneyman, {make_transfer_operation(alice.id, moneyman.get_id(), asset(100))});
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(alice.id, moneyman.get_id(), asset(101))});
|
||||
BOOST_CHECK_NO_THROW(db.check_tansaction_for_duplicated_operations(trx));
|
||||
}
|
||||
|
|
@ -321,23 +321,23 @@ BOOST_AUTO_TEST_CASE( check_passes_for_no_duplicates_in_pending_transactions_lis
|
|||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( check_fails_for_several_trаnsactions_with_duplicates_in_pending_list )
|
||||
BOOST_AUTO_TEST_CASE( check_fails_for_several_transactions_with_duplicates_in_pending_list )
|
||||
{
|
||||
try
|
||||
{
|
||||
ACTORS((alice))
|
||||
|
||||
|
||||
fc::ecc::private_key committee_key = init_account_priv_key;
|
||||
|
||||
|
||||
const account_object& moneyman = create_account("moneyman", init_account_pub_key);
|
||||
const asset_object& core = asset_id_type()(db);
|
||||
|
||||
|
||||
transfer(account_id_type()(db), moneyman, core.amount(1000000));
|
||||
|
||||
|
||||
auto duplicate = make_transfer_operation(alice.id, moneyman.get_id(), asset(100));
|
||||
push_proposal(*this, moneyman, {make_transfer_operation(alice.id, moneyman.get_id(), asset(101)),
|
||||
duplicate});
|
||||
|
||||
|
||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {duplicate,
|
||||
make_transfer_operation(alice.id, moneyman.get_id(), asset(102))});
|
||||
BOOST_CHECK_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
||||
|
|
|
|||
Loading…
Reference in a new issue