Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
use lower_bound to find top open bid #21
Browse files Browse the repository at this point in the history
  • Loading branch information
moskvanaft committed Jul 19, 2018
1 parent 385c670 commit b30a7b3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion eosio.system/src/producer_pay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace eosiosystem {
if( (timestamp.slot - _gstate.last_name_close.slot) > blocks_per_day ) {
name_bid_table bids(_self,_self);
auto idx = bids.get_index<N(highbid)>();
auto highest = idx.begin();
auto highest = idx.lower_bound( std::numeric_limits<uint64_t>::max()/2 );
if( highest != idx.end() &&
highest->high_bid > 0 &&
highest->last_bid_time < (current_time() - useconds_per_day) &&
Expand Down
1 change: 1 addition & 0 deletions tests/eosio.system_tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ class eosio_system_tester : public TESTER {
trx.sign( get_private_key( config::system_account_name, "active" ), control->get_chain_id() );
trx.sign( get_private_key( N(producer1111), "active" ), control->get_chain_id() );
push_transaction( trx );
produce_block();
}
}

Expand Down
15 changes: 15 additions & 0 deletions tests/eosio.system_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2367,6 +2367,21 @@ BOOST_FIXTURE_TEST_CASE( multiple_namebids, eosio_system_tester ) try {

} FC_LOG_AND_RETHROW()

BOOST_FIXTURE_TEST_CASE( namebid_pending_winner, eosio_system_tester ) try {
cross_15_percent_threshold();
produce_block( fc::hours(14*24) ); //wait 14 day for name auction activation
transfer( config::system_account_name, N(alice1111111), core_from_string("10000.0000") );
transfer( config::system_account_name, N(bob111111111), core_from_string("10000.0000") );

BOOST_REQUIRE_EQUAL( success(), bidname( "alice1111111", "prefa", core_from_string( "50.0000" ) ));
BOOST_REQUIRE_EQUAL( success(), bidname( "bob111111111", "prefb", core_from_string( "30.0000" ) ));
produce_block( fc::hours(100) ); //should close "perfa"
produce_block( fc::hours(100) ); //should close "perfb"

//despite "perfa" account hasn't been created, we should be able to create "perfb" account
create_account_with_resources( N(prefb), N(bob111111111) );
} FC_LOG_AND_RETHROW()

BOOST_FIXTURE_TEST_CASE( vote_producers_in_and_out, eosio_system_tester ) try {

const asset net = core_from_string("80.0000");
Expand Down

0 comments on commit b30a7b3

Please sign in to comment.