提交 85abd227 编写于 作者: K Khaled Al-Hassanieh

Delete token class and currency contract, refactor noop

上级 18df341d
......@@ -13,7 +13,6 @@ add_subdirectory(eosio.msig)
add_subdirectory(multi_index_test)
add_subdirectory(eosio.system)
add_subdirectory(identity)
add_subdirectory(currency)
add_subdirectory(stltest)
add_subdirectory(exchange)
add_subdirectory(test.inline)
......
file(GLOB ABI_FILES "*.abi")
configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
add_wast_executable(TARGET currency
INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}"
LIBRARIES libc++ libc eosiolib
DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR}
)
{
"types": [{
"new_type_name": "account_name",
"type": "name"
}
],
"structs": [{
"name": "transfer",
"base": "",
"fields": [
{"name":"from", "type":"account_name"},
{"name":"to", "type":"account_name"},
{"name":"quantity", "type":"asset"},
{"name":"memo", "type":"string"}
]
},{
"name": "create",
"base": "",
"fields": [
{"name":"issuer", "type":"account_name"},
{"name":"maximum_supply", "type":"asset"},
{"name":"can_freeze", "type":"uint8"},
{"name":"can_recall", "type":"uint8"},
{"name":"can_whitelist", "type":"uint8"}
]
},{
"name": "issue",
"base": "",
"fields": [
{"name":"to", "type":"account_name"},
{"name":"quantity", "type":"asset"},
{"name":"memo", "type":"string"}
]
},{
"name": "account",
"base": "",
"fields": [
{"name":"balance", "type":"asset"},
{"name":"frozen", "type":"uint8"},
{"name":"whitelist", "type":"uint8"}
]
},{
"name": "currency_stats",
"base": "",
"fields": [
{"name":"supply", "type":"asset"},
{"name":"max_supply", "type":"asset"},
{"name":"issuer", "type":"account_name"},
{"name":"can_freeze", "type":"uint8"},
{"name":"can_recall", "type":"uint8"},
{"name":"can_whitelist", "type":"uint8"},
{"name":"is_frozen", "type":"uint8"},
{"name":"enforce_whitelist", "type":"uint8"}
]
}
],
"actions": [{
"name": "transfer",
"type": "transfer",
"ricardian_contract": ""
},{
"name": "issue",
"type": "issue",
"ricardian_contract": ""
}, {
"name": "create",
"type": "create",
"ricardian_contract": ""
}
],
"tables": [{
"name": "accounts",
"type": "account",
"index_type": "i64",
"key_names" : ["currency"],
"key_types" : ["uint64"]
},{
"name": "stat",
"type": "currency_stats",
"index_type": "i64",
"key_names" : ["currency"],
"key_types" : ["uint64"]
}
],
"ricardian_clauses": []
}
#if 0
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <eosiolib/currency.hpp>
extern "C" {
/// The apply method implements the dispatch of events to this contract
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
eosio::currency(receiver).apply( code, action );
}
}
#endif
/**
* @file token.hpp
* @copyright defined in eos/LICENSE.txt
* @brief Defines types and ABI for standard token messages and database tables
*
*/
#pragma once
#include <eosiolib/math.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/reflect.hpp>
#include <eosiolib/asset.hpp>
#include <eosiolib/serialize.hpp>
namespace eosio {
/**
* @defgroup tokens Token API
* @brief Defines the ABI for interfacing with standard-compatible token messages and database tables.
* @ingroup contractdev
*
* @{
*/
template<typename BaseToken, typename QuoteToken>
struct price;
template< uint64_t Code,
uint64_t Symbol,
typename NumberType = uint64_t
>
struct token {
/**
* Type of the currency (e.g. eos) represented as an unsigned 64 bit integer
* @brief Type of the currency
*/
static const uint64_t code = Code;
static const uint64_t symbol = Symbol;
/**
* Default constructor
* @brief Default constructor
*/
token(){}
template<typename Base, typename Quote>
friend price<Base,Quote> operator / ( const Base& b, const Quote& q );
explicit operator asset()const { return asset( int64_t(quantity), Symbol ); }
token( const asset& a ):quantity(NumberType(a.amount)) {
eosio_assert( a.symbol == Symbol, "attempt to construct token from asset with different symbol" );
eosio_assert( 0 <= a.amount, "attemt to convert asset with negative value to token" );
}
/**
* Constructor for token given quantity of tokens available
* @brief Constructor for token given quantity of tokens available
* @param v - quantity of tokens available
*/
explicit token( NumberType v ):quantity(v){}
/**
* Quantity of tokens available
* @brief Quantity of tokens available
*/
NumberType quantity = 0;
/**
* Subtracts quantity of token from this object
* Throws an exception if underflow
* @brief Subtracts quantity of token from this object
* @param a token to be subtracted
* @return this token after subtraction
*/
token& operator-=( const token& a ) {
eosio_assert( quantity >= a.quantity, "integer underflow subtracting token balance" );
quantity -= a.quantity;
return *this;
}
/**
* Adds quantity of token to this object
* Throws an exception if overflow
* @brief Adds quantity of token to this object
* @param a token to be added
* @return this token after addition
*/
token& operator+=( const token& a ) {
eosio_assert( quantity + a.quantity >= a.quantity, "integer overflow adding token balance" );
quantity += a.quantity;
return *this;
}
/**
* Adds quantity of two tokens and return a new token
* Throws an exception if overflow
* @brief Adds quantity of two tokens and return a new token
* @param a token to be added
* @param b token to be added
* @return result of addition as a new token
*/
inline friend token operator+( const token& a, const token& b ) {
token result = a;
result += b;
return result;
}
/**
* Subtracts quantity of two tokens and return a new token
* Throws an exception if underflow
* @brief Subtracts quantity of two tokens and return a new token
* @param a token to be subtracted
* @param b token to be subtracted
* @return result of subtraction as a new token
*/
inline friend token operator-( const token& a, const token& b ) {
token result = a;
result -= b;
return result;
}
/**
* Multiplies quantity of token by an integer
* Throws an exception if overflow
* @brief Multiplies quantity of token by an integer
* @param a multipier
* @return this token after addition
*/
token& operator*=( uint64_t a ) {
eosio_assert( a == 0 || (quantity * a) / a == quantity, "integer overflow multiplying token balance" );
quantity *= a;
return *this;
}
/**
* Multiplies token and integer
* Throws an exception if overflow
* @brief Multiplies quantity of two tokens and return a new token
* @param a token to be multiplied
* @param b multipier
* @return result of addition as a new token
*/
inline friend token operator*( const token& a, uint64_t b ) {
token result = a;
result *= b;
return result;
}
/**
* Multiplies token and integer
* Throws an exception if overflow
* @brief Multiplies quantity of two tokens and return a new token
* @param a token to be multiplied
* @param b multipier
* @return result of addition as a new token
*/
inline friend token operator*( uint64_t b, const token& a ) {
token result = a;
result *= b;
return result;
}
/**
* Divides quantity of token by an integer
* Throws an exception if overflow
* @brief Divides quantity of token by an integer
* @param a multipier
* @return this token after addition
*/
token& operator/=( uint64_t a ) {
quantity /= a;
return *this;
}
/**
* Divides token and integer
* Throws an exception if overflow
* @brief Divides quantity of two tokens and return a new token
* @param a token to be multiplied
* @param b multipier
* @return result of addition as a new token
*/
inline friend token operator/( const token& a, uint64_t b ) {
token result = a;
result /= b;
return result;
}
/**
* Divides two tokens
* Throws an exception if overflow
* @brief Divides quantity of two tokens and return a new token
* @param a token
* @param b token
* @return result of addition as a new token
*/
inline friend NumberType operator/( const token& a, const token& b ) {
return a.quantity / b.quantity;
}
/**
* Less than or equal to comparison operator
* @brief Less than or equal to comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is less than or equal to quantity of b
*/
friend bool operator <= ( const token& a, const token& b ) { return a.quantity <= b.quantity; }
/**
* Less than comparison operator
* @brief Less than comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is less than quantity of b
*/
friend bool operator < ( const token& a, const token& b ) { return a.quantity < b.quantity; }
/**
* Greater than or equal to comparison operator
* @brief Greater than or equal to comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is greater than or equal to quantity of b
*/
friend bool operator >= ( const token& a, const token& b ) { return a.quantity >= b.quantity; }
/**
* Greater than comparison operator
* @brief Greater than comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is greater than quantity of b
*/
friend bool operator > ( const token& a, const token& b ) { return a.quantity > b.quantity; }
/**
* Equality comparison operator
* @brief Equality comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is equal to quantity of b
*/
friend bool operator == ( const token& a, const token& b ) { return a.quantity == b.quantity; }
/**
* Inequality comparison operator
* @brief Inequality comparison operator
* @param a token to be compared
* @param b token to be compared
* @return true if quantity of a is not equal to quantity of b
*/
friend bool operator != ( const token& a, const token& b ) { return a.quantity != b.quantity; }
/**
* Boolean conversion operator
* @brief Boolean conversion operator
* @return true if quantity is not zero
*/
explicit operator bool()const { return quantity != 0; }
template<typename DataStream>
friend DataStream& operator << ( DataStream& ds, const token& t ){
return ds << t.quantity;
}
template<typename DataStream>
friend DataStream& operator >> ( DataStream& ds, token& t ){
return ds >> t.quantity;
}
};
/// @}
template<typename BaseToken, typename QuoteToken>
struct price_ratio {
BaseToken base;
QuoteToken quote;
};
template<typename Base, typename Quote>
price<Base,Quote> operator / ( const Base& b, const Quote& q ) {
return price<Base,Quote>(b,q);
}
/**
*
* @brief Defines a fixed precision price between two tokens.
* @tparam BaseToken - represents the type of the base token
* @tparam QuoteToken - represents the type of the quote token
* @ingroup tokens
*
* @details Defines a fixed precision price between two tokens.
* A price is written as X Base/Quote. Where X is a power of 10 which makes it simpler to just shift the decimal.
* It supports the following operator: /, \, <=, <, ==, !=, >=, > and also print functionality
*
* Example:
* @code
* typedef eosio::token<uint64_t, N(MyBaseToken)> MyBaseToken;
* typedef eosio::token<uint64_t, N(MyQuoteToken)> MyQuoteToken;
* typedef price<MyBaseToken, MyQuoteToken> MyBaseToQuotePrice;
* MyBaseToken zeroBaseToken;
* MyQuoteToken zeroQuoteToken;
* MyBaseToQuotePrice zeroBaseToQuote(zeroBaseToken, zeroQuoteToken); // throws invalid price exception
* MyBaseToken baseToken(128);
* MyQuoteToken quoteToken(128);
* MyBaseToQuotePrice aPrice(baseToken, quoteToken);
* aPrice.print(); // Output: 1e+15. MyBaseToken / MyQuoteToken
* MyQuoteToken anotherQuote = baseToken / price;
* std::cout << (anotherQuote == quoteToken); // Output: true
* MyBaseToken anotherBase = quoteToken * price;
* std::cout << (anotherBase == baseToken); // Output: true
* MyBaseToQuotePrice anotherPrice(baseToken, quoteToken);
* std::cout << (aPrice == anotherPrice); // Output: true
* std::cout << (aPrice != anotherPrice); // Output: false
* MyBaseToken base256(256);
* MyBaseToQuotePrice price2(base256, quoteToken);
* std::cout << (price2 > aPrice); // Output: true
* std::cout << (aPrice < price2); // Output: true
* @endcode
*
* @{
*/
template<typename BaseToken, typename QuoteToken>
struct price
{
typedef BaseToken base_token_type;
typedef QuoteToken quote_token_type;
/**
* The largest base 10 integer that can be represented with 53 bits of
* a double. This number keeps the math in range of JavaScript. By
* being a power of 10 it makes it easier for developers to read and
* interpret the integer by simply shifting the decimal.
* @brief Precision of the price.
*/
static const uint64_t precision = 1000ll*1000ll*1000ll*1000ll*1000ll;
/**
* Default constructor.
* Initialize base per quote to be 1.
* @brief Default constructor.
*/
price():base_per_quote(1ul){}
explicit price( uint128_t b ):base_per_quote(b){}
price& operator=( uint128_t b ) {
base_per_quote = b;
return *this;
}
/**
* Construction for price given the base token and quote token.
* @brief Construction for price given the base token and quote token.
* @param base - base token
* @param quote - quote token
*/
price( BaseToken base, QuoteToken quote ) {
eosio_assert( base >= BaseToken(1ul), "invalid price" );
eosio_assert( quote >= QuoteToken(1ul), "invalid price" );
base_per_quote = base.quantity;
base_per_quote *= precision;
base_per_quote /= quote.quantity;
}
/**
* Operator returns a quote token given a base token and the conversion price.
* @brief Operator returns a quote token given a base token and the conversion price.
* @param b - base token
* @param q - price
* @return quote token
*/
friend QuoteToken operator / ( BaseToken b, const price& q ) {
return QuoteToken( uint64_t((uint128(b.quantity) * uint128(precision) / q.base_per_quote)) );
}
/**
* Operator returns a base token given a quote token and the conversion price.
* @brief Operator returns a base token given a quote token and the conversion price.
* @param b - quote token
* @param q - price
* @return base token
*/
friend BaseToken operator * ( const QuoteToken& b, const price& q ) {
//return QuoteToken( uint64_t( mult_div_i128( b.quantity, q.base_per_quote, precision ) ) );
return BaseToken( uint64_t((b.quantity * q.base_per_quote) / precision) );
}
/**
* Less than or equal to comparison operator.
* @brief Less than or equal to comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is less than or equal to base per quote of b
*/
friend bool operator <= ( const price& a, const price& b ) { return a.base_per_quote <= b.base_per_quote; }
/**
* Less than comparison operator.
* @brief Less than comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is less than base per quote of b
*/
friend bool operator < ( const price& a, const price& b ) { return a.base_per_quote < b.base_per_quote; }
/**
* Greater than or equal to comparison operator.
* @brief Greater than or equal to comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is greater than or equal to base per quote of b
*/
friend bool operator >= ( const price& a, const price& b ) { return a.base_per_quote >= b.base_per_quote; }
/**
* Greater than comparison operator.
* @brief Greater than comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is greater than base per quote of b
*/
friend bool operator > ( const price& a, const price& b ) { return a.base_per_quote > b.base_per_quote; }
/**
* Equality comparison operator.
* @brief Equality comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is equal to base per quote of b
*/
friend bool operator == ( const price& a, const price& b ) { return a.base_per_quote == b.base_per_quote; }
/**
* Inequality comparison operator.
* @brief Inequality comparison operator.
* @param a price to be compared
* @param b price to be compared
* @return true if base per quote of a is not equal to base per quote of b
*/
friend bool operator != ( const price& a, const price& b ) { return a.base_per_quote != b.base_per_quote; }
operator uint128_t()const { return base_per_quote; }
EOSLIB_SERIALIZE( price, (base_per_quote) )
private:
/**
* Represents as number of base tokens to purchase 1 quote token.
* @brief Represents number of base tokens to purchase 1 quote token.
*/
uint128_t base_per_quote;
};
/// @}
/// @} tokenhppapi
}
......@@ -5,7 +5,6 @@ add_wast_executable(TARGET exchange
DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR}
)
configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
add_dependencies( exchange currency )
add_executable(test_exchange test_exchange.cpp )
#bfp/lib/pack.c bfp/lib/posit.cpp bfp/lib/util.c bfp/lib/op2.c)
......
......@@ -3,13 +3,21 @@
* @copyright defined in eos/LICENSE.txt
*/
#include <noop/noop.hpp>
namespace noop {
extern "C" {
/// The apply method implements the dispatch of events to this contract
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
eosio::dispatch<noop, noop::anyaction>(code, action);
}
}
}
#include <eosiolib/eosio.hpp>
namespace eosio {
class noop: public contract {
public:
noop( account_name self ): contract( self ) { }
void anyaction( account_name from,
const std::string& /*type*/,
const std::string& /*data*/ )
{
require_auth( from );
}
};
EOSIO_ABI( noop, ( anyaction ) )
} /// eosio
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#pragma once
#include <eosiolib/eosio.hpp>
#include <eosiolib/dispatcher.hpp>
namespace noop {
using std::string;
/**
noop contract
All it does is require sender authorization.
Actions: anyaction
*/
class noop {
public:
ACTION(N(noop), anyaction) {
anyaction() { }
anyaction(account_name f, const string& t, const string& d): from(f), type(t), data(d) { }
account_name from;
string type;
string data;
EOSLIB_SERIALIZE(anyaction, (from)(type)(data))
};
static void on(const anyaction& act)
{
require_auth(act.from);
}
};
} /// noop
......@@ -53,7 +53,7 @@ namespace proxy {
configs::store(code_config, self);
transaction out;
out.actions.emplace_back(permission_level{self, N(active)}, N(currency), N(transfer), new_transfer);
out.actions.emplace_back(permission_level{self, N(active)}, N(eosio.token), N(transfer), new_transfer);
out.delay_sec = code_config.delay;
out.send(id, self);
}
......@@ -90,6 +90,13 @@ namespace proxy {
using namespace proxy;
using namespace eosio;
struct transfer_args {
account_name from;
account_name to;
asset quantity;
string memo;
};
extern "C" {
/// The apply method implements the dispatch of events to this contract
......@@ -101,9 +108,9 @@ extern "C" {
// Comment this out for now so that the contract compiles, this will change with refactoring to use eosio.token
// apply_transfer(receiver, code, unpack_action_data<eosiosystem::contract<N(eosio.system)>::currency::transfer_memo>());
}
} else if ( code == N(currency) ) {
} else if ( code == N(eosio.token) ) {
if( action == N(transfer) ) {
// apply_transfer(receiver, code, unpack_action_data<eosio::currency::transfer>());
apply_transfer(receiver, code, unpack_action_data<transfer_args>());
}
} else if (code == receiver ) {
if ( action == N(setowner)) {
......
......@@ -136,7 +136,6 @@
#include <stdexcept>
*/
//include <eosiolib/eos.hpp>
#include <eosiolib/token.hpp>
#include <eosiolib/dispatcher.hpp>
using namespace eosio;
......@@ -159,9 +158,6 @@ namespace stltest {
class contract {
public:
typedef eosio::token<N(mycurrency),S(4,MYCUR)> token_type;
static const uint64_t code = token_type::code;
static const uint64_t symbol = token_type::symbol;
static const uint64_t sent_table_name = N(sent);
static const uint64_t received_table_name = N(received);
......
......@@ -6,5 +6,3 @@ add_library( txn_test_gen_plugin
target_link_libraries( txn_test_gen_plugin appbase fc http_plugin chain_plugin )
target_include_directories( txn_test_gen_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
target_include_directories( txn_test_gen_plugin PUBLIC ${CMAKE_BINARY_DIR}/contracts )
add_dependencies( txn_test_gen_plugin currency )
......@@ -28,7 +28,7 @@ target_include_directories( chain_test PUBLIC ${CMAKE_BINARY_DIR}/contracts ${CM
target_include_directories( chain_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/wasm_tests )
target_include_directories( chain_test PUBLIC ${CMAKE_SOURCE_DIR}/plugins/net_plugin/include )
target_include_directories( chain_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include )
add_dependencies(chain_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange currency proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig)
add_dependencies(chain_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig)
#
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/p2p_tests/sync/test.sh ${CMAKE_CURRENT_BINARY_DIR}/p2p_tests/sync/test.sh COPYONLY)
......
......@@ -928,7 +928,7 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
BOOST_REQUIRE_EXCEPTION(
chain.push_action(config::system_account_name, contracts::linkauth::get_name(), tester_account, fc::mutable_variant_object()
("account", "tester")
("code", "currency")
("code", eosio_token)
("type", "transfer")
("requirement", "second"),
30, 3),
......@@ -1071,27 +1071,27 @@ BOOST_AUTO_TEST_CASE( link_delay_unlink_test ) { try {
("delay", 10));
chain.push_action(config::system_account_name, contracts::linkauth::get_name(), tester_account, fc::mutable_variant_object()
("account", "tester")
("code", "currency")
("code", eosio_token)
("type", "transfer")
("requirement", "first"));
chain.produce_blocks();
chain.push_action(N(currency), N(create), N(currency), mutable_variant_object()
("issuer", "currency" )
chain.push_action(N(eosio.token), N(create), N(eosio.token), mutable_variant_object()
("issuer", eosio_token )
("maximum_supply", "9000000.0000 CUR" )
("can_freeze", 0)
("can_recall", 0)
("can_whitelist", 0)
);
chain.push_action(N(currency), name("issue"), N(currency), fc::mutable_variant_object()
("to", "currency")
chain.push_action(N(eosio.token), name("issue"), N(eosio.token), fc::mutable_variant_object()
("to", eosio_token)
("quantity", "1000000.0000 CUR")
("memo", "for stuff")
);
auto trace = chain.push_action(N(currency), name("transfer"), N(currency), fc::mutable_variant_object()
("from", "currency")
auto trace = chain.push_action(N(eosio.token), name("transfer"), N(eosio.token), fc::mutable_variant_object()
("from", eosio_token)
("to", "tester")
("quantity", "100.0000 CUR")
("memo", "hi" )
......@@ -1131,7 +1131,7 @@ BOOST_AUTO_TEST_CASE( link_delay_unlink_test ) { try {
BOOST_REQUIRE_EXCEPTION(
chain.push_action(config::system_account_name, contracts::unlinkauth::get_name(), tester_account, fc::mutable_variant_object()
("account", "tester")
("code", "currency")
("code", eosio_token)
("type", "transfer"),
30, 7),
transaction_exception,
......@@ -1145,7 +1145,7 @@ BOOST_AUTO_TEST_CASE( link_delay_unlink_test ) { try {
// this transaction will be delayed 20 blocks
chain.push_action(config::system_account_name, contracts::unlinkauth::get_name(), tester_account, fc::mutable_variant_object()
("account", "tester")
("code", "currency")
("code", eosio_token)
("type", "transfer"),
30, 10
);
......@@ -1313,13 +1313,13 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
chain.produce_blocks();
auto liquid_balance = get_currency_balance(chain, N(currency));
auto liquid_balance = get_currency_balance(chain, N(eosio.token));
BOOST_REQUIRE_EQUAL(asset::from_string("999900.0000 CUR"), liquid_balance);
liquid_balance = get_currency_balance(chain, N(tester));
BOOST_REQUIRE_EQUAL(asset::from_string("100.0000 CUR"), liquid_balance);
// this transaction will be delayed 20 blocks
trace = chain.push_action(N(currency), name("transfer"), N(tester), fc::mutable_variant_object()
trace = chain.push_action(N(eosio.token), name("transfer"), N(tester), fc::mutable_variant_object()
("from", "tester")
("to", "tester2")
("quantity", "1.0000 CUR")
......@@ -1401,7 +1401,7 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
BOOST_REQUIRE_EQUAL(asset::from_string("1.0000 CUR"), liquid_balance);
// this transfer is performed right away since delay is removed
trace = chain.push_action(N(currency), name("transfer"), N(tester), fc::mutable_variant_object()
trace = chain.push_action(N(eosio.token), name("transfer"), N(tester), fc::mutable_variant_object()
("from", "tester")
("to", "tester2")
("quantity", "10.0000 CUR")
......@@ -1585,11 +1585,11 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(currency));
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
chain.set_code(N(currency), currency_wast);
chain.set_abi(N(currency), currency_abi);
chain.set_code(N(eosio.token), eosio_token_wast);
chain.set_abi(N(eosio.token), eosio_token_abi);
chain.produce_blocks();
chain.create_account(N(tester));
......@@ -1655,7 +1655,7 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
chain.produce_blocks();
liquid_balance = get_currency_balance(chain, N(currency));
liquid_balance = get_currency_balance(chain, N(eosio.token));
BOOST_REQUIRE_EQUAL(asset::from_string("999900.0000 CUR"), liquid_balance);
liquid_balance = get_currency_balance(chain, N(tester));
BOOST_REQUIRE_EQUAL(asset::from_string("100.0000 CUR"), liquid_balance);
......@@ -1708,7 +1708,7 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
BOOST_REQUIRE_EQUAL(asset::from_string("0.0000 CUR"), liquid_balance);
// this transaction will be delayed 20 blocks
trace = chain.push_action(N(currency), name("transfer"), N(tester), fc::mutable_variant_object()
trace = chain.push_action(N(eosio.token), name("transfer"), N(tester), fc::mutable_variant_object()
("from", "tester")
("to", "tester2")
("quantity", "5.0000 CUR")
......
......@@ -366,7 +366,7 @@ BOOST_FIXTURE_TEST_CASE(test_symbol, TESTER) try {
}
} FC_LOG_AND_RETHROW() /// test_symbol
#if 0
BOOST_FIXTURE_TEST_CASE( test_proxy, currency_tester ) try {
produce_blocks(2);
......@@ -420,8 +420,7 @@ BOOST_FIXTURE_TEST_CASE( test_proxy, currency_tester ) try {
BOOST_REQUIRE_EQUAL(get_balance( N(alice)), asset::from_string("5.0000 CUR"));
} FC_LOG_AND_RETHROW() /// test_currency
#endif
#if 0
BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
produce_blocks(2);
......@@ -518,6 +517,5 @@ BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
BOOST_REQUIRE_EQUAL(get_balance( N(bob)), asset::from_string("0.0000 CUR"));
} FC_LOG_AND_RETHROW() /// test_currency
#endif
BOOST_AUTO_TEST_SUITE_END()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册