Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove transfer action and change tests that depend on it to use sett… #602

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions contracts/eden/include/eden.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ namespace eden

void donate(eosio::name payer, const eosio::asset& quantity);

void transfer(eosio::name to, const eosio::asset& quantity, const std::string& memo);

void genesis(std::string community,
eosio::symbol community_symbol,
eosio::asset minimum_donation,
Expand Down Expand Up @@ -195,7 +193,6 @@ namespace eden
"eden.gm"_n,
action(withdraw, owner, quantity, ricardian_contract(withdraw_ricardian)),
action(donate, owner, quantity),
action(transfer, to, quantity, memo),
action(fundtransfer, from, distribution_time, rank, to, amount, memo),
action(usertransfer, from, to, amount, memo),
action(genesis,
Expand Down
14 changes: 0 additions & 14 deletions contracts/eden/src/actions/accounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ namespace eden
}
}

void eden::transfer(eosio::name to, const eosio::asset& quantity, const std::string& memo)
{
require_auth(get_self());
accounts internal{get_self(), "owned"_n};
setup_distribution(get_self(), internal);
internal.sub_balance("master"_n, quantity);
accounts{get_self(), "outgoing"_n}.add_balance(to, quantity, false);
eosio::action{{get_self(), "active"_n},
token_contract,
"transfer"_n,
std::tuple(get_self(), to, quantity, memo)}
.send();
}

void eden::withdraw(eosio::name owner, const eosio::asset& quantity)
{
require_auth(owner);
Expand Down
12 changes: 11 additions & 1 deletion contracts/eden/tests/include/tester-base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,17 @@ struct eden_tester
}
else if (balance > amount)
{
eden_gm.act<actions::transfer>("eosio.token"_n, balance - amount, "memo");
#ifdef ENABLE_SET_TABLE_ROWS
eden_gm.act<actions::settablerows>(
"owned"_n, std::vector<eden::table_variant>{eden::account_v0{"master"_n, amount}});
eden_gm.act<actions::settablerows>(
"outgoing"_n,
std::vector<eden::table_variant>{eden::account_v0{"eosio.token"_n, balance - amount}});
eden_gm.act<token::actions::transfer>("eden.gm"_n, "eosio.token"_n, balance - amount,
"memo");
#else
eosio::check(false, "Cannot decrease balance");
#endif
}
}

Expand Down
35 changes: 15 additions & 20 deletions contracts/eden/tests/test-eden.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ struct CompareFile
for (auto& ttrace : history->traces)
{
std::visit(
[&](auto& ttrace)
{
[&](auto& ttrace) {
for (auto& atrace : ttrace.action_traces)
{
std::visit(
[&](auto& atrace)
{
[&](auto& atrace) {
if (atrace.receiver == "eosio.null"_n &&
atrace.act.name == "eden.events"_n)
{
Expand Down Expand Up @@ -412,8 +410,7 @@ TEST_CASE("induction")
"alice"_n, 4, eosio::sha256(hash_data.data(), hash_data.size() - 1)),
"Outdated endorsement");

auto endorse_all = [&]
{
auto endorse_all = [&] {
t.alice.act<actions::inductendors>("alice"_n, 4, induction_hash);
t.pip.act<actions::inductendors>("pip"_n, 4, induction_hash);
t.egeon.act<actions::inductendors>("egeon"_n, 4, induction_hash);
Expand Down Expand Up @@ -675,8 +672,7 @@ TEST_CASE("deposit and spend")

TEST_CASE("election config")
{
auto verify_cfg = [](const auto& config, uint16_t num_participants)
{
auto verify_cfg = [](const auto& config, uint16_t num_participants) {
INFO("participants: " << num_participants)
if (num_participants < 1)
{
Expand Down Expand Up @@ -1001,6 +997,8 @@ TEST_CASE("budget distribution underflow")
CHECK(t.get_budgets_by_period() == expected);
}

#ifdef ENABLE_SET_TABLE_ROWS

TEST_CASE("budget distribution min")
{
eden_tester t;
Expand All @@ -1023,6 +1021,8 @@ TEST_CASE("budget distribution min")
CHECK(t.get_budgets_by_period() == expected);
}

#endif

TEST_CASE("budget adjustment on resignation")
{
eden_tester t;
Expand Down Expand Up @@ -1124,20 +1124,14 @@ TEST_CASE("accounting")
t.genesis();
// should now have 30.0000 EOS, with a 90.0000 EOS deposit from alice
CHECK(get_token_balance("eden.gm"_n) == s2a("120.0000 EOS"));
expect(t.eden_gm.trace<actions::transfer>("eosio"_n, s2a("30.0001 EOS"), ""),
"insufficient balance");
t.eden_gm.act<actions::transfer>("eosio"_n, s2a("30.0000 EOS"), "");
CHECK(get_token_balance("eden.gm"_n) == s2a("90.0000 EOS"));
CHECK(get_token_balance("eosio"_n) == s2a("30.0000 EOS"));
}

TEST_CASE("pre-genesis balance")
{
eden_tester t{[&]
{
t.eosio_token.act<token::actions::transfer>("eosio.token"_n, "eden.gm"_n,
s2a("3.1415 EOS"), "");
}};
eden_tester t{[&] {
t.eosio_token.act<token::actions::transfer>("eosio.token"_n, "eden.gm"_n, s2a("3.1415 EOS"),
"");
}};
t.genesis();
CHECK(get_token_balance("eden.gm"_n) == t.get_total_balance());
}
Expand All @@ -1155,8 +1149,7 @@ TEST_CASE("account migration")
{
eden_tester t;
t.genesis();
auto sum_accounts = [](eden::account_table_type& table)
{
auto sum_accounts = [](eden::account_table_type& table) {
auto total = s2a("0.0000 EOS");
for (auto iter = table.begin(), end = table.end(); iter != end; ++iter)
{
Expand Down Expand Up @@ -1199,11 +1192,13 @@ TEST_CASE("account migration")
get_token_balance("eden.gm"_n));
}

#ifdef ENABLE_SET_TABLE_ROWS
t.set_balance(s2a("0.0000 EOS"));
t.alice.act<actions::withdraw>("alice"_n, get_eden_account("alice"_n)->balance());
t.eden_gm.act<token::actions::close>("eden.gm"_n, eosio::symbol("EOS", 4));
t.eden_gm.act<actions::unmigrate>();
t.eden_gm.act<actions::migrate>(100);
#endif
}

#ifdef ENABLE_SET_TABLE_ROWS
Expand Down