Skip to content

Commit

Permalink
Update unit tests to use witness_set_props_op steemit#1765
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandeberg committed Dec 18, 2017
1 parent 9429748 commit 4986179
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
44 changes: 28 additions & 16 deletions tests/db_fixture/database_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,21 +532,11 @@ void database_fixture::proxy( const string& account, const string& proxy )

void database_fixture::set_price_feed( const price& new_price )
{
try
{
for ( int i = 1; i < 8; i++ )
{
feed_publish_operation op;
op.publisher = STEEM_INIT_MINER_NAME + fc::to_string( i );
op.exchange_rate = new_price;
trx.operations.push_back( op );
trx.set_expiration( db->head_block_time() + STEEM_MAX_TIME_UNTIL_EXPIRATION );
db->push_transaction( trx, ~0 );
trx.operations.clear();
}
} FC_CAPTURE_AND_RETHROW( (new_price) )
flat_map< string, vector< char > > props;
props[ "sbd_exchange_rate" ] = fc::raw::pack( new_price );

set_witness_props( props );

generate_blocks( STEEM_BLOCKS_PER_HOUR );
BOOST_REQUIRE(
#ifdef IS_TEST_NET
!db->skip_price_feed_limit_check ||
Expand All @@ -555,6 +545,28 @@ void database_fixture::set_price_feed( const price& new_price )
);
}

void database_fixture::set_witness_props( const flat_map< string, vector< char > >& props )
{
for( size_t i = 1; i < 8; i++ )
{
witness_set_properties_operation op;
op.owner = STEEM_INIT_MINER_NAME + fc::to_string( i );
op.props = props;

if( op.props.find( "key" ) == op.props.end() )
{
op.props[ "key" ] = fc::raw::pack( init_account_pub_key );
}

trx.operations.push_back( op );
trx.set_expiration( db->head_block_time() + STEEM_MAX_TIME_UNTIL_EXPIRATION );
db->push_transaction( trx, ~0 );
trx.operations.clear();
}

generate_blocks( STEEM_BLOCKS_PER_HOUR );
}

const asset& database_fixture::get_balance( const string& account_name )const
{
return db->get_account( account_name ).balance;
Expand Down Expand Up @@ -613,7 +625,7 @@ asset_symbol_type smt_database_fixture::create_smt( signed_transaction& tx, cons

set_price_feed( price( ASSET( "1.000 TBD" ), ASSET( "1.000 TESTS" ) ) );
convert( account_name, ASSET( "5000.000 TESTS" ) );

// The list of available nais is not dependent on SMT desired precision (token_decimal_places).
auto available_nais = db->get_smt_next_identifier();
FC_ASSERT( available_nais.size() > 0, "No available nai returned by get_smt_next_identifier." );
Expand All @@ -630,7 +642,7 @@ asset_symbol_type smt_database_fixture::create_smt( signed_transaction& tx, cons

db->push_transaction( tx, 0 );

generate_block();
generate_block();
}
FC_LOG_AND_RETHROW();

Expand Down
1 change: 1 addition & 0 deletions tests/db_fixture/database_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ struct database_fixture {
void vest( const string& account, const asset& amount );
void proxy( const string& account, const string& proxy );
void set_price_feed( const price& new_price );
void set_witness_props( const flat_map< string, vector< char > >& new_props );
const asset& get_balance( const string& account_name )const;
void sign( signed_transaction& trx, const fc::ecc::private_key& key );

Expand Down

0 comments on commit 4986179

Please sign in to comment.