|
COOPENOMICS
v1
Кооперативная Экономика
|
#include <boost/test/unit_test.hpp>#include <eosio/testing/tester.hpp>#include <eosio/chain/abi_serializer.hpp>#include "eosio.system_tester.hpp"#include <fc/variant_object.hpp>Классы | |
| class | eosio_token_tester |
Определения типов | |
| using | mvo = fc::mutable_variant_object |
Функции | |
| BOOST_FIXTURE_TEST_CASE (create_tests, eosio_token_tester) | |
| FC_LOG_AND_RETHROW () BOOST_FIXTURE_TEST_CASE(create_negative_max_supply | |
| TKN ("max_supply", "100 TKN")("issuer" | |
| produce_blocks (1) | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("token with symbol already exists"), create("alice"_n, asset::from_string("100 TKN"))) | |
| TKN ("max_supply", "4611686018427387903 TKN")("issuer" | |
| asset | max (10, symbol(SY(0, NKT))) |
| memcpy & | max (share_type) |
| BOOST_CHECK_EXCEPTION (create("alice"_n, max), asset_type_exception, [](const asset_type_exception &e) { return expect_assert_message(e, "magnitude of asset amount must be less than 2^62");}) | |
| TKN ("max_supply", "1.000000000000000000 TKN")("issuer" | |
| issue ("alice"_n, asset::from_string("500.000 TKN"), "hola") | |
| TKN ("max_supply", "1000.000 TKN")("issuer" | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("quantity exceeds available supply"), issue("alice"_n, asset::from_string("500.001 TKN"), "hola")) | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("must issue positive quantity"), issue("alice"_n, asset::from_string("-1.000 TKN"), "hola")) | |
| BOOST_REQUIRE_EQUAL (success(), issue("alice"_n, asset::from_string("1.000 TKN"), "hola")) | |
| BOOST_REQUIRE_EQUAL (success(), issue("alice"_n, asset::from_string("500.000 TKN"), "hola")) | |
| BOOST_REQUIRE_EQUAL (success(), retire("alice"_n, asset::from_string("200.000 TKN"), "hola")) | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("overdrawn balance"), retire("alice"_n, asset::from_string("500.000 TKN"), "hola")) | |
| BOOST_REQUIRE_EQUAL (success(), transfer("alice"_n, "bob"_n, asset::from_string("200.000 TKN"), "hola")) | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("overdrawn balance"), retire("alice"_n, asset::from_string("300.000 TKN"), "hola")) | |
| BOOST_REQUIRE_EQUAL (success(), transfer("bob"_n, "alice"_n, asset::from_string("200.000 TKN"), "hola")) | |
| BOOST_REQUIRE_EQUAL (success(), retire("alice"_n, asset::from_string("300.000 TKN"), "hola")) | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("overdrawn balance"), retire("alice"_n, asset::from_string("1.000 TKN"), "hola")) | |
| issue ("alice"_n, asset::from_string("1000 CERO"), "hola") | |
| CERO ("max_supply", "1000 CERO")("issuer" | |
| transfer ("alice"_n, "bob"_n, asset::from_string("300 CERO"), "hola") | |
| CERO ("frozen", 0)("whitelist" | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("overdrawn balance"), transfer("alice"_n, "bob"_n, asset::from_string("701 CERO"), "hola")) | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("must transfer positive quantity"), transfer("alice"_n, "bob"_n, asset::from_string("-1000 CERO"), "hola")) | |
| BOOST_REQUIRE_EQUAL (true, alice_balance.is_null()) | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("tokens can only be issued to issuer account"), push_action("alice"_n, "issue"_n, mvo()("to", "bob")("quantity", asset::from_string("1000 CERO"))("memo", ""))) | |
| BOOST_REQUIRE_EQUAL (success(), issue("alice"_n, asset::from_string("1000 CERO"), "issue")) | |
| BOOST_REQUIRE_EQUAL (true, bob_balance.is_null()) | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("owner account does not exist"), open("nonexistent"_n, "0,CERO", "alice"_n)) | |
| BOOST_REQUIRE_EQUAL (success(), open("bob"_n, "0,CERO", "alice"_n)) | |
| BOOST_REQUIRE_EQUAL (success(), transfer("alice"_n, "bob"_n, asset::from_string("200 CERO"), "hola")) | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("symbol does not exist"), open("carol"_n, "0,INVALID", "alice"_n)) | |
| BOOST_REQUIRE_EQUAL (wasm_assert_msg("symbol precision mismatch"), open("carol"_n, "1,CERO", "alice"_n)) | |
| BOOST_REQUIRE_EQUAL (success(), issue("alice"_n, asset::from_string("1000 CERO"), "hola")) | |
| BOOST_REQUIRE_EQUAL (success(), transfer("alice"_n, "bob"_n, asset::from_string("1000 CERO"), "hola")) | |
| BOOST_REQUIRE_EQUAL (success(), close("alice"_n, "0,CERO")) | |
Переменные | |
| eosio_token_tester | try |
| auto | stats = get_stats("0,TKN") |
| supply | |
| alice | |
| share_type | amount = 4611686018427387904 |
| auto | alice_balance = get_account("alice"_n, "3,TKN") |
| balance | |
| TKN | |
| CERO | |
| auto | bob_balance = get_account("bob"_n, "0,CERO") |
| using mvo = fc::mutable_variant_object |
| BOOST_CHECK_EXCEPTION | ( | create("alice"_n, max) | , |
| asset_type_exception | , | ||
| [] (const asset_type_exception &e) { return expect_assert_message(e, "magnitude of asset amount must be less than 2^62");} | |||
| ) |
| BOOST_FIXTURE_TEST_CASE | ( | create_tests | , |
| eosio_token_tester | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| close("alice"_n, "0,CERO") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| issue("alice"_n, asset::from_string("1.000 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| issue("alice"_n, asset::from_string("1000 CERO"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| issue("alice"_n, asset::from_string("500.000 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| open("bob"_n, "0,CERO", "alice"_n) | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| retire("alice"_n, asset::from_string("200.000 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| retire("alice"_n, asset::from_string("300.000 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| transfer("alice"_n, "bob"_n, asset::from_string("1000 CERO"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| transfer("alice"_n, "bob"_n, asset::from_string("200 CERO"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| transfer("alice"_n, "bob"_n, asset::from_string("200.000 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | success() | , |
| transfer("bob"_n, "alice"_n, asset::from_string("200.000 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | true | , |
| alice_balance. | is_null() | ||
| ) |
| BOOST_REQUIRE_EQUAL | ( | true | , |
| bob_balance. | is_null() | ||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("must issue positive quantity") | , |
| issue("alice"_n, asset::from_string("-1.000 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("must transfer positive quantity") | , |
| transfer("alice"_n, "bob"_n, asset::from_string("-1000 CERO"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("overdrawn balance") | , |
| retire("alice"_n, asset::from_string("1.000 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("overdrawn balance") | , |
| retire("alice"_n, asset::from_string("300.000 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("overdrawn balance") | , |
| retire("alice"_n, asset::from_string("500.000 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("overdrawn balance") | , |
| transfer("alice"_n, "bob"_n, asset::from_string("701 CERO"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("owner account does not exist") | , |
| open("nonexistent"_n, "0,CERO", "alice"_n) | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("quantity exceeds available supply") | , |
| issue("alice"_n, asset::from_string("500.001 TKN"), "hola") | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("symbol does not exist") | , |
| open("carol"_n, "0,INVALID", "alice"_n) | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("symbol precision mismatch") | , |
| open("carol"_n, "1,CERO", "alice"_n) | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("token with symbol already exists") | , |
| create("alice"_n, asset::from_string("100 TKN")) | |||
| ) |
| BOOST_REQUIRE_EQUAL | ( | wasm_assert_msg("tokens can only be issued to issuer account") | , |
| push_action("alice"_n, "issue"_n, mvo()("to", "bob")("quantity", asset::from_string("1000 CERO"))("memo", "")) | |||
| ) |
| CERO | ( | "frozen" | , |
| 0 | |||
| ) |
| CERO | ( | "max_supply" | , |
| "1000 CERO" | |||
| ) |
| FC_LOG_AND_RETHROW | ( | ) |
| issue | ( | "alice" | _n, |
| asset::from_string("1000 CERO") | , | ||
| "hola" | |||
| ) |
| issue | ( | "alice" | _n, |
| asset::from_string("500.000 TKN") | , | ||
| "hola" | |||
| ) |
| asset max | ( | 10 | , |
| symbol(SY(0, NKT)) | |||
| ) |
| memcpy & max | ( | share_type | ) |
| produce_blocks | ( | 1 | ) |
| TKN | ( | "max_supply" | , |
| "1.000000000000000000 TKN" | |||
| ) |
| TKN | ( | "max_supply" | , |
| "100 TKN" | |||
| ) |
| TKN | ( | "max_supply" | , |
| "1000.000 TKN" | |||
| ) |
| TKN | ( | "max_supply" | , |
| "4611686018427387903 TKN" | |||
| ) |
| transfer | ( | "alice" | _n, |
| "bob" | _n, | ||
| asset::from_string("300 CERO") | , | ||
| "hola" | |||
| ) |
| alice |
| auto alice_balance = get_account("alice"_n, "3,TKN") |
| share_type amount = 4611686018427387904 |
| balance |
| auto bob_balance = get_account("bob"_n, "0,CERO") |
| CERO |
| auto stats = get_stats("0,TKN") |
| supply |
| TKN |