Skip to content

Commit

Permalink
Merge pull request EOSIO#3431 from EOSIO/system-remove-eosio-specialc…
Browse files Browse the repository at this point in the history
…ases

system contract cleanup: remove special handling for eosio
  • Loading branch information
Greg Lee authored May 25, 2018
2 parents a1e0226 + 7358715 commit e528e5f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
20 changes: 8 additions & 12 deletions contracts/eosio.system/delegate_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,10 @@ namespace eosiosystem {
auto quant_after_fee = quant;
quant_after_fee.amount -= fee.amount;

if( payer != N(eosio) ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
{ payer, N(eosio.ram), quant_after_fee, std::string("buy ram") } );
}
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
{ payer, N(eosio.ram), quant_after_fee, std::string("buy ram") } );

if( payer != N(eosio) && fee.amount > 0 ) {
if( fee.amount > 0 ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
{ payer, N(eosio.ramfee), fee, std::string("ram fee") } );
}
Expand Down Expand Up @@ -182,14 +180,12 @@ namespace eosiosystem {
});
set_resource_limits( res_itr->owner, res_itr->ram_bytes, res_itr->net_weight.amount, res_itr->cpu_weight.amount );

if( N(eosio) != account ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio.ram),N(active)},
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio.ram),N(active)},
{ N(eosio.ram), account, asset(tokens_out), std::string("sell ram") } );
auto fee = tokens_out.amount / 200;
if( fee > 0 ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {account,N(active)},
{ account, N(eosio.ramfee), asset(fee), std::string("sell ram fee") } );
}
auto fee = tokens_out.amount / 200;
if( fee > 0 ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {account,N(active)},
{ account, N(eosio.ramfee), asset(fee), std::string("sell ram fee") } );
}
}

Expand Down
2 changes: 0 additions & 2 deletions unittests/eosio.system_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ BOOST_AUTO_TEST_SUITE(eosio_system_tests)

BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try {

BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance( "eosio" ) + get_balance( "eosio.ramfee" ) + get_balance( "eosio.stake" ) );
BOOST_REQUIRE_EQUAL( core_from_string("0.0000"), get_balance( "alice1111111" ) );

transfer( "eosio", "alice1111111", core_from_string("1000.0000"), "eosio" );
Expand Down Expand Up @@ -119,7 +118,6 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try {

BOOST_FIXTURE_TEST_CASE( stake_unstake, eosio_system_tester ) try {

BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance( "eosio" ) + get_balance( "eosio.ramfee" ) + get_balance( "eosio.stake" ) );
BOOST_REQUIRE_EQUAL( core_from_string("0.0000"), get_balance( "alice1111111" ) );
transfer( "eosio", "alice1111111", core_from_string("1000.0000"), "eosio" );

Expand Down
3 changes: 1 addition & 2 deletions unittests/eosio_system_tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ class eosio_system_tester : public TESTER {
create_account_with_resources( N(bob111111111), config::system_account_name, core_from_string("0.4500"), false );
create_account_with_resources( N(carol1111111), config::system_account_name, core_from_string("1.0000"), false );


BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance("eosio") + get_balance("eosio.ramfee") + get_balance("eosio.stake"));
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance("eosio") + get_balance("eosio.ramfee") + get_balance("eosio.stake") + get_balance("eosio.ram") );
}


Expand Down
9 changes: 6 additions & 3 deletions unittests/multisig_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )

create_currency( N(eosio.token), config::system_account_name, core_from_string("10000000000.0000") );
issue(config::system_account_name, core_from_string("1000000000.0000"));
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance("eosio") + get_balance("eosio.ramfee") + get_balance("eosio.stake") );
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"),
get_balance("eosio") + get_balance("eosio.ramfee") + get_balance("eosio.stake") + get_balance("eosio.ram") );

set_code( config::system_account_name, eosio_system_wast );
set_abi( config::system_account_name, eosio_system_abi );
Expand All @@ -431,7 +432,8 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
create_account_with_resources( N(bob111111111), N(eosio), core_from_string("0.4500"), false );
create_account_with_resources( N(carol1111111), N(eosio), core_from_string("1.0000"), false );

BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance("eosio") + get_balance("eosio.ramfee") + get_balance("eosio.stake") );
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"),
get_balance("eosio") + get_balance("eosio.ramfee") + get_balance("eosio.stake") + get_balance("eosio.ram") );

vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name },
{N(carol), config::active_name} };
Expand Down Expand Up @@ -541,7 +543,8 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
create_account_with_resources( N(bob111111111), N(eosio), core_from_string("0.4500"), false );
create_account_with_resources( N(carol1111111), N(eosio), core_from_string("1.0000"), false );

BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance("eosio") + get_balance("eosio.ramfee") + get_balance("eosio.stake") );
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"),
get_balance("eosio") + get_balance("eosio.ramfee") + get_balance("eosio.stake") + get_balance("eosio.ram") );

vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name },
{N(carol), config::active_name}, {N(apple), config::active_name}};
Expand Down

0 comments on commit e528e5f

Please sign in to comment.