COOPENOMICS  v1
Кооперативная Экономика
Файл eosio.token_tests.cpp
#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")
 

Типы

◆ mvo

using mvo = fc::mutable_variant_object

Функции

◆ BOOST_CHECK_EXCEPTION()

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()

BOOST_FIXTURE_TEST_CASE ( create_tests  ,
eosio_token_tester   
)

◆ BOOST_REQUIRE_EQUAL() [1/26]

BOOST_REQUIRE_EQUAL ( success()  ,
close("alice"_n, "0,CERO")   
)

◆ BOOST_REQUIRE_EQUAL() [2/26]

BOOST_REQUIRE_EQUAL ( success()  ,
issue("alice"_n, asset::from_string("1.000 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [3/26]

BOOST_REQUIRE_EQUAL ( success()  ,
issue("alice"_n, asset::from_string("1000 CERO"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [4/26]

BOOST_REQUIRE_EQUAL ( success()  ,
issue("alice"_n, asset::from_string("1000 CERO"), "issue")   
)

◆ BOOST_REQUIRE_EQUAL() [5/26]

BOOST_REQUIRE_EQUAL ( success()  ,
issue("alice"_n, asset::from_string("500.000 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [6/26]

BOOST_REQUIRE_EQUAL ( success()  ,
open("bob"_n, "0,CERO", "alice"_n)   
)

◆ BOOST_REQUIRE_EQUAL() [7/26]

BOOST_REQUIRE_EQUAL ( success()  ,
retire("alice"_n, asset::from_string("200.000 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [8/26]

BOOST_REQUIRE_EQUAL ( success()  ,
retire("alice"_n, asset::from_string("300.000 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [9/26]

BOOST_REQUIRE_EQUAL ( success()  ,
transfer("alice"_n, "bob"_n, asset::from_string("1000 CERO"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [10/26]

BOOST_REQUIRE_EQUAL ( success()  ,
transfer("alice"_n, "bob"_n, asset::from_string("200 CERO"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [11/26]

BOOST_REQUIRE_EQUAL ( success()  ,
transfer("alice"_n, "bob"_n, asset::from_string("200.000 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [12/26]

BOOST_REQUIRE_EQUAL ( success()  ,
transfer("bob"_n, "alice"_n, asset::from_string("200.000 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [13/26]

BOOST_REQUIRE_EQUAL ( true  ,
alice_balance.  is_null() 
)

◆ BOOST_REQUIRE_EQUAL() [14/26]

BOOST_REQUIRE_EQUAL ( true  ,
bob_balance.  is_null() 
)

◆ BOOST_REQUIRE_EQUAL() [15/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("must issue positive quantity")  ,
issue("alice"_n, asset::from_string("-1.000 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [16/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("must transfer positive quantity")  ,
transfer("alice"_n, "bob"_n, asset::from_string("-1000 CERO"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [17/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("overdrawn balance")  ,
retire("alice"_n, asset::from_string("1.000 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [18/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("overdrawn balance")  ,
retire("alice"_n, asset::from_string("300.000 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [19/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("overdrawn balance")  ,
retire("alice"_n, asset::from_string("500.000 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [20/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("overdrawn balance")  ,
transfer("alice"_n, "bob"_n, asset::from_string("701 CERO"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [21/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("owner account does not exist")  ,
open("nonexistent"_n, "0,CERO", "alice"_n)   
)

◆ BOOST_REQUIRE_EQUAL() [22/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("quantity exceeds available supply")  ,
issue("alice"_n, asset::from_string("500.001 TKN"), "hola")   
)

◆ BOOST_REQUIRE_EQUAL() [23/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("symbol does not exist")  ,
open("carol"_n, "0,INVALID", "alice"_n)   
)

◆ BOOST_REQUIRE_EQUAL() [24/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("symbol precision mismatch")  ,
open("carol"_n, "1,CERO", "alice"_n)   
)

◆ BOOST_REQUIRE_EQUAL() [25/26]

BOOST_REQUIRE_EQUAL ( wasm_assert_msg("token with symbol already exists")  ,
create("alice"_n, asset::from_string("100 TKN"))   
)

◆ BOOST_REQUIRE_EQUAL() [26/26]

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() [1/2]

CERO ( "frozen"  ,
 
)

◆ CERO() [2/2]

CERO ( "max_supply"  ,
"1000 CERO"   
)

◆ FC_LOG_AND_RETHROW()

FC_LOG_AND_RETHROW ( )

◆ issue() [1/2]

issue ( "alice"  _n,
asset::from_string("1000 CERO")  ,
"hola"   
)

◆ issue() [2/2]

issue ( "alice"  _n,
asset::from_string("500.000 TKN")  ,
"hola"   
)

◆ max() [1/2]

asset max ( 10  ,
symbol(SY(0, NKT))   
)

◆ max() [2/2]

memcpy & max ( share_type  )

◆ produce_blocks()

produce_blocks ( )

◆ TKN() [1/4]

TKN ( "max_supply"  ,
"1.000000000000000000 TKN"   
)

◆ TKN() [2/4]

TKN ( "max_supply"  ,
"100 TKN"   
)

◆ TKN() [3/4]

TKN ( "max_supply"  ,
"1000.000 TKN"   
)

◆ TKN() [4/4]

TKN ( "max_supply"  ,
"4611686018427387903 TKN"   
)

◆ transfer()

transfer ( "alice"  _n,
"bob"  _n,
asset::from_string("300 CERO")  ,
"hola"   
)

Переменные

◆ alice

alice

◆ alice_balance

auto alice_balance = get_account("alice"_n, "3,TKN")

◆ amount

share_type amount = 4611686018427387904

◆ balance

balance

◆ bob_balance

auto bob_balance = get_account("bob"_n, "0,CERO")

◆ CERO

CERO

◆ stats

auto stats = get_stats("0,TKN")

◆ supply

supply

◆ TKN

TKN

◆ try

Инициализатор
{
BOOST_REQUIRE_EQUAL( wasm_assert_msg( "max-supply must be positive" ),
create( "alice"_n, asset::from_string("-1000.000 TKN"))
)
BOOST_REQUIRE_EQUAL(wasm_assert_msg("token with symbol already exists"), create("alice"_n, asset::from_string("100 TKN")))