Skip to content

Commit

Permalink
Fix database_fixture::set_witness_props steemit#2830
Browse files Browse the repository at this point in the history
  • Loading branch information
theoreticalbts committed Aug 23, 2018
1 parent 3c4b978 commit f3ce7e9
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions tests/db_fixture/database_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,20 @@ void database_fixture::proxy( const string& account, const string& proxy )

void database_fixture::set_price_feed( const price& new_price )
{
flat_map< string, vector< char > > props;
props[ "sbd_exchange_rate" ] = fc::raw::pack_to_vector( new_price );
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[ "sbd_exchange_rate" ] = fc::raw::pack_to_vector( new_price );
op.props[ "key" ] = fc::raw::pack_to_vector( init_account_pub_key );

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

generate_blocks( STEEM_BLOCKS_PER_HOUR );

BOOST_REQUIRE(
#ifdef IS_TEST_NET
Expand All @@ -575,24 +585,32 @@ 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++ )
trx.clear();
for( size_t i=0; i<STEEM_MAX_WITNESSES; i++ )
{
witness_set_properties_operation op;
op.owner = STEEM_INIT_MINER_NAME + fc::to_string( i );
op.owner = STEEM_INIT_MINER_NAME + fc::to_string( i+1 );
op.props = props;

if( op.props.find( "key" ) == op.props.end() )
{
op.props[ "key" ] = fc::raw::pack_to_vector( init_account_pub_key );
}
if( props.find( "key" ) == props.end() )
op.props["key"] = fc::raw::pack_to_vector( 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.clear();
}

generate_blocks( STEEM_BLOCKS_PER_HOUR );
const witness_schedule_object* wso = &(db->get_witness_schedule_object());
uint32_t old_next_shuffle = wso->next_shuffle_block_num;

for( size_t i=0; i<2*STEEM_MAX_WITNESSES+1; i++ )
{
generate_block();
wso = &(db->get_witness_schedule_object());
if( wso->next_shuffle_block_num != old_next_shuffle )
return;
}
FC_ASSERT( false, "Couldn't apply properties in ${n} blocks", ("n", 2*STEEM_MAX_WITNESSES+1) );
}

const asset& database_fixture::get_balance( const string& account_name )const
Expand Down

0 comments on commit f3ce7e9

Please sign in to comment.