From 391e65b650574b09b7c650140d7c41ae0437b962 Mon Sep 17 00:00:00 2001 From: Leister Francisco Alvarez Campos Date: Thu, 29 Jun 2023 21:02:00 -0600 Subject: [PATCH] chore(contract): comment the logic to issue sbt from the smart contract --- contracts/eden/src/actions/elect.cpp | 4 +- contracts/eden/tests/test-eden.cpp | 338 +++++++++++++-------------- 2 files changed, 171 insertions(+), 171 deletions(-) diff --git a/contracts/eden/src/actions/elect.cpp b/contracts/eden/src/actions/elect.cpp index 87eab5144..053dc7059 100644 --- a/contracts/eden/src/actions/elect.cpp +++ b/contracts/eden/src/actions/elect.cpp @@ -68,8 +68,8 @@ namespace eden current_session.value.require_auth(voter); elections elections(get_self()); elections.vote(round, voter, candidate); - badges badges(get_self()); - badges.create_badge(voter); + // badges badges(get_self()); + // badges.create_badge(voter); } void eden::electvideo(const eosio::not_in_abi& current_session, diff --git a/contracts/eden/tests/test-eden.cpp b/contracts/eden/tests/test-eden.cpp index 796009ea8..d401b1dbd 100644 --- a/contracts/eden/tests/test-eden.cpp +++ b/contracts/eden/tests/test-eden.cpp @@ -1284,175 +1284,175 @@ TEST_CASE("bylaws") } } -TEST_CASE("distribute sbt on vote") -{ - constexpr std::size_t num_accounts = 12; - eden_tester t; - t.genesis(); - t.eden_gm.act(s2t("2020-07-04T15:30:00.000")); - auto test_accounts = make_names(num_accounts - 3); - t.create_accounts(test_accounts); - - for (auto account : test_accounts) - { - t.chain.start_block(); - t.alice.act(42, "alice"_n, account, std::vector{"pip"_n, "egeon"_n}); - t.finish_induction(42, "alice"_n, account, {"pip"_n, "egeon"_n}); - } - t.electdonate_all(); - - t.skip_to("2020-07-03T15:30:00.000"); - t.electseed(eosio::time_point_sec(0x5f009260)); - t.skip_to("2020-07-04T15:30:00.000"); - t.setup_election(); - - uint8_t round = 0; - t.generic_group_vote(t.get_current_groups(), round++); - - std::vector expected{"edenmember11"_n, "alice"_n, "egeon"_n, - "edenmember1c"_n, "edenmember1b"_n, "edenmember1d"_n, - "edenmember1a"_n, "edenmember15"_n, "edenmember13"_n, - "edenmember14"_n, "edenmember12"_n, "pip"_n}; - CHECK(t.get_badges() == expected); - - t.eden_gm.act(2); - expected.erase(expected.begin(), expected.begin() + 2); - - CHECK(t.get_badges() == expected); - - t.eden_gm.act(100); - - CHECK(t.get_badges() == std::vector{}); - expect(t.eden_gm.trace(1), "Nothing to do"); -} - -TEST_CASE("distribute sbt in the second election") -{ - constexpr std::size_t num_accounts = 12; - eden_tester t; - t.genesis(); - t.eden_gm.act(s2t("2020-07-04T15:30:00.000")); - auto test_accounts = make_names(num_accounts - 3); - t.create_accounts(test_accounts); - - for (auto account : test_accounts) - { - t.chain.start_block(); - t.alice.act(42, "alice"_n, account, std::vector{"pip"_n, "egeon"_n}); - t.finish_induction(42, "alice"_n, account, {"pip"_n, "egeon"_n}); - } - - t.run_election(); - - std::vector expected{"alice"_n, "edenmember14"_n, "egeon"_n, - "edenmember13"_n, "edenmember1d"_n, "edenmember15"_n, - "edenmember11"_n, "edenmember12"_n, "edenmember1b"_n, - "pip"_n, "edenmember1a"_n, "edenmember1c"_n}; - CHECK(t.get_badges() == expected); - - std::vector expected_extended{"edenmember1a"_n, "edenmember1d"_n, "edenmember12"_n, - "edenmember15"_n, "alice"_n, "pip"_n, - "edenmember13"_n, "edenmember11"_n, "edenmember14"_n, - "egeon"_n, "edenmember1c"_n, "edenmember1b"_n}; - expected.insert(expected.end(), expected_extended.begin(), expected_extended.end()); - - t.run_election(); - - CHECK(t.get_badges() == expected); -} - -TEST_CASE("cannot distribute sbt if round has not finished") -{ - constexpr std::size_t num_accounts = 12; - eden_tester t; - t.genesis(); - t.eden_gm.act(s2t("2020-07-04T15:30:00.000")); - auto test_accounts = make_names(num_accounts - 3); - t.create_accounts(test_accounts); - - for (auto account : test_accounts) - { - t.chain.start_block(); - t.alice.act(42, "alice"_n, account, std::vector{"pip"_n, "egeon"_n}); - t.finish_induction(42, "alice"_n, account, {"pip"_n, "egeon"_n}); - } - t.electdonate_all(); - - t.skip_to("2020-07-03T15:30:00.000"); - t.electseed(eosio::time_point_sec(0x5f009260)); - t.skip_to("2020-07-04T15:30:00.000"); - t.setup_election(); - - uint8_t round = 0; - /* - GROUPS INFO - - GROUP_ID: 0 - MEMBER: edenmember11 - MEMBER: alice - MEMBER: egeon - MEMBER: edenmember1c - - GROUP_ID: 1 - MEMBER: edenmember1b - MEMBER: edenmember1d - MEMBER: edenmember1a - MEMBER: edenmember15 - - GROUP_ID: 2 - MEMBER: edenmember13 - MEMBER: edenmember14 - MEMBER: edenmember12 - MEMBER: pip - */ - - // GROUP_ID: 0 - t.skip_to("2020-07-04T15:35:00.000"); - t.chain.as("edenmember11"_n).act(round, "edenmember11"_n, "alice"_n); - t.alice.act(round, "alice"_n, "alice"_n); - t.egeon.act(round, "egeon"_n, "alice"_n); - t.chain.as("edenmember1c"_n).act(round, "edenmember1c"_n, "alice"_n); - - expect(t.eden_gm.trace(100), "Nothing to do"); - - // GROUP_ID: 1 - t.skip_to("2020-07-04T15:55:00.000"); - t.chain.as("edenmember1b"_n).act(round, "edenmember1b"_n, "edenmember1b"_n); - t.chain.as("edenmember1d"_n).act(round, "edenmember1d"_n, "edenmember1b"_n); - t.chain.as("edenmember1a"_n).act(round, "edenmember1a"_n, "edenmember1b"_n); - t.chain.as("edenmember15"_n).act(round, "edenmember15"_n, "edenmember1b"_n); - - expect(t.eden_gm.trace(100), "Nothing to do"); - - // GROUP_ID: 2 - t.skip_to("2020-07-04T16:15:00.000"); - t.chain.as("edenmember13"_n).act(round, "edenmember13"_n, "edenmember13"_n); - t.chain.as("edenmember14"_n).act(round, "edenmember14"_n, "edenmember13"_n); - t.chain.as("edenmember12"_n).act(round, "edenmember12"_n, "edenmember13"_n); - // can only get 1 sbt even though there are multiple votes - t.pip.act(round, "pip"_n, "edenmember13"_n); - t.chain.start_block(); - t.pip.act(round, "pip"_n, "edenmember14"_n); - t.chain.start_block(); - t.pip.act(round, "pip"_n, "edenmember12"_n); - t.chain.start_block(); - t.pip.act(round, "pip"_n, "edenmember13"_n); - - expect(t.eden_gm.trace(100), "Nothing to do"); - - // finish election - t.skip_to("2020-07-04T16:30:00.000"); - t.alice.act(256); - t.eden_gm.act(10); - - std::vector expected{"edenmember12"_n, "pip"_n}; - - CHECK(t.get_badges() == expected); - - t.eden_gm.act(2); - - CHECK(t.get_badges() == std::vector{}); -} +// TEST_CASE("distribute sbt on vote") +// { +// constexpr std::size_t num_accounts = 12; +// eden_tester t; +// t.genesis(); +// t.eden_gm.act(s2t("2020-07-04T15:30:00.000")); +// auto test_accounts = make_names(num_accounts - 3); +// t.create_accounts(test_accounts); + +// for (auto account : test_accounts) +// { +// t.chain.start_block(); +// t.alice.act(42, "alice"_n, account, std::vector{"pip"_n, "egeon"_n}); +// t.finish_induction(42, "alice"_n, account, {"pip"_n, "egeon"_n}); +// } +// t.electdonate_all(); + +// t.skip_to("2020-07-03T15:30:00.000"); +// t.electseed(eosio::time_point_sec(0x5f009260)); +// t.skip_to("2020-07-04T15:30:00.000"); +// t.setup_election(); + +// uint8_t round = 0; +// t.generic_group_vote(t.get_current_groups(), round++); + +// std::vector expected{"edenmember11"_n, "alice"_n, "egeon"_n, +// "edenmember1c"_n, "edenmember1b"_n, "edenmember1d"_n, +// "edenmember1a"_n, "edenmember15"_n, "edenmember13"_n, +// "edenmember14"_n, "edenmember12"_n, "pip"_n}; +// CHECK(t.get_badges() == expected); + +// t.eden_gm.act(2); +// expected.erase(expected.begin(), expected.begin() + 2); + +// CHECK(t.get_badges() == expected); + +// t.eden_gm.act(100); + +// CHECK(t.get_badges() == std::vector{}); +// expect(t.eden_gm.trace(1), "Nothing to do"); +// } + +// TEST_CASE("distribute sbt in the second election") +// { +// constexpr std::size_t num_accounts = 12; +// eden_tester t; +// t.genesis(); +// t.eden_gm.act(s2t("2020-07-04T15:30:00.000")); +// auto test_accounts = make_names(num_accounts - 3); +// t.create_accounts(test_accounts); + +// for (auto account : test_accounts) +// { +// t.chain.start_block(); +// t.alice.act(42, "alice"_n, account, std::vector{"pip"_n, "egeon"_n}); +// t.finish_induction(42, "alice"_n, account, {"pip"_n, "egeon"_n}); +// } + +// t.run_election(); + +// std::vector expected{"alice"_n, "edenmember14"_n, "egeon"_n, +// "edenmember13"_n, "edenmember1d"_n, "edenmember15"_n, +// "edenmember11"_n, "edenmember12"_n, "edenmember1b"_n, +// "pip"_n, "edenmember1a"_n, "edenmember1c"_n}; +// CHECK(t.get_badges() == expected); + +// std::vector expected_extended{"edenmember1a"_n, "edenmember1d"_n, "edenmember12"_n, +// "edenmember15"_n, "alice"_n, "pip"_n, +// "edenmember13"_n, "edenmember11"_n, "edenmember14"_n, +// "egeon"_n, "edenmember1c"_n, "edenmember1b"_n}; +// expected.insert(expected.end(), expected_extended.begin(), expected_extended.end()); + +// t.run_election(); + +// CHECK(t.get_badges() == expected); +// } + +// TEST_CASE("cannot distribute sbt if round has not finished") +// { +// constexpr std::size_t num_accounts = 12; +// eden_tester t; +// t.genesis(); +// t.eden_gm.act(s2t("2020-07-04T15:30:00.000")); +// auto test_accounts = make_names(num_accounts - 3); +// t.create_accounts(test_accounts); + +// for (auto account : test_accounts) +// { +// t.chain.start_block(); +// t.alice.act(42, "alice"_n, account, std::vector{"pip"_n, "egeon"_n}); +// t.finish_induction(42, "alice"_n, account, {"pip"_n, "egeon"_n}); +// } +// t.electdonate_all(); + +// t.skip_to("2020-07-03T15:30:00.000"); +// t.electseed(eosio::time_point_sec(0x5f009260)); +// t.skip_to("2020-07-04T15:30:00.000"); +// t.setup_election(); + +// uint8_t round = 0; +// /* +// GROUPS INFO + +// GROUP_ID: 0 +// MEMBER: edenmember11 +// MEMBER: alice +// MEMBER: egeon +// MEMBER: edenmember1c + +// GROUP_ID: 1 +// MEMBER: edenmember1b +// MEMBER: edenmember1d +// MEMBER: edenmember1a +// MEMBER: edenmember15 + +// GROUP_ID: 2 +// MEMBER: edenmember13 +// MEMBER: edenmember14 +// MEMBER: edenmember12 +// MEMBER: pip +// */ + +// // GROUP_ID: 0 +// t.skip_to("2020-07-04T15:35:00.000"); +// t.chain.as("edenmember11"_n).act(round, "edenmember11"_n, "alice"_n); +// t.alice.act(round, "alice"_n, "alice"_n); +// t.egeon.act(round, "egeon"_n, "alice"_n); +// t.chain.as("edenmember1c"_n).act(round, "edenmember1c"_n, "alice"_n); + +// expect(t.eden_gm.trace(100), "Nothing to do"); + +// // GROUP_ID: 1 +// t.skip_to("2020-07-04T15:55:00.000"); +// t.chain.as("edenmember1b"_n).act(round, "edenmember1b"_n, "edenmember1b"_n); +// t.chain.as("edenmember1d"_n).act(round, "edenmember1d"_n, "edenmember1b"_n); +// t.chain.as("edenmember1a"_n).act(round, "edenmember1a"_n, "edenmember1b"_n); +// t.chain.as("edenmember15"_n).act(round, "edenmember15"_n, "edenmember1b"_n); + +// expect(t.eden_gm.trace(100), "Nothing to do"); + +// // GROUP_ID: 2 +// t.skip_to("2020-07-04T16:15:00.000"); +// t.chain.as("edenmember13"_n).act(round, "edenmember13"_n, "edenmember13"_n); +// t.chain.as("edenmember14"_n).act(round, "edenmember14"_n, "edenmember13"_n); +// t.chain.as("edenmember12"_n).act(round, "edenmember12"_n, "edenmember13"_n); +// // can only get 1 sbt even though there are multiple votes +// t.pip.act(round, "pip"_n, "edenmember13"_n); +// t.chain.start_block(); +// t.pip.act(round, "pip"_n, "edenmember14"_n); +// t.chain.start_block(); +// t.pip.act(round, "pip"_n, "edenmember12"_n); +// t.chain.start_block(); +// t.pip.act(round, "pip"_n, "edenmember13"_n); + +// expect(t.eden_gm.trace(100), "Nothing to do"); + +// // finish election +// t.skip_to("2020-07-04T16:30:00.000"); +// t.alice.act(256); +// t.eden_gm.act(10); + +// std::vector expected{"edenmember12"_n, "pip"_n}; + +// CHECK(t.get_badges() == expected); + +// t.eden_gm.act(2); + +// CHECK(t.get_badges() == std::vector{}); +// } TEST_CASE("accounting") {