提交 26e338f4 编写于 作者: M Matias Romeo

Add cmake configuration parameter to set the CORE symbol. (CORE_SYMBOL_NAME)

上级 eeed07b0
......@@ -180,6 +180,18 @@ endif()
add_subdirectory( externals )
if ("${CORE_SYMBOL_NAME}" STREQUAL "")
set( CORE_SYMBOL_NAME "SYS" )
endif()
string(TOUPPER ${CORE_SYMBOL_NAME} CORE_SYMBOL_NAME)
string(LENGTH ${CORE_SYMBOL_NAME} CORE_SYMBOL_NAME_LENGTH)
if (CORE_SYMBOL_NAME_LENGTH GREATER 7)
message(FATAL_ERROR "CORE_SYMBOL_NAME lenght must be a between 1 and 7 characters")
endif()
message( STATUS "Using ${CORE_SYMBOL_NAME} as CORE symbol name")
include(wasm)
add_subdirectory( libraries )
......
......@@ -35,7 +35,7 @@ class dice : public eosio::contract {
//@abi action
void offerbet(const asset& bet, const account_name player, const checksum256& commitment) {
eosio_assert( bet.symbol == S(4,SYS) , "only SYS token allowed" );
eosio_assert( bet.symbol == CORE_SYMBOL, "only core token allowed" );
eosio_assert( bet.is_valid(), "invalid bet" );
eosio_assert( bet.amount > 0, "must bet positive quantity" );
......
......@@ -119,9 +119,9 @@ namespace eosiosystem {
* This action will buy an exact amount of ram and bill the payer the current market price.
*/
void system_contract::buyrambytes( account_name payer, account_name receiver, uint32_t bytes ) {
auto itr = _rammarket.find(S(4,RAMSYS));
auto itr = _rammarket.find(S(4,RAMCORE));
auto tmp = *itr;
auto eosout = tmp.convert( asset(bytes,S(0,RAM)), S(4,SYS) );
auto eosout = tmp.convert( asset(bytes,S(0,RAM)), CORE_SYMBOL );
buyram( payer, receiver, eosout );
}
......@@ -148,7 +148,7 @@ namespace eosiosystem {
int64_t bytes_out;
auto itr = _rammarket.find(S(4,RAMSYS));
auto itr = _rammarket.find(S(4,RAMCORE));
_rammarket.modify( itr, 0, [&]( auto& es ) {
bytes_out = es.convert( quant, S(0,RAM) ).amount;
});
......@@ -190,10 +190,10 @@ namespace eosiosystem {
eosio_assert( res_itr->ram_bytes >= bytes, "insufficient quota" );
asset tokens_out;
auto itr = _rammarket.find(S(4,RAMSYS));
auto itr = _rammarket.find(S(4,RAMCORE));
_rammarket.modify( itr, 0, [&]( auto& es ) {
/// the cast to int64_t of bytes is safe because we certify bytes is <= quota which is limited by prior purchases
tokens_out = es.convert( asset(bytes,S(0,RAM)), S(4,SYS) );
tokens_out = es.convert( asset(bytes,S(0,RAM)), CORE_SYMBOL);
});
_gstate.total_ram_bytes_reserved -= bytes;
......
......@@ -19,18 +19,18 @@ namespace eosiosystem {
//print( "construct system\n" );
_gstate = _global.exists() ? _global.get() : get_default_parameters();
auto itr = _rammarket.find(S(4,RAMSYS));
auto itr = _rammarket.find(S(4,RAMCORE));
if( itr == _rammarket.end() ) {
auto system_token_supply = eosio::token(N(eosio.token)).get_supply(eosio::symbol_type(system_token_symbol).name()).amount;
if( system_token_supply > 0 ) {
itr = _rammarket.emplace( _self, [&]( auto& m ) {
m.supply.amount = 100000000000000ll;
m.supply.symbol = S(4,RAMSYS);
m.supply.symbol = S(4,RAMCORE);
m.base.balance.amount = int64_t(_gstate.free_ram());
m.base.balance.symbol = S(0,RAM);
m.quote.balance.amount = system_token_supply / 1000;
m.quote.balance.symbol = S(4,SYS);
m.quote.balance.symbol = CORE_SYMBOL;
});
}
} else {
......@@ -58,7 +58,7 @@ namespace eosiosystem {
eosio_assert( max_ram_size > _gstate.total_ram_bytes_reserved, "attempt to set max below reserved" );
auto delta = int64_t(max_ram_size) - int64_t(_gstate.max_ram_size);
auto itr = _rammarket.find(S(4,RAMSYS));
auto itr = _rammarket.find(S(4,RAMCORE));
/**
* Increase or decrease the amount of ram for sale based upon the change in max
......
......@@ -113,7 +113,7 @@ namespace eosiosystem {
// static constexpr uint32_t max_inflation_rate = 5; // 5% annual inflation
static constexpr uint32_t seconds_per_day = 24 * 3600;
static constexpr uint64_t system_token_symbol = S(4,SYS);
static constexpr uint64_t system_token_symbol = CORE_SYMBOL;
class system_contract : public native {
private:
......
......@@ -131,7 +131,7 @@ namespace eosiosystem {
* @pre if proxy is set then proxy account must exist and be registered as a proxy
* @pre every listed producer or proxy must have been previously registered
* @pre voter must authorize this action
* @pre voter must have previously staked some SYS for voting
* @pre voter must have previously staked some EOS for voting
* @pre voter->staked must be up to date
*
* @post every producer previously voted for will have vote reduced by previous vote weight
......
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/core_symbol.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/core_symbol.hpp)
add_wast_library(TARGET eosiolib
INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}" ${CMAKE_SOURCE_DIR}/externals/magic_get/include
DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR}
)
)
\ No newline at end of file
......@@ -2,119 +2,19 @@
#include <eosiolib/serialize.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/system.h>
#include <eosiolib/symbol.hpp>
#include <tuple>
#include <limits>
namespace eosio {
static constexpr uint64_t string_to_symbol( uint8_t precision, const char* str ) {
uint32_t len = 0;
while( str[len] ) ++len;
uint64_t result = 0;
for( uint32_t i = 0; i < len; ++i ) {
if( str[i] < 'A' || str[i] > 'Z' ) {
/// ERRORS?
} else {
result |= (uint64_t(str[i]) << (8*(1+i)));
}
}
result |= uint64_t(precision);
return result;
}
#define S(P,X) ::eosio::string_to_symbol(P,#X)
typedef uint64_t symbol_name;
static constexpr bool is_valid_symbol( symbol_name sym ) {
sym >>= 8;
for( int i = 0; i < 7; ++i ) {
char c = (char)(sym & 0xff);
if( !('A' <= c && c <= 'Z') ) return false;
sym >>= 8;
if( !(sym & 0xff) ) {
do {
sym >>= 8;
if( (sym & 0xff) ) return false;
++i;
} while( i < 7 );
}
}
return true;
}
static constexpr uint32_t symbol_name_length( symbol_name tmp ) {
tmp >>= 8; /// skip precision
uint32_t length = 0;
while( tmp & 0xff && length <= 7) {
++length;
tmp >>= 8;
}
return length;
}
struct symbol_type {
symbol_name value;
symbol_type() { }
symbol_type(symbol_name s): value(s) { }
bool is_valid()const { return is_valid_symbol( value ); }
uint64_t precision()const { return value & 0xff; }
uint64_t name()const { return value >> 8; }
uint32_t name_length()const { return symbol_name_length( value ); }
operator symbol_name()const { return value; }
void print(bool show_precision=true)const {
if( show_precision ){
::eosio::print(precision());
prints(",");
}
auto sym = value;
sym >>= 8;
for( int i = 0; i < 7; ++i ) {
char c = (char)(sym & 0xff);
if( !c ) return;
prints_l(&c, 1 );
sym >>= 8;
}
}
EOSLIB_SERIALIZE( symbol_type, (value) )
};
struct extended_symbol : public symbol_type
{
extended_symbol( symbol_name s = 0, account_name c = 0 ):symbol_type{s},contract(c){}
account_name contract;
void print()const {
symbol_type::print();
prints("@");
printn( contract );
}
friend bool operator == ( const extended_symbol& a, const extended_symbol& b ) {
return std::tie( a.value, a.contract ) == std::tie( b.value, b.contract );
}
friend bool operator != ( const extended_symbol& a, const extended_symbol& b ) {
return std::tie( a.value, a.contract ) != std::tie( b.value, b.contract );
}
EOSLIB_SERIALIZE( extended_symbol, (value)(contract) )
};
struct asset {
int64_t amount;
symbol_type symbol;
static constexpr int64_t max_amount = (1LL << 62) - 1;
explicit asset( int64_t a = 0, symbol_name s = S(4,SYS))
explicit asset( int64_t a = 0, symbol_type s = CORE_SYMBOL )
:amount(a),symbol{s}
{
eosio_assert( is_amount_within_range(), "magnitude of asset amount must be less than 2^62" );
......
/** @file
* @copyright defined in eos/LICENSE.txt
*
* \warning This file is machine generated. DO NOT EDIT. See core_symbol.hpp.in for changes.
*/
#define CORE_SYMBOL S(4,${CORE_SYMBOL_NAME})
\ No newline at end of file
#pragma once
#include <eosiolib/core_symbol.hpp>
#include <eosiolib/serialize.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/system.h>
#include <tuple>
#include <limits>
namespace eosio {
static constexpr uint64_t string_to_symbol( uint8_t precision, const char* str ) {
uint32_t len = 0;
while( str[len] ) ++len;
uint64_t result = 0;
for( uint32_t i = 0; i < len; ++i ) {
if( str[i] < 'A' || str[i] > 'Z' ) {
/// ERRORS?
} else {
result |= (uint64_t(str[i]) << (8*(1+i)));
}
}
result |= uint64_t(precision);
return result;
}
#define S(P,X) ::eosio::string_to_symbol(P,#X)
typedef uint64_t symbol_name;
static constexpr bool is_valid_symbol( symbol_name sym ) {
sym >>= 8;
for( int i = 0; i < 7; ++i ) {
char c = (char)(sym & 0xff);
if( !('A' <= c && c <= 'Z') ) return false;
sym >>= 8;
if( !(sym & 0xff) ) {
do {
sym >>= 8;
if( (sym & 0xff) ) return false;
++i;
} while( i < 7 );
}
}
return true;
}
static constexpr uint32_t symbol_name_length( symbol_name tmp ) {
tmp >>= 8; /// skip precision
uint32_t length = 0;
while( tmp & 0xff && length <= 7) {
++length;
tmp >>= 8;
}
return length;
}
struct symbol_type {
symbol_name value;
symbol_type() { }
symbol_type(symbol_name s): value(s) { }
bool is_valid()const { return is_valid_symbol( value ); }
uint64_t precision()const { return value & 0xff; }
uint64_t name()const { return value >> 8; }
uint32_t name_length()const { return symbol_name_length( value ); }
operator symbol_name()const { return value; }
void print(bool show_precision=true)const {
if( show_precision ){
::eosio::print(precision());
prints(",");
}
auto sym = value;
sym >>= 8;
for( int i = 0; i < 7; ++i ) {
char c = (char)(sym & 0xff);
if( !c ) return;
prints_l(&c, 1 );
sym >>= 8;
}
}
EOSLIB_SERIALIZE( symbol_type, (value) )
};
struct extended_symbol : public symbol_type
{
extended_symbol( symbol_name s = 0, account_name c = 0 ):symbol_type{s},contract(c){}
account_name contract;
void print()const {
symbol_type::print();
prints("@");
printn( contract );
}
friend bool operator == ( const extended_symbol& a, const extended_symbol& b ) {
return std::tie( a.value, a.contract ) == std::tie( b.value, b.contract );
}
friend bool operator != ( const extended_symbol& a, const extended_symbol& b ) {
return std::tie( a.value, a.contract ) != std::tie( b.value, b.contract );
}
EOSLIB_SERIALIZE( extended_symbol, (value)(contract) )
};
} /// namespace eosio
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/eosio/chain/core_symbol.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/eosio/chain/core_symbol.hpp)
file(GLOB HEADERS "include/eosio/chain/*.hpp" "include/eosio/chain/contracts/*.hpp")
## SORT .cpp by most likely to change / break compile
......
......@@ -7,13 +7,6 @@
#include <eosio/chain/types.hpp>
#include <eosio/chain/symbol.hpp>
/// eos with 8 digits of precision
#define SYS_SYMBOL_VALUE (int64_t(4) | (uint64_t('S') << 8) | (uint64_t('Y') << 16) | (uint64_t('S') << 24))
static const eosio::chain::symbol SYS_SYMBOL(SYS_SYMBOL_VALUE);
/// Defined to be largest power of 10 that fits in 53 bits of precision
#define EOS_MAX_SHARE_SUPPLY int64_t(1'000'000'000'000'000ll)
namespace eosio { namespace chain {
/**
......@@ -29,7 +22,7 @@ struct asset
{
static constexpr int64_t max_amount = (1LL << 62) - 1;
explicit asset(share_type a = 0, symbol id = SYS_SYMBOL) :amount(a), sym(id) {
explicit asset(share_type a = 0, symbol id = symbol(CORE_SYMBOL)) :amount(a), sym(id) {
EOS_ASSERT( is_amount_within_range(), asset_type_exception, "magnitude of asset amount must be less than 2^62" );
EOS_ASSERT( sym.valid(), asset_type_exception, "invalid symbol" );
}
......
/** @file
* @copyright defined in eos/LICENSE.txt
*
* \warning This file is machine generated. DO NOT EDIT. See core_symbol.hpp.in for changes.
*/
#define CORE_SYMBOL SY(4,${CORE_SYMBOL_NAME})
#define CORE_SYMBOL_NAME "${CORE_SYMBOL_NAME}"
\ No newline at end of file
......@@ -5,6 +5,7 @@
#pragma once
#include <fc/exception/exception.hpp>
#include <eosio/chain/types.hpp>
#include <eosio/chain/core_symbol.hpp>
#include <string>
#include <functional>
......@@ -65,7 +66,7 @@ namespace eosio {
explicit symbol(uint8_t p, const char* s): m_value(string_to_symbol(p, s)) {
FC_ASSERT(valid(), "invalid symbol: ${s}", ("s",s));
}
explicit symbol(uint64_t v = SY(4, SYS)): m_value(v) {
explicit symbol(uint64_t v = CORE_SYMBOL): m_value(v) {
FC_ASSERT(valid(), "invalid symbol: ${name}", ("name",name()));
}
static symbol from_string(const string& from)
......
......@@ -24,6 +24,8 @@ std::ostream& operator<<( std::ostream& osm, const fc::variant_object& v );
std::ostream& operator<<( std::ostream& osm, const fc::variant_object::entry& e );
eosio::chain::asset core_from_string(const std::string& s);
namespace boost { namespace test_tools { namespace tt_detail {
template<>
......
......@@ -7,6 +7,10 @@
#include <eosio.bios/eosio.bios.wast.hpp>
#include <eosio.bios/eosio.bios.abi.hpp>
eosio::chain::asset core_from_string(const std::string& s) {
return eosio::chain::asset::from_string(s + " " CORE_SYMBOL_NAME);
}
namespace eosio { namespace testing {
bool expect_assert_message(const fc::exception& ex, string expected) {
......
......@@ -22,6 +22,8 @@ target_include_directories( plugin_test PUBLIC ${CMAKE_SOURCE_DIR}/plugins/net_p
add_dependencies(plugin_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}/core_symbol.py.in ${CMAKE_CURRENT_SOURCE_DIR}/core_symbol.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/p2p_tests/sync/test.sh ${CMAKE_CURRENT_BINARY_DIR}/p2p_tests/sync/test.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/p2p_tests/dawn_515/test.sh ${CMAKE_CURRENT_BINARY_DIR}/p2p_tests/dawn_515/test.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/trans_sync_across_mixed_cluster_test.sh ${CMAKE_CURRENT_BINARY_DIR}/trans_sync_across_mixed_cluster_test.sh COPYONLY)
......@@ -30,6 +32,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/distributed-transactions-remote-test.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sample-cluster-map.json ${CMAKE_CURRENT_BINARY_DIR}/sample-cluster-map.json COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/restart-scenarios-test.py ${CMAKE_CURRENT_BINARY_DIR}/restart-scenarios-test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testUtils.py ${CMAKE_CURRENT_BINARY_DIR}/testUtils.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/core_symbol.py ${CMAKE_CURRENT_BINARY_DIR}/core_symbol.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_run_test.py ${CMAKE_CURRENT_BINARY_DIR}/nodeos_run_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_run_remote_test.py ${CMAKE_CURRENT_BINARY_DIR}/nodeos_run_remote_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/consensus-validation-malicious-producers.py ${CMAKE_CURRENT_BINARY_DIR}/consensus-validation-malicious-producers.py COPYONLY)
......
CORE_SYMBOL='${CORE_SYMBOL_NAME}'
\ No newline at end of file
......@@ -15,6 +15,7 @@ import re
Print=testUtils.Utils.Print
errorExit=testUtils.Utils.errorExit
from core_symbol import CORE_SYMBOL
def cmdError(name, cmdCode=0, exitNow=False):
msg="FAILURE - %s%s" % (name, ("" if cmdCode == 0 else (" returned error code %d" % cmdCode)))
......@@ -255,7 +256,7 @@ try:
if not node.verifyAccount(testeraAccount):
errorExit("FAILURE - account creation failed.", raw=True)
transferAmount="97.5321 SYS"
transferAmount="97.5321 {0}".format(CORE_SYMBOL)
Print("Transfer funds %s from account %s to %s" % (transferAmount, defproduceraAccount.name, testeraAccount.name))
if node.transferFunds(defproduceraAccount, testeraAccount, transferAmount, "test transfer") is None:
cmdError("%s transfer" % (ClientName))
......@@ -269,7 +270,7 @@ try:
cmdError("FAILURE - transfer failed")
errorExit("Transfer verification failed. Excepted %s, actual: %s" % (expectedAmount, actualAmount))
transferAmount="0.0100 SYS"
transferAmount="0.0100 {0}".format(CORE_SYMBOL)
Print("Force transfer funds %s from account %s to %s" % (
transferAmount, defproduceraAccount.name, testeraAccount.name))
if node.transferFunds(defproduceraAccount, testeraAccount, transferAmount, "test transfer", force=True) is None:
......@@ -277,7 +278,7 @@ try:
errorExit("Failed to force transfer funds %d from account %s to %s" % (
transferAmount, defproduceraAccount.name, testeraAccount.name))
expectedAmount="97.5421 SYS"
expectedAmount="97.5421 {0}".format(CORE_SYMBOL)
Print("Verify transfer, Expected: %s" % (expectedAmount))
actualAmount=node.getAccountEosBalanceStr(testeraAccount.name)
if expectedAmount != actualAmount:
......@@ -298,7 +299,7 @@ try:
cmdError("%s wallet unlock" % (ClientName))
errorExit("Failed to unlock wallet %s" % (testWallet.name))
transferAmount="97.5311 SYS"
transferAmount="97.5311 {0}".format(CORE_SYMBOL)
Print("Transfer funds %s from account %s to %s" % (
transferAmount, testeraAccount.name, currencyAccount.name))
trans=node.transferFunds(testeraAccount, currencyAccount, transferAmount, "test transfer a->b")
......@@ -308,7 +309,7 @@ try:
transferAmount, testeraAccount.name, currencyAccount.name))
transId=testUtils.Node.getTransId(trans)
expectedAmount="98.0311 SYS" # 5000 initial deposit
expectedAmount="98.0311 {0}".format(CORE_SYMBOL) # 5000 initial deposit
Print("Verify transfer, Expected: %s" % (expectedAmount))
actualAmount=node.getAccountEosBalanceStr(currencyAccount.name)
if expectedAmount != actualAmount:
......
......@@ -5,6 +5,8 @@ import time
import copy
import threading
from core_symbol import CORE_SYMBOL
class StressNetwork:
speeds=[1,5,10,30,60,100,500]
sec=10
......@@ -50,7 +52,7 @@ class StressNetwork:
print("issue currency0000 into %s" % (acc1.name))
contract="eosio"
action="issue"
data="{\"to\":\"" + acc1.name + "\",\"quantity\":\"1000000.0000 SYS\"}"
data="{\"to\":\"" + acc1.name + "\",\"quantity\":\"1000000.0000 "+CORE_SYMBOL+"\"}"
opts="--permission eosio@active"
tr=node.pushMessage(contract, action, data, opts)
trid = node.getTransId(tr[1])
......
......@@ -17,6 +17,8 @@ import random
import json
import shlex
from core_symbol import CORE_SYMBOL
###########################################################################################
class Utils:
Debug=False
......@@ -537,9 +539,10 @@ class Node(object):
# Create & initialize account and return creation transactions. Return transaction json object
def createInitializeAccount(self, account, creatorAccount, stakedDeposit=1000, waitForTransBlock=False):
cmd='%s %s system newaccount -j %s %s %s %s --stake-net "100 SYS" --stake-cpu "100 SYS" --buy-ram-EOS "100 SYS"' % (
cmd='%s %s system newaccount -j %s %s %s %s --stake-net "100 %s" --stake-cpu "100 %s" --buy-ram-EOS "100 %s"' % (
Utils.EosClientPath, self.endpointArgs, creatorAccount.name, account.name,
account.ownerPublicKey, account.activePublicKey)
account.ownerPublicKey, account.activePublicKey,
CORE_SYMBOL, CORE_SYMBOL, CORE_SYMBOL)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
trans=None
......@@ -553,7 +556,7 @@ class Node(object):
if stakedDeposit > 0:
self.waitForTransIdOnNode(transId) # seems like account creation needs to be finlized before transfer can happen
trans = self.transferFunds(creatorAccount, account, "%0.04f SYS" % (stakedDeposit/10000), "init")
trans = self.transferFunds(creatorAccount, account, "%0.04f %s" % (stakedDeposit/10000, CORE_SYMBOL), "init")
transId=Node.getTransId(trans)
if waitForTransBlock and not self.waitForTransIdOnNode(transId):
......@@ -580,7 +583,7 @@ class Node(object):
if stakedDeposit > 0:
self.waitForTransIdOnNode(transId) # seems like account creation needs to be finlized before transfer can happen
trans = self.transferFunds(creatorAccount, account, "%0.04f SYS" % (stakedDeposit/10000), "init")
trans = self.transferFunds(creatorAccount, account, "%0.04f %s" % (stakedDeposit/10000, CORE_SYMBOL), "init")
transId=Node.getTransId(trans)
if waitForTransBlock and not self.waitForTransIdOnNode(transId):
......@@ -1927,7 +1930,7 @@ class Cluster(object):
contract=eosioTokenAccount.name
Utils.Print("push create action to %s contract" % (contract))
action="create"
data="{\"issuer\":\"%s\",\"maximum_supply\":\"1000000000.0000 SYS\",\"can_freeze\":\"0\",\"can_recall\":\"0\",\"can_whitelist\":\"0\"}" % (eosioTokenAccount.name)
data="{\"issuer\":\"%s\",\"maximum_supply\":\"1000000000.0000 %s\",\"can_freeze\":\"0\",\"can_recall\":\"0\",\"can_whitelist\":\"0\"}" % (eosioTokenAccount.name, CORE_SYMBOL)
opts="--permission %s@active" % (contract)
trans=biosNode.pushMessage(contract, action, data, opts)
if trans is None or not trans[0]:
......@@ -1941,7 +1944,7 @@ class Cluster(object):
contract=eosioTokenAccount.name
Utils.Print("push issue action to %s contract" % (contract))
action="issue"
data="{\"to\":\"%s\",\"quantity\":\"1000000000.0000 SYS\",\"memo\":\"initial issue\"}" % (eosioAccount.name)
data="{\"to\":\"%s\",\"quantity\":\"1000000000.0000 %s\",\"memo\":\"initial issue\"}" % (eosioAccount.name, CORE_SYMBOL)
opts="--permission %s@active" % (contract)
trans=biosNode.pushMessage(contract, action, data, opts)
if trans is None or not trans[0]:
......@@ -1953,7 +1956,7 @@ class Cluster(object):
transId=Node.getTransId(trans[1])
biosNode.waitForTransIdOnNode(transId)
expectedAmount="1000000000.0000 SYS"
expectedAmount="1000000000.0000 {0}".format(CORE_SYMBOL)
Utils.Print("Verify eosio issue, Expected: %s" % (expectedAmount))
actualAmount=biosNode.getAccountEosBalanceStr(eosioAccount.name)
if expectedAmount != actualAmount:
......@@ -1973,7 +1976,7 @@ class Cluster(object):
Node.validateTransaction(trans)
initialFunds="1000000.0000 SYS"
initialFunds="1000000.0000 {0}".format(CORE_SYMBOL)
Utils.Print("Transfer initial fund %s to individual accounts." % (initialFunds))
trans=None
contract=eosioTokenAccount.name
......
......@@ -156,7 +156,7 @@ public:
}
asset get_balance( const account_name& act ) {
return get_currency_balance(N(eosio.token), symbol(SY(4,SYS)), act);
return get_currency_balance(N(eosio.token), symbol(CORE_SYMBOL), act);
}
void set_code_abi(const account_name& account, const char* wast, const char* abi, const private_key_type* signer = nullptr) {
......@@ -202,11 +202,11 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
BOOST_TEST(eosio_token_acc.privileged == true);
// Create EOS tokens in eosio.token, set its manager as eosio
auto max_supply = asset::from_string("10000000000.0000 SYS"); /// 1x larger than 1B initial tokens
auto initial_supply = asset::from_string("1000000000.0000 SYS"); /// 1x larger than 1B initial tokens
// Create SYS tokens in eosio.token, set its manager as eosio
auto max_supply = core_from_string("10000000000.0000"); /// 1x larger than 1B initial tokens
auto initial_supply = core_from_string("1000000000.0000"); /// 1x larger than 1B initial tokens
create_currency(N(eosio.token), config::system_account_name, max_supply);
// Issue the genesis supply of 1 billion EOS tokens to eosio.system
// Issue the genesis supply of 1 billion SYS tokens to eosio.system
issue(N(eosio.token), config::system_account_name, config::system_account_name, initial_supply);
auto actual = get_balance(config::system_account_name);
......@@ -321,7 +321,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
BOOST_REQUIRE(control->head_block_time().time_since_epoch() < first_june_2028);
// This should thrown an error, since block one can only unstake all his stake after 10 years
BOOST_REQUIRE_THROW(undelegate_bandwidth(N(b1), N(b1), asset::from_string("49999500.0000 EOS"), asset::from_string("49999500.0000 EOS")), assert_exception);
BOOST_REQUIRE_THROW(undelegate_bandwidth(N(b1), N(b1), core_from_string("49999500.0000"), core_from_string("49999500.0000")), assert_exception);
// Skip 10 years
produce_block(first_june_2028 - control->head_block_time().time_since_epoch());
......@@ -330,7 +330,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
register_producer(pro);
}
// Block one should be able to unstake all his stake now
undelegate_bandwidth(N(b1), N(b1), asset::from_string("49999500.0000 EOS"), asset::from_string("49999500.0000 EOS"));
undelegate_bandwidth(N(b1), N(b1), core_from_string("49999500.0000"), core_from_string("49999500.0000"));
return;
produce_blocks(7000); /// produce blocks until virutal bandwidth can acomadate a small user
......
......@@ -275,18 +275,18 @@ BOOST_FIXTURE_TEST_CASE(test_symbol, TESTER) try {
}
{
symbol eos(4, "SYS");
BOOST_REQUIRE_EQUAL(SYS_SYMBOL_VALUE, eos.value());
BOOST_REQUIRE_EQUAL("4,SYS", eos.to_string());
BOOST_REQUIRE_EQUAL("SYS", eos.name());
BOOST_REQUIRE_EQUAL(4, eos.decimals());
symbol sys(4, "SYS");
BOOST_REQUIRE_EQUAL(SY(4,SYS), sys.value());
BOOST_REQUIRE_EQUAL("4,SYS", sys.to_string());
BOOST_REQUIRE_EQUAL("SYS", sys.name());
BOOST_REQUIRE_EQUAL(4, sys.decimals());
}
// default is "4,EOS"
// default is "4,${CORE_SYMBOL_NAME}"
{
symbol def;
BOOST_REQUIRE_EQUAL(4, def.decimals());
BOOST_REQUIRE_EQUAL("SYS", def.name());
BOOST_REQUIRE_EQUAL(CORE_SYMBOL_NAME, def.name());
}
// from string
{
......
......@@ -237,18 +237,18 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
push_action(N(eosio.token), N(create), N(eosio.token), mvo()
("issuer", "eosio.token")
("maximum_supply", "1000000000.0000 SYS")
("maximum_supply", core_from_string("1000000000.0000"))
);
push_action(N(eosio.token), N(issue), N(eosio.token), mvo()
("to", "eosio")
("quantity", "1000000000.0000 SYS")
("quantity", core_from_string("1000000000.0000"))
("memo", "")
);
transfer( N(eosio), N(alice), "10000.0000 SYS", "", N(eosio.token) );
transfer( N(eosio), N(bob), "10000.0000 SYS", "", N(eosio.token) );
transfer( N(eosio), N(carol), "10000.0000 SYS", "", N(eosio.token) );
transfer( N(eosio), N(alice), core_from_string("10000.0000"), "", N(eosio.token) );
transfer( N(eosio), N(bob), core_from_string("10000.0000"), "", N(eosio.token) );
transfer( N(eosio), N(carol), core_from_string("10000.0000"), "", N(eosio.token) );
produce_block();
......@@ -257,54 +257,54 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
produce_block();
// Alice deposits 1000 SYS
deposit( N(alice), asset::from_string("1000.0000 SYS"));
// Alice deposits 1000
deposit( N(alice), core_from_string("1000.0000"));
produce_block();
BOOST_REQUIRE_EQUAL( balance_of(N(alice)), asset::from_string("1000.0000 SYS"));
BOOST_REQUIRE_EQUAL( balance_of(N(alice)), core_from_string("1000.0000"));
BOOST_REQUIRE_EQUAL( open_games(N(alice)), 0);
// Alice tries to bet 0 SYS (fail)
// Alice tries to bet 0 (fail)
// secret : 9b886346e1351d4144d0b8392a975612eb0f8b6de7eae1cc9bcc55eb52be343c
BOOST_CHECK_THROW( offer_bet( N(alice), asset::from_string("0.0000 SYS"),
BOOST_CHECK_THROW( offer_bet( N(alice), core_from_string("0.0000"),
commitment_for("9b886346e1351d4144d0b8392a975612eb0f8b6de7eae1cc9bcc55eb52be343c")
), fc::exception);
// Alice bets 10 SYS (success)
// Alice bets 10 (success)
// secret : 0ba044d2833758ee2c8f24d8a3f70c82c334abe6ce13219a4cf3b862abb03c46
offer_bet( N(alice), asset::from_string("10.0000 SYS"),
offer_bet( N(alice), core_from_string("10.0000"),
commitment_for("0ba044d2833758ee2c8f24d8a3f70c82c334abe6ce13219a4cf3b862abb03c46")
);
produce_block();
// Bob tries to bet using a secret previously used by Alice (fail)
// secret : 00000000000000000000000000000002c334abe6ce13219a4cf3b862abb03c46
BOOST_CHECK_THROW( offer_bet( N(bob), asset::from_string("10.0000 SYS"),
BOOST_CHECK_THROW( offer_bet( N(bob), core_from_string("10.0000"),
commitment_for("0ba044d2833758ee2c8f24d8a3f70c82c334abe6ce13219a4cf3b862abb03c46")
), fc::exception);
produce_block();
// Alice tries to bet 1000 SYS (fail)
// Alice tries to bet 1000 (fail)
// secret : a512f6b1b589a8906d574e9de74a529e504a5c53a760f0991a3e00256c027971
BOOST_CHECK_THROW( offer_bet( N(alice), asset::from_string("1000.0000 SYS"),
BOOST_CHECK_THROW( offer_bet( N(alice), core_from_string("1000.0000"),
commitment_for("a512f6b1b589a8906d574e9de74a529e504a5c53a760f0991a3e00256c027971")
), fc::exception);
produce_block();
// Bob tries to bet 90 SYS without deposit
// Bob tries to bet 90 without deposit
// secret : 4facfc98932dde46fdc4403125a16337f6879a842a7ff8b0dc8e1ecddd59f3c8
BOOST_CHECK_THROW( offer_bet( N(bob), asset::from_string("90.0000 SYS"),
BOOST_CHECK_THROW( offer_bet( N(bob), core_from_string("90.0000"),
commitment_for("4facfc98932dde46fdc4403125a16337f6879a842a7ff8b0dc8e1ecddd59f3c8")
), fc::exception);
produce_block();
// Bob deposits 500 SYS
deposit( N(bob), asset::from_string("500.0000 SYS"));
BOOST_REQUIRE_EQUAL( balance_of(N(bob)), asset::from_string("500.0000 SYS"));
// Bob deposits 500
deposit( N(bob), core_from_string("500.0000"));
BOOST_REQUIRE_EQUAL( balance_of(N(bob)), core_from_string("500.0000"));
// Bob bets 11 SYS (success)
// Bob bets 11 (success)
// secret : eec3272712d974c474a3e7b4028b53081344a5f50008e9ccf918ba0725a8d784
offer_bet( N(bob), asset::from_string("11.0000 SYS"),
offer_bet( N(bob), core_from_string("11.0000"),
commitment_for("eec3272712d974c474a3e7b4028b53081344a5f50008e9ccf918ba0725a8d784")
);
produce_block();
......@@ -314,12 +314,12 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
cancel_offer( N(bob), commitment_for("eec3272712d974c474a3e7b4028b53081344a5f50008e9ccf918ba0725a8d784") );
BOOST_REQUIRE_EQUAL( open_offers(N(bob)), 0);
// Carol deposits 300 SYS
deposit( N(carol), asset::from_string("300.0000 SYS"));
// Carol deposits 300
deposit( N(carol), core_from_string("300.0000"));
// Carol bets 10 SYS (success)
// Carol bets 10 (success)
// secret : 3efb4bd5e19b780f4980c919330c0306f8157f93db1fc72c7cefec63e0e7f37a
offer_bet( N(carol), asset::from_string("10.0000 SYS"),
offer_bet( N(carol), core_from_string("10.0000"),
commitment_for("3efb4bd5e19b780f4980c919330c0306f8157f93db1fc72c7cefec63e0e7f37a")
);
produce_block();
......@@ -330,7 +330,7 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
BOOST_REQUIRE_EQUAL( open_games(N(carol)), 1);
BOOST_REQUIRE_EQUAL( open_offers(N(carol)), 0);
BOOST_REQUIRE_EQUAL( game_bet(1), asset::from_string("10.0000 SYS"));
BOOST_REQUIRE_EQUAL( game_bet(1), core_from_string("10.0000"));
// Alice tries to cancel a nonexistent bet (fail)
......@@ -376,31 +376,31 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
BOOST_REQUIRE_EQUAL( open_games(N(alice)), 0);
BOOST_REQUIRE_EQUAL( open_offers(N(alice)), 0);
BOOST_REQUIRE_EQUAL( balance_of(N(alice)), asset::from_string("1010.0000 SYS"));
BOOST_REQUIRE_EQUAL( balance_of(N(alice)), core_from_string("1010.0000"));
BOOST_REQUIRE_EQUAL( open_games(N(carol)), 0);
BOOST_REQUIRE_EQUAL( open_offers(N(carol)), 0);
BOOST_REQUIRE_EQUAL( balance_of(N(carol)), asset::from_string("290.0000 SYS"));
BOOST_REQUIRE_EQUAL( balance_of(N(carol)), core_from_string("290.0000"));
// Alice withdraw 1009 SYS (success)
withdraw( N(alice), asset::from_string("1009.0000 SYS"));
BOOST_REQUIRE_EQUAL( balance_of(N(alice)), asset::from_string("1.0000 SYS"));
// Alice withdraw 1009 (success)
withdraw( N(alice), core_from_string("1009.0000"));
BOOST_REQUIRE_EQUAL( balance_of(N(alice)), core_from_string("1.0000"));
BOOST_REQUIRE_EQUAL(
get_currency_balance(N(eosio.token), SYS_SYMBOL, N(alice)),
asset::from_string("10009.0000 SYS")
get_currency_balance(N(eosio.token), symbol(CORE_SYMBOL), N(alice)),
core_from_string("10009.0000")
);
// Alice withdraw 2 SYS (fail)
BOOST_CHECK_THROW( withdraw( N(alice), asset::from_string("2.0000 SYS")),
// Alice withdraw 2 (fail)
BOOST_CHECK_THROW( withdraw( N(alice), core_from_string("2.0000")),
fc::exception);
// Alice withdraw 1 SYS (success)
withdraw( N(alice), asset::from_string("1.0000 SYS"));
// Alice withdraw 1 (success)
withdraw( N(alice), core_from_string("1.0000"));
BOOST_REQUIRE_EQUAL(
get_currency_balance(N(eosio.token), SYS_SYMBOL, N(alice)),
asset::from_string("10010.0000 SYS")
get_currency_balance(N(eosio.token), symbol(CORE_SYMBOL), N(alice)),
core_from_string("10010.0000")
);
// Verify alice account was deleted
......
此差异已折叠。
......@@ -62,14 +62,14 @@ BOOST_AUTO_TEST_CASE( forking ) try {
auto cr = c.push_action( N(eosio.token), N(create), N(eosio.token), mutable_variant_object()
("issuer", "eosio" )
("maximum_supply", "10000000.0000 SYS")
("maximum_supply", core_from_string("10000000.0000"))
);
wdump((fc::json::to_pretty_string(cr)));
cr = c.push_action( N(eosio.token), N(issue), N(eosio), mutable_variant_object()
("to", "dan" )
("quantity", "100.0000 SYS")
("quantity", core_from_string("100.0000"))
("memo", "")
);
......
......@@ -53,7 +53,7 @@ public:
}
transaction_trace_ptr create_account_with_resources( account_name a, account_name creator, asset ramfunds, bool multisig,
asset net = asset::from_string("10.0000 SYS"), asset cpu = asset::from_string("10.0000 SYS") ) {
asset net = core_from_string("10.0000"), asset cpu = core_from_string("10.0000") ) {
signed_transaction trx;
set_transaction_headers(trx);
......@@ -97,17 +97,14 @@ public:
void create_currency( name contract, name manager, asset maxsupply ) {
auto act = mutable_variant_object()
("issuer", manager )
("maximum_supply", maxsupply )
("can_freeze", 0)
("can_recall", 0)
("can_whitelist", 0);
("maximum_supply", maxsupply );
base_tester::push_action(contract, N(create), contract, act );
}
void issue( name to, const string& amount, name manager = config::system_account_name ) {
void issue( name to, const asset& amount, name manager = config::system_account_name ) {
base_tester::push_action( N(eosio.token), N(issue), manager, mutable_variant_object()
("to", to )
("quantity", asset::from_string(amount) )
("quantity", amount )
("memo", "")
);
}
......@@ -120,7 +117,7 @@ public:
);
}
asset get_balance( const account_name& act ) {
//return get_currency_balance( config::system_account_name, symbol(SY(4,EOS)), act );
//return get_currency_balance( config::system_account_name, symbol(CORE_SYMBOL), act );
//temporary code. current get_currency_balancy uses table name N(accounts) from currency.h
//generic_currency table name is N(account).
const auto& db = control->db();
......@@ -129,14 +126,14 @@ public:
// the balance is implied to be 0 if either the table or row does not exist
if (tbl) {
const auto *obj = db.find<key_value_object, by_scope_primary>(boost::make_tuple(tbl->id, symbol(SY(4,SYS)).to_symbol_code()));
const auto *obj = db.find<key_value_object, by_scope_primary>(boost::make_tuple(tbl->id, symbol(CORE_SYMBOL).to_symbol_code()));
if (obj) {
// balance is the first field in the serialization
fc::datastream<const char *> ds(obj->value.data(), obj->value.size());
fc::raw::unpack(ds, result);
}
}
return asset( result, symbol(SY(4,SYS)) );
return asset( result, symbol(CORE_SYMBOL) );
}
transaction_trace_ptr push_action( const account_name& signer, const action_name& name, const variant_object& data, bool auth = true ) {
......@@ -421,20 +418,20 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
set_code( N(eosio.token), eosio_token_wast );
set_abi( N(eosio.token), eosio_token_abi );
create_currency( N(eosio.token), config::system_account_name, asset::from_string("10000000000.0000 SYS") );
issue(config::system_account_name, "1000000000.0000 SYS");
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 SYS"), get_balance( "eosio" ) );
create_currency( N(eosio.token), config::system_account_name, core_from_string("10000000000.0000") );
issue(config::system_account_name, core_from_string("1000000000.0000"));
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance( "eosio" ) );
set_code( config::system_account_name, eosio_system_wast );
set_abi( config::system_account_name, eosio_system_abi );
produce_blocks();
create_account_with_resources( N(alice1111111), N(eosio), asset::from_string("1.0000 SYS"), false );
create_account_with_resources( N(bob111111111), N(eosio), asset::from_string("0.4500 SYS"), false );
create_account_with_resources( N(carol1111111), N(eosio), asset::from_string("1.0000 SYS"), false );
create_account_with_resources( N(alice1111111), N(eosio), core_from_string("1.0000"), false );
create_account_with_resources( N(bob111111111), N(eosio), core_from_string("0.4500"), false );
create_account_with_resources( N(carol1111111), N(eosio), core_from_string("1.0000"), false );
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 SYS"), get_balance( "eosio" ) );
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance( "eosio" ) );
vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name },
{N(carol), config::active_name} };
......@@ -508,7 +505,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
BOOST_REQUIRE_EQUAL( transaction_receipt::executed, trace->receipt->status );
// can't create account because system contract was replace by the test_api contract
BOOST_REQUIRE_EXCEPTION(create_account_with_resources( N(alice1111112), N(eosio), asset::from_string("1.0000 SYS"), false ),
BOOST_REQUIRE_EXCEPTION(create_account_with_resources( N(alice1111112), N(eosio), core_from_string("1.0000"), false ),
fc::assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "condition: assertion failed: Unknown Test");
......@@ -532,20 +529,20 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
set_code( N(eosio.token), eosio_token_wast );
set_abi( N(eosio.token), eosio_token_abi );
create_currency( N(eosio.token), config::system_account_name, asset::from_string("10000000000.0000 SYS") );
issue(config::system_account_name, "1000000000.0000 SYS");
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 SYS"), get_balance( "eosio" ) );
create_currency( N(eosio.token), config::system_account_name, core_from_string("10000000000.0000") );
issue(config::system_account_name, core_from_string("1000000000.0000"));
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance( "eosio" ) );
set_code( config::system_account_name, eosio_system_wast );
set_abi( config::system_account_name, eosio_system_abi );
produce_blocks();
create_account_with_resources( N(alice1111111), N(eosio), asset::from_string("1.0000 SYS"), false );
create_account_with_resources( N(bob111111111), N(eosio), asset::from_string("0.4500 SYS"), false );
create_account_with_resources( N(carol1111111), N(eosio), asset::from_string("1.0000 SYS"), false );
create_account_with_resources( N(alice1111111), N(eosio), core_from_string("1.0000"), false );
create_account_with_resources( N(bob111111111), N(eosio), core_from_string("0.4500"), false );
create_account_with_resources( N(carol1111111), N(eosio), core_from_string("1.0000"), false );
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 SYS"), get_balance( "eosio" ) );
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance( "eosio" ) );
vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name },
{N(carol), config::active_name}, {N(apple), config::active_name}};
......@@ -634,7 +631,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
BOOST_REQUIRE_EQUAL( transaction_receipt::executed, trace->receipt->status );
// can't create account because system contract was replace by the test_api contract
BOOST_REQUIRE_EXCEPTION(create_account_with_resources( N(alice1111112), N(eosio), asset::from_string("1.0000 SYS"), false ),
BOOST_REQUIRE_EXCEPTION(create_account_with_resources( N(alice1111112), N(eosio), core_from_string("1.0000"), false ),
fc::assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "condition: assertion failed: Unknown Test");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册