From fe2296e8391818ecb7af98c283eea8a812928a30 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Fri, 25 May 2018 16:53:47 -0400 Subject: [PATCH 1/3] system contract cleanup: remove special handling for eosio delegating/buying #3430 --- contracts/eosio.system/delegate_bandwidth.cpp | 20 ++++++++----------- unittests/eosio.system_tests.cpp | 2 -- unittests/eosio_system_tester.hpp | 3 --- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/contracts/eosio.system/delegate_bandwidth.cpp b/contracts/eosio.system/delegate_bandwidth.cpp index a292f8552eb..a66cc181103 100644 --- a/contracts/eosio.system/delegate_bandwidth.cpp +++ b/contracts/eosio.system/delegate_bandwidth.cpp @@ -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") } ); } @@ -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") } ); } } diff --git a/unittests/eosio.system_tests.cpp b/unittests/eosio.system_tests.cpp index bb41e3eda40..5fdf47904f8 100644 --- a/unittests/eosio.system_tests.cpp +++ b/unittests/eosio.system_tests.cpp @@ -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" ); @@ -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" ); diff --git a/unittests/eosio_system_tester.hpp b/unittests/eosio_system_tester.hpp index ea676617d40..d6b24629dfa 100644 --- a/unittests/eosio_system_tester.hpp +++ b/unittests/eosio_system_tester.hpp @@ -81,9 +81,6 @@ class eosio_system_tester : public TESTER { create_account_with_resources( N(alice1111111), config::system_account_name, core_from_string("1.0000"), false ); 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")); } From ec7151cd300b86980e3d1d8bdb83904a2b59cc70 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Fri, 25 May 2018 17:06:40 -0400 Subject: [PATCH 2/3] system contract cleanup: fixed and put back check for eosio balance #3430 --- unittests/eosio_system_tester.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unittests/eosio_system_tester.hpp b/unittests/eosio_system_tester.hpp index d6b24629dfa..f1578526694 100644 --- a/unittests/eosio_system_tester.hpp +++ b/unittests/eosio_system_tester.hpp @@ -81,6 +81,8 @@ class eosio_system_tester : public TESTER { create_account_with_resources( N(alice1111111), config::system_account_name, core_from_string("1.0000"), false ); 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") + get_balance("eosio.ram") ); } From 0770df787deedd57c7925c2e9d06eb821e8fcfbc Mon Sep 17 00:00:00 2001 From: arhag Date: Fri, 25 May 2018 18:29:18 -0400 Subject: [PATCH 3/3] fix eosio_msig_tests #3430 --- unittests/multisig_tests.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/unittests/multisig_tests.cpp b/unittests/multisig_tests.cpp index d2044ef634c..50da46df88d 100644 --- a/unittests/multisig_tests.cpp +++ b/unittests/multisig_tests.cpp @@ -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 ); @@ -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 perm = { { N(alice), config::active_name }, { N(bob), config::active_name }, {N(carol), config::active_name} }; @@ -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 perm = { { N(alice), config::active_name }, { N(bob), config::active_name }, {N(carol), config::active_name}, {N(apple), config::active_name}};