added test
This commit is contained in:
parent
2d388452d9
commit
ab4749d4ce
4 changed files with 1048 additions and 160 deletions
|
|
@ -33,11 +33,6 @@
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
bool is_manager( const database& db, const sport_id_type sport_id, const account_id_type manager_id )
|
|
||||||
{
|
|
||||||
return db.get(sport_id).manager == manager_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void_result sport_create_evaluator::do_evaluate(const sport_create_operation& op)
|
void_result sport_create_evaluator::do_evaluate(const sport_create_operation& op)
|
||||||
{ try {
|
{ try {
|
||||||
FC_ASSERT(db().head_block_time() >= HARDFORK_1000_TIME);
|
FC_ASSERT(db().head_block_time() >= HARDFORK_1000_TIME);
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit c1f098e14a9f1d4e31b539b63265ffe575240d10
|
Subproject commit c8c05254b1285fdfb1ea345da8342e4575426995
|
||||||
1047
tests/tests/manager_tests.cpp
Normal file
1047
tests/tests/manager_tests.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1816,160 +1816,6 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test )
|
||||||
// TODO: Test with non-core asset and Bob account
|
// TODO: Test with non-core asset and Bob account
|
||||||
} FC_LOG_AND_RETHROW() }
|
} FC_LOG_AND_RETHROW() }
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( manager_test )
|
|
||||||
{
|
|
||||||
#define PUSH_TX_D( TRX ) \
|
|
||||||
processed_transaction ptrx; \
|
|
||||||
try { \
|
|
||||||
ptx = PUSH_TX( db, TRX, ~0); \
|
|
||||||
} catch (fc::exception &e ) { \
|
|
||||||
edump( ( e.to_detail_string() ) ); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define EDUMP( MSG ) edump( ( MSG ) )
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ACTOR( alice );
|
|
||||||
database& db = db();
|
|
||||||
transfer( committee_account, alice_id, asset(10000) );
|
|
||||||
|
|
||||||
sport_id_type sport_id;
|
|
||||||
|
|
||||||
EDUMP( "1. create a sport with alice as manager" );
|
|
||||||
{
|
|
||||||
sport_create_operation scop;
|
|
||||||
scop.name = "TEST_SPORT";
|
|
||||||
scop.extensions.value.manager = alice_id;
|
|
||||||
// fee_paying_account is allways WITNESS_ACC
|
|
||||||
|
|
||||||
proposal_create_operation pcop = proposal_create_operation::commitee_proposal(
|
|
||||||
db.get_global_properties(),
|
|
||||||
db.head_block_time()
|
|
||||||
);
|
|
||||||
pcop.fee = asset(0);
|
|
||||||
pcop.fee_paying_account = alice_id;
|
|
||||||
pcop.review_period_seconds.reset();
|
|
||||||
fc::time_point_sec exp_time = db.head_block_time() + fc::seconds(10);
|
|
||||||
pcop.expiration_time = exp_time;
|
|
||||||
pcop.proposed_ops.push_back( scop );
|
|
||||||
|
|
||||||
signed_transaction trx;
|
|
||||||
set_expiration( db, trx );
|
|
||||||
trx.operations.push_back( pcop );
|
|
||||||
PUSH_TX_D( trx );
|
|
||||||
|
|
||||||
EDUMP( "1.1 Wait till proposal is executed" );
|
|
||||||
{
|
|
||||||
// TODO MAYBE THIS DOESNT WORK
|
|
||||||
// MAYBE 0
|
|
||||||
const auto proposal_id = ptrx.operation_results[1];
|
|
||||||
|
|
||||||
while( exp_time + fc::seconds(5) > db.head_block_time() ) {
|
|
||||||
const proposal_object& proposal_obj = db.get( proposal_id );
|
|
||||||
if( proposal_obj.is_authorized_to_execute(db) )
|
|
||||||
EDUMP( "READY TO EXECUTE" );
|
|
||||||
generate_blocks();
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& idx = db.get_index_type<sport_index>();
|
|
||||||
idx.inspect_all_objects( [&](const object& obj){
|
|
||||||
const sport_object& so = static_cast<const sport_obj&>(obj);
|
|
||||||
if(so.name == "TEST_SPORT"){
|
|
||||||
sport_id = so.id;
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EDUMP( "2. modify the sport with WITNESS_ACCOUNT" );
|
|
||||||
{
|
|
||||||
sport_update_operation suop;
|
|
||||||
suop.new_name = "NEW_NAME";
|
|
||||||
|
|
||||||
proposal_create_operation pcop = proposal_create_operation::commitee_proposal(
|
|
||||||
db.get_global_properties(),
|
|
||||||
db.head_block_time()
|
|
||||||
);
|
|
||||||
pcop.fee = asset(0);
|
|
||||||
pcop.fee_paying_account = alice_id;
|
|
||||||
pcop.review_period_seconds.reset();
|
|
||||||
fc::time_point_sec exp_time = db.head_block_time() + fc::seconds(10);
|
|
||||||
pcop.expiration_time = exp_time;
|
|
||||||
pcop.proposed_ops.push_back( scop );
|
|
||||||
|
|
||||||
signed_transaction trx;
|
|
||||||
set_expiration( db, trx );
|
|
||||||
trx.operations.push_back( pcop );
|
|
||||||
PUSH_TX_D( trx );
|
|
||||||
|
|
||||||
EDUMP( "2.1 Wait till proposal is executed" );
|
|
||||||
{
|
|
||||||
while( exp_time + fc::seconds(5) > db.head_block_time() ) {
|
|
||||||
generate_blocks();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sport_object sport_obj = db.get( sport_id );
|
|
||||||
BOOST_CHECK( sport_obj.name == "NEW_NAME");
|
|
||||||
}
|
|
||||||
|
|
||||||
// maybe every account can be passed when validating the transaction
|
|
||||||
// but should normally not be
|
|
||||||
EDUMP( "3. modify the sport with alice_acc" );
|
|
||||||
{
|
|
||||||
sport_update_operation suop;
|
|
||||||
suop.new_name = "BY_ALICE";
|
|
||||||
suop.extensions.value.manager = alice_id;
|
|
||||||
|
|
||||||
signed_transaction trx;
|
|
||||||
set_expiration( db, trx );
|
|
||||||
trx.operations.push_back( trx );
|
|
||||||
PUSH_TX_D( trx );
|
|
||||||
|
|
||||||
sport_object sport_obj = db.get( sport_id );
|
|
||||||
BOOST_CHECK( sport_obj.name == "BY_ALICE" );
|
|
||||||
}
|
|
||||||
|
|
||||||
EDUMP( "4. modify with a proposal but with manager set" );
|
|
||||||
{
|
|
||||||
sport_update_operation suop;
|
|
||||||
suop.new_name = "WITH_MAN";
|
|
||||||
suop.extensions.value.manager = alice_id;
|
|
||||||
|
|
||||||
proposal_create_operation pcop = proposal_create_operation::commitee_proposal(
|
|
||||||
db.get_global_properties(),
|
|
||||||
db.head_block_time()
|
|
||||||
);
|
|
||||||
pcop.fee = asset(0);
|
|
||||||
pcop.fee_paying_account = alice_id;
|
|
||||||
pcop.review_period_seconds.reset();
|
|
||||||
fc::time_point_sec exp_time = db.head_block_time() + fc::seconds(10);
|
|
||||||
pcop.expiration_time = exp_time;
|
|
||||||
pcop.proposed_ops.push_back( scop );
|
|
||||||
|
|
||||||
signed_transaction trx;
|
|
||||||
set_expiration( db, trx );
|
|
||||||
trx.operations.push_back( pcop );
|
|
||||||
PUSH_TX_D( trx );
|
|
||||||
|
|
||||||
EDUMP( "4.1 Wait till proposal is executed" );
|
|
||||||
{
|
|
||||||
while( exp_time + fc::seconds(5) > db.head_block_time() ) {
|
|
||||||
generate_blocks();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sport_object sport_obj = db.get( sport_id );
|
|
||||||
BOOST_CHECK( sport_obj.name == "WITH_MAN");
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch( fc::exception &e ) {
|
|
||||||
EDUMP( e.to_detail_string() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Write linear VBO tests
|
// TODO: Write linear VBO tests
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue