提交 cd9ff2de 编写于 作者: A arhag

better name bidding assert messages and cleanup eosio.system tests

上级 2691b555
......@@ -117,7 +117,7 @@ namespace eosiosystem {
} else {
eosio_assert( current->high_bid > 0, "this auction has already closed" );
eosio_assert( bid.amount - current->high_bid > (current->high_bid / 10), "must increase bid by 10%" );
eosio_assert( current->high_bidder != bidder, "account is already high bidder" );
eosio_assert( current->high_bidder != bidder, "account is already highest bidder" );
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio.names),N(active)},
{ N(eosio.names), current->high_bidder, asset(current->high_bid),
......@@ -135,13 +135,10 @@ namespace eosiosystem {
* Called after a new account is created. This code enforces resource-limits rules
* for new accounts as well as new account naming conventions.
*
* 1. accounts cannot contain '.' symbols which forces all acccounts to be 12
* characters long without '.' until a future account auction process is implemented
* which prevents name squatting.
* Account names containing '.' symbols must have a suffix equal to the name of the creator.
* This allows users who buy a premium name (shorter than 12 characters with no dots) to be the only ones
* who can create accounts with the creator's name as a suffix.
*
* 2. new accounts must stake a minimal number of tokens (as set in system parameters)
* therefore, this method will execute an inline buyram from receiver for newacnt in
* an amount equal to the current new account creation fee.
*/
void native::newaccount( account_name creator,
account_name newact
......@@ -157,13 +154,13 @@ namespace eosiosystem {
has_dot |= !(tmp & 0x1f);
tmp >>= 5;
}
if( has_dot ) { // or is less than 12 characters
auto suffix = eosio::name_suffix(newact);
if( has_dot ) {
if( suffix == newact ) {
name_bid_table bids(_self,_self);
auto current = bids.find( newact );
eosio_assert( current != bids.end(), "no active bid for name" );
eosio_assert( current->high_bidder == creator, "only high bidder can claim" );
eosio_assert( current->high_bidder == creator, "only highest bidder can claim" );
eosio_assert( current->high_bid < 0, "auction for name is not closed yet" );
bids.erase( current );
} else {
......
......@@ -2229,22 +2229,24 @@ BOOST_FIXTURE_TEST_CASE( buyname, eosio_system_tester ) try {
produce_block( fc::days(14) );
produce_block();
BOOST_REQUIRE_THROW( create_accounts_with_resources( { N(fail) }, N(dan) ), fc::exception ); // dan shouldn't be able to create fail
BOOST_REQUIRE_EXCEPTION( create_accounts_with_resources( { N(fail) }, N(dan) ), // dan shouldn't be able to create fail
eosio_assert_message_exception, eosio_assert_message_is( "no active bid for name" ) );
bidname( "dan", "nofail", core_from_string( "1.0000" ) );
BOOST_REQUIRE_EQUAL( "assertion failure with message: must increase bid by 10%", bidname( "sam", "nofail", core_from_string( "1.0000" ) )); // didn't increase bid by 10%
BOOST_REQUIRE_EQUAL( success(), bidname( "sam", "nofail", core_from_string( "2.0000" ) )); // didn't increase bid by 10%
produce_block( fc::days(1) );
produce_block();
BOOST_REQUIRE_THROW( create_accounts_with_resources( { N(nofail) }, N(dan) ), fc::exception); // dan shoudn't be able to do this, sam won
BOOST_REQUIRE_EXCEPTION( create_accounts_with_resources( { N(nofail) }, N(dan) ), // dan shoudn't be able to do this, sam won
eosio_assert_message_exception, eosio_assert_message_is( "only highest bidder can claim" ) );
//wlog( "verify sam can create nofail" );
create_accounts_with_resources( { N(nofail) }, N(sam) ); // sam should be able to do this, he won the bid
//wlog( "verify nofail can create test.nofail" );
transfer( "eosio", "nofail", core_from_string( "1000.0000" ) );
create_accounts_with_resources( { N(test.nofail) }, N(nofail) ); // only nofail can create test.nofail
//wlog( "verify dan cannot create test.fail" );
BOOST_REQUIRE_THROW( create_accounts_with_resources( { N(test.fail) }, N(dan) ), fc::exception ); // dan shouldn't be able to do this
BOOST_REQUIRE_EXCEPTION( create_accounts_with_resources( { N(test.fail) }, N(dan) ), // dan shouldn't be able to do this
eosio_assert_message_exception, eosio_assert_message_is( "only suffix may create this account" ) );
create_accounts_with_resources( { N(goodgoodgood) }, N(dan) ); /// 12 char names should succeed
} FC_LOG_AND_RETHROW()
......@@ -2290,7 +2292,7 @@ BOOST_FIXTURE_TEST_CASE( multiple_namebids, eosio_system_tester ) try {
bidname( "carl", "prefe", core_from_string("1.0000") );
BOOST_REQUIRE_EQUAL( core_from_string( "9998.0000" ), get_balance("carl") );
BOOST_REQUIRE_EQUAL( error("assertion failure with message: account is already high bidder"),
BOOST_REQUIRE_EQUAL( error("assertion failure with message: account is already highest bidder"),
bidname( "bob", "prefb", core_from_string("1.1001") ) );
BOOST_REQUIRE_EQUAL( error("assertion failure with message: must increase bid by 10%"),
bidname( "alice", "prefb", core_from_string("1.0999") ) );
......@@ -2379,9 +2381,9 @@ BOOST_FIXTURE_TEST_CASE( multiple_namebids, eosio_system_tester ) try {
produce_blocks(2);
// bid for prefb has closed, only highest bidder can claim
BOOST_REQUIRE_EXCEPTION( create_account_with_resources( N(prefb), N(alice) ),
fc::exception, fc_assert_exception_message_is("only high bidder can claim") );
eosio_assert_message_exception, eosio_assert_message_is( "only highest bidder can claim" ) );
BOOST_REQUIRE_EXCEPTION( create_account_with_resources( N(prefb), N(carl) ),
fc::exception, fc_assert_exception_message_is("only high bidder can claim") );
eosio_assert_message_exception, eosio_assert_message_is( "only highest bidder can claim" ) );
create_account_with_resources( N(prefb), N(eve) );
BOOST_REQUIRE_EXCEPTION( create_account_with_resources( N(prefe), N(carl) ),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册