提交 ea85e14e 编写于 作者: B Bart Wyatt

merge slim @ 7c1827cd

......@@ -10,6 +10,7 @@
*.dot
*.abi.hpp
*.cmake
*.ninja
\#*
\.#*
CMakeCache.txt
......@@ -29,6 +30,9 @@ libraries/egenesis/egenesis_full.cpp
libraries/egenesis/embed_genesis
libraries/types/type_generator
libraries/types/types_test
libraries/fc/test/crypto/test_cypher_suites
libraries/testing/chain_tester
libraries/wallet/Doxyfile
libraries/wallet/api_documentation.cpp
......@@ -39,26 +43,24 @@ libraries/wasm-jit/Source/Programs/Disassemble
libraries/wasm-jit/Source/Programs/Test
libraries/wasm-jit/Source/Programs/wavm
programs/cli_wallet/cli_wallet
programs/cleos/cleos
programs/js_operation_serializer/js_operation_serializer
programs/witness_node/witness_node
programs/data-dir
programs/eos-walletd/eos-walletd
programs/eosiod/eosiod
programs/eosioc/eosioc
programs/launcher/launcher
programs/eosio-abigen/eosio-abigen
programs/cleos/config.hpp
programs/eosio-applesedemo/eosio-applesedemo
programs/eosio-launcher/config.hpp
programs/eosio-launcher/eosio-launcher
programs/keosd/keosd
programs/nodeos/config.hpp
programs/nodeos/nodeos
scripts/tn_init.sh
tests/app_test
tests/chain_bench
tests/chain_test
tests/intense_test
tests/performance_test
tests/plugin_test
tests/config.hpp
unittests/config.hpp
unittests/unit_test
doxygen
......@@ -67,10 +69,6 @@ witness_node_data_dir
*.wallet
programs/witness_node/object_database/*
object_database/*
*.pyc
*.pyo
......
......@@ -35,7 +35,7 @@ namespace eosiosystem {
account_name owner;
asset net_weight;
asset cpu_weight;
uint64_t storage_bytes = 0;
int64_t storage_bytes = 0;
uint64_t primary_key()const { return owner; }
......@@ -102,7 +102,7 @@ namespace eosiosystem {
user_resources_table userres( _self, newact);
auto r = userres.emplace( newact, [&]( auto& res ) {
userres.emplace( newact, [&]( auto& res ) {
res.owner = newact;
});
......@@ -117,21 +117,12 @@ 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 ) {
const double system_token_supply = eosio::token(N(eosio.token)).get_supply(eosio::symbol_type(system_token_symbol).name()).amount;
const double unstaked_token_supply = system_token_supply - _gstate.total_storage_stake.amount;
const double R = unstaked_token_supply;
const double C = _gstate.free_ram() + bytes;
const double F = _gstate.storage_reserve_ratio / 10000.0;
const double T = bytes;
const double ONE(1.0);
double E = -R * (ONE - std::pow( ONE + T/C, F ) );
int64_t tokens_out = int64_t(E*1.0105);
print( "desired ram: ", bytes, "\n" );
buyram( payer, receiver, asset(tokens_out) );
auto itr = _rammarket.find(S(4,RAMEOS));
auto tmp = *itr;
auto eosout = tmp.convert( asset(bytes,S(0,RAM)), S(4,EOS) );
print( "eosout: ", eosout, "\n" );
buyram( payer, receiver, eosout );
}
......@@ -154,20 +145,15 @@ namespace eosiosystem {
{ payer, N(eosio), quant, std::string("buy ram") } );
}
const double system_token_supply = eosio::token(N(eosio.token)).get_supply(eosio::symbol_type(system_token_symbol).name()).amount;
const double unstaked_token_supply = system_token_supply - _gstate.total_storage_stake.amount;
print( "free ram: ", _gstate.free_ram(), "\n");
print( "free ram: ", _gstate.free_ram(), " tokens: ", system_token_supply, " unstaked: ", unstaked_token_supply, "\n" );
int64_t bytes_out;
const double E = quant.amount;
const double R = unstaked_token_supply - E;
const double C = _gstate.free_ram(); //free_ram;
const double F = 1./(_gstate.storage_reserve_ratio/10000.0); /// 10% reserve ratio pricing, assumes only 10% of tokens will ever want to stake for ram
const double ONE(1.0);
auto itr = _rammarket.find(S(4,RAMEOS));
_rammarket.modify( itr, 0, [&]( auto& es ) {
bytes_out = es.convert( quant, S(0,RAM) ).amount;
});
double T = C * (std::pow( ONE + E/R, F ) - ONE);
T *= .99; /// 1% fee on every conversion
int64_t bytes_out = static_cast<int64_t>(T);
print( "ram bytes out: ", bytes_out, "\n" );
eosio_assert( bytes_out > 0, "must reserve a positive amount" );
......@@ -180,11 +166,11 @@ namespace eosiosystem {
if( res_itr == userres.end() ) {
res_itr = userres.emplace( receiver, [&]( auto& res ) {
res.owner = receiver;
res.storage_bytes = uint64_t(bytes_out);
res.storage_bytes = bytes_out;
});
} else {
userres.modify( res_itr, receiver, [&]( auto& res ) {
res.storage_bytes += uint64_t(bytes_out);
res.storage_bytes += bytes_out;
});
}
set_resource_limits( res_itr->owner, res_itr->storage_bytes, res_itr->net_weight.amount, res_itr->cpu_weight.amount );
......@@ -197,35 +183,30 @@ namespace eosiosystem {
* and selling ram.
*/
void system_contract::sellram( account_name account, uint32_t bytes ) {
require_auth( account );
user_resources_table userres( _self, account );
auto res_itr = userres.find( account );
eosio_assert( res_itr != userres.end(), "no resource row" );
eosio_assert( res_itr->storage_bytes >= bytes, "insufficient quota" );
const double system_token_supply = eosio::token(N(eosio.token)).get_supply(eosio::symbol_type(system_token_symbol).name()).amount;
const double unstaked_token_supply = system_token_supply - _gstate.total_storage_stake.amount;
const double R = unstaked_token_supply;
const double C = _gstate.free_ram() + bytes;
const double F = _gstate.storage_reserve_ratio / 10000.0;
const double T = bytes;
const double ONE(1.0);
double E = -R * (ONE - std::pow( ONE + T/C, F ) );
E *= .99; /// 1% fee on every conversion,
/// let the system contract profit on speculation while preventing abuse caused by rounding errors
int64_t tokens_out = int64_t(E);
eosio_assert( tokens_out > 0, "must free at least one token" );
asset tokens_out;
auto itr = _rammarket.find(S(4,RAMEOS));
_rammarket.modify( itr, 0, [&]( auto& es ) {
tokens_out = es.convert( asset(bytes,S(0,RAM)), S(4,EOS) );
print( "out: ", tokens_out, "\n" );
});
_gstate.total_storage_bytes_reserved -= bytes;
_gstate.total_storage_stake.amount -= tokens_out;
_gstate.total_storage_stake.amount -= tokens_out.amount;
//// this shouldn't happen, but just in case it does we should prevent it
eosio_assert( _gstate.total_storage_stake.amount >= 0, "error, attempt to unstake more tokens than previously staked" );
userres.modify( res_itr, account, [&]( auto& res ) {
res.storage_bytes -= bytes;
});
set_resource_limits( res_itr->owner, res_itr->storage_bytes, uint64_t(res_itr->net_weight.amount), uint64_t(res_itr->cpu_weight.amount) );
set_resource_limits( res_itr->owner, res_itr->storage_bytes, res_itr->net_weight.amount, res_itr->cpu_weight.amount );
if( N(eosio) != account ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)},
......@@ -281,7 +262,7 @@ namespace eosiosystem {
});
}
set_resource_limits( tot_itr->owner, tot_itr->storage_bytes, uint64_t(tot_itr->net_weight.amount), uint64_t(tot_itr->cpu_weight.amount) );
set_resource_limits( tot_itr->owner, tot_itr->storage_bytes, tot_itr->net_weight.amount, tot_itr->cpu_weight.amount );
if( N(eosio) != from) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {from,N(active)},
......
......@@ -4,6 +4,7 @@
#include "delegate_bandwidth.cpp"
#include "producer_pay.cpp"
#include "voting.cpp"
#include "exchange_state.cpp"
namespace eosiosystem {
......@@ -12,10 +13,27 @@ namespace eosiosystem {
:native(s),
_voters(_self,_self),
_producers(_self,_self),
_global(_self,_self)
_global(_self,_self),
_rammarket(_self,_self)
{
print( "construct system\n" );
_gstate = _global.exists() ? _global.get() : get_default_parameters();
auto itr = _rammarket.find(S(4,RAMEOS));
if( itr == _rammarket.end() ) {
auto system_token_supply = eosio::token(N(eosio.token)).get_supply(eosio::symbol_type(system_token_symbol).name()).amount;
itr = _rammarket.emplace( _self, [&]( auto& m ) {
m.supply.amount = 100000000000000ll;
m.supply.symbol = S(4,RAMEOS);
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,EOS);
});
} else {
print( "ram market already created" );
}
}
eosio_global_state system_contract::get_default_parameters() {
......
......@@ -8,6 +8,7 @@
#include <eosiolib/asset.hpp>
#include <eosiolib/privileged.hpp>
#include <eosiolib/singleton.hpp>
#include <eosio.system/exchange_state.hpp>
#include <string>
......@@ -116,6 +117,7 @@ namespace eosiosystem {
global_state_singleton _global;
eosio_global_state _gstate;
rammarket _rammarket;
public:
system_contract( account_name s );
......
#include <exchange/exchange_state.hpp>
namespace eosiosystem {
asset exchange_state::convert_to_exchange( connector& c, asset in ) {
real_type R(supply.amount);
real_type C(c.balance.amount+in.amount);
real_type F(c.weight/1000.0);
real_type T(in.amount);
real_type ONE(1.0);
real_type E = -R * (ONE - std::pow( ONE + T / C, F) );
//print( "E: ", E, "\n");
int64_t issued = int64_t(E);
supply.amount += issued;
c.balance.amount += in.amount;
return asset( issued, supply.symbol );
}
asset exchange_state::convert_from_exchange( connector& c, asset in ) {
eosio_assert( in.symbol== supply.symbol, "unexpected asset symbol input" );
real_type R(supply.amount - in.amount);
real_type C(c.balance.amount);
real_type F(1000.0/c.weight);
real_type E(in.amount);
real_type ONE(1.0);
real_type T = C * (std::pow( ONE + E/R, F) - ONE);
//print( "T: ", T, "\n");
int64_t out = int64_t(T);
supply.amount -= in.amount;
c.balance.amount -= out;
return asset( out, c.balance.symbol );
}
asset exchange_state::convert( asset from, symbol_type to ) {
auto sell_symbol = from.symbol;
auto ex_symbol = supply.symbol;
auto base_symbol = base.balance.symbol;
auto quote_symbol = quote.balance.symbol;
//print( "From: ", from, " TO ", asset( 0,to), "\n" );
//print( "base: ", base_symbol, "\n" );
//print( "quote: ", quote_symbol, "\n" );
//print( "ex: ", supply.symbol, "\n" );
if( sell_symbol != ex_symbol ) {
if( sell_symbol == base_symbol ) {
from = convert_to_exchange( base, from );
} else if( sell_symbol == quote_symbol ) {
from = convert_to_exchange( quote, from );
} else {
eosio_assert( false, "invalid sell" );
}
} else {
if( to == base_symbol ) {
from = convert_from_exchange( base, from );
} else if( to == quote_symbol ) {
from = convert_from_exchange( quote, from );
} else {
eosio_assert( false, "invalid conversion" );
}
}
if( to != from.symbol )
return convert( from, to );
return from;
}
} /// namespace eosiosystem
#pragma once
#include <eosiolib/asset.hpp>
namespace eosiosystem {
using eosio::asset;
using eosio::symbol_type;
typedef double real_type;
/**
* Uses Bancor math to create a 50/50 relay between two asset types. The state of the
* bancor exchange is entirely contained within this struct. There are no external
* side effects associated with using this API.
*/
struct exchange_state {
asset supply;
struct connector {
asset balance;
double weight = .5;
EOSLIB_SERIALIZE( connector, (balance)(weight) )
};
connector base;
connector quote;
uint64_t primary_key()const { return supply.symbol; }
asset convert_to_exchange( connector& c, asset in );
asset convert_from_exchange( connector& c, asset in );
asset convert( asset from, symbol_type to );
EOSLIB_SERIALIZE( exchange_state, (supply)(base)(quote) )
};
typedef eosio::multi_index<N(rammarket), exchange_state> rammarket;
} /// namespace eosiosystem
......@@ -39,7 +39,7 @@ namespace eosiosystem {
* @pre authority of producer to register
*
*/
void system_contract::regproducer( const account_name producer, const public_key& producer_key, const std::string& url ) { //, const eosio_parameters& prefs ) {
void system_contract::regproducer( const account_name producer, const eosio::public_key& producer_key, const std::string& url ) { //, const eosio_parameters& prefs ) {
eosio_assert( url.size() < 512, "url too long" );
//eosio::print("produce_key: ", producer_key.size(), ", sizeof(public_key): ", sizeof(public_key), "\n");
require_auth( producer );
......@@ -67,7 +67,7 @@ namespace eosiosystem {
const auto& prod = _producers.get( producer );
_producers.modify( prod, 0, [&]( producer_info& info ){
info.producer_key = public_key();
info.producer_key = eosio::public_key();
});
}
......
......@@ -63,10 +63,10 @@ namespace eosio {
static constexpr uint8_t max_precision = 18;
explicit symbol(uint8_t p, const char* s): m_value(string_to_symbol(p, s)) {
FC_ASSERT(valid(), "invalid symbol", ("s",s));
FC_ASSERT(valid(), "invalid symbol: ${s}", ("s",s));
}
explicit symbol(uint64_t v = SY(4, EOS)): m_value(v) {
FC_ASSERT(valid(), "invalid symbol", ("name",name()));
FC_ASSERT(valid(), "invalid symbol: ${name}", ("name",name()));
}
static symbol from_string(const string& from)
{
......
......@@ -401,6 +401,24 @@ chain::action create_action(const vector<permission_level>& authorization, const
return chain::action{authorization, code, act, result.get_object()["binargs"].as<bytes>()};
}
chain::action create_buyram(const name& creator, const name& newaccount, const asset& quantity) {
fc::variant act_payload = fc::mutable_variant_object()
("payer", creator.to_string())
("receiver", newaccount.to_string())
("quant", quantity.to_string());
return create_action(tx_permission.empty() ? vector<chain::permission_level>{{creator,config::active_name}} : get_account_permissions(tx_permission),
config::system_account_name, N(buyram), act_payload);
}
chain::action create_buyrambytes(const name& creator, const name& newaccount, uint32_t numbytes) {
fc::variant act_payload = fc::mutable_variant_object()
("payer", creator.to_string())
("receiver", newaccount.to_string())
("bytes", numbytes);
return create_action(tx_permission.empty() ? vector<chain::permission_level>{{creator,config::active_name}} : get_account_permissions(tx_permission),
config::system_account_name, N(buyrambytes), act_payload);
}
fc::variant regproducer_variant(const account_name& producer,
public_key_type key,
string url) {
......@@ -923,12 +941,18 @@ int main( int argc, char** argv ) {
string account_name;
string owner_key_str;
string active_key_str;
uint32_t buy_ram_bytes_in_kbytes = 8;
string buy_ram_eos;
auto createAccount = create->add_subcommand("account", localized("Create a new account on the blockchain"), false);
createAccount->add_option("creator", creator, localized("The name of the account creating the new account"))->required();
createAccount->add_option("name", account_name, localized("The name of the new account"))->required();
createAccount->add_option("OwnerKey", owner_key_str, localized("The owner public key for the new account"))->required();
createAccount->add_option("ActiveKey", active_key_str, localized("The active public key for the new account"))->required();
createAccount->add_option("--buy-ram-bytes", buy_ram_bytes_in_kbytes,
(localized("The amount of RAM bytes to purchase for the new account in kilobytes KiB, default is 8 KiB")));
createAccount->add_option("--buy-ram-EOS", buy_ram_eos,
(localized("The amount of RAM bytes to purchase for the new account in EOS")));
add_standard_transaction_options(createAccount, "creator@active");
createAccount->set_callback([&] {
public_key_type owner_key, active_key;
......@@ -938,7 +962,15 @@ int main( int argc, char** argv ) {
try {
active_key = public_key_type(active_key_str);
} EOS_RETHROW_EXCEPTIONS(public_key_type_exception, "Invalid active public key: ${public_key}", ("public_key", active_key_str))
send_actions({create_newaccount(creator, account_name, owner_key, active_key)});
if( !buy_ram_eos.empty() ) {
action buyact = create_buyram(creator, account_name, asset::from_string(buy_ram_eos));
send_actions({create_newaccount(creator, account_name, owner_key, active_key), buyact});
} else if( buy_ram_bytes_in_kbytes > 0 ){
action buyact = create_buyrambytes(creator, account_name, buy_ram_bytes_in_kbytes * 1024 * 1024);
send_actions({create_newaccount(creator, account_name, owner_key, active_key), buyact});
} else {
send_actions({create_newaccount(creator, account_name, owner_key, active_key)});
}
});
// Get subcommand
......
......@@ -488,7 +488,7 @@ class Node(object):
# Create account and return creation transactions. Return transaction json object
# waitForTransBlock: wait on creation transaction id to appear in a block
def createAccount(self, account, creatorAccount, stakedDeposit=1000, waitForTransBlock=False):
cmd="%s %s create account -j %s %s %s %s" % (
cmd="%s %s create account -j --buy-ram-bytes 0 %s %s %s %s" % (
Utils.EosClientPath, self.endpointArgs, creatorAccount.name, account.name,
account.ownerPublicKey, account.activePublicKey)
......
......@@ -43,6 +43,7 @@ class currency_tester : public TESTER {
signed_transaction trx;
trx.actions.emplace_back(std::move(act));
set_transaction_headers(trx);
trx.sign(get_private_key(signer, "active"), chain_id_type());
return push_transaction(trx);
......@@ -316,7 +317,7 @@ BOOST_FIXTURE_TEST_CASE(test_symbol, TESTER) try {
// invalid - contains lower case characters, no validation
{
BOOST_CHECK_EXCEPTION(symbol malformed(SY(6,EoS)),
fc::assert_exception, fc_assert_exception_message_is("invalid symbol"));
fc::assert_exception, fc_assert_exception_message_is("invalid symbol: EoS"));
}
// invalid - contains lower case characters, exception thrown
......
......@@ -91,9 +91,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_test ) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
......@@ -235,9 +232,6 @@ BOOST_AUTO_TEST_CASE(delete_auth_test) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
......@@ -259,8 +253,7 @@ BOOST_AUTO_TEST_CASE(delete_auth_test) { try {
("permission", "first")),
permission_query_exception,
[] (const permission_query_exception &e)->bool {
std::string check_str = "3010001 permission_query_exception: Permission Query Exception\nFailed to retrieve permission";
BOOST_REQUIRE_EQUAL(check_str, e.to_detail_string().substr(0, check_str.length()));
expect_assert_message(e, "permission_query_exception: Permission Query Exception\nFailed to retrieve permission");
return true;
});
......@@ -335,8 +328,7 @@ BOOST_AUTO_TEST_CASE(delete_auth_test) { try {
("permission", "first")),
action_validate_exception,
[] (const action_validate_exception &e)->bool {
std::string check_str = "3040000 action_validate_exception: message validation exception\nCannot delete a linked authority";
BOOST_REQUIRE_EQUAL(check_str, e.to_detail_string().substr(0, check_str.length()));
expect_assert_message(e, "action_validate_exception: message validation exception\nCannot delete a linked authority");
return true;
});
......@@ -380,9 +372,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_parent_permission_test ) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
......@@ -524,9 +513,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_walk_parent_permissions_test ) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
......@@ -674,9 +660,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_test ) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
......@@ -871,9 +854,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_with_delay_heirarchy_test ) {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
......@@ -1074,9 +1054,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
......@@ -1170,8 +1147,7 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
30, 3),
transaction_exception,
[] (const transaction_exception &e)->bool {
std::string check_str = "3030000 transaction_exception: transaction validation exception\nauthorization imposes a delay (10 sec) greater than the delay specified in transaction header (3 sec)";
BOOST_REQUIRE_EQUAL(check_str, e.to_detail_string().substr(0, check_str.length()));
expect_assert_message(e, "transaction_exception: transaction validation exception\nauthorization imposes a delay (10 sec) greater than the delay specified in transaction header (3 sec)");
return true;
}
);
......@@ -1282,9 +1258,6 @@ BOOST_AUTO_TEST_CASE( link_delay_unlink_test ) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
......@@ -1369,8 +1342,7 @@ BOOST_AUTO_TEST_CASE( link_delay_unlink_test ) { try {
30, 7),
transaction_exception,
[] (const transaction_exception &e)->bool {
std::string check_str = "3030000 transaction_exception: transaction validation exception\nauthorization imposes a delay (10 sec) greater than the delay specified in transaction header (7 sec)";
BOOST_REQUIRE_EQUAL(check_str, e.to_detail_string().substr(0, check_str.length()));
expect_assert_message(e, "transaction_exception: transaction validation exception\nauthorization imposes a delay (10 sec) greater than the delay specified in transaction header (7 sec)");
return true;
}
);
......@@ -1478,9 +1450,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
......@@ -1675,9 +1644,6 @@ BOOST_AUTO_TEST_CASE( mindelay_test ) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
chain.produce_blocks(10);
......@@ -1811,8 +1777,6 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
TESTER chain;
const auto& tester_account = N(tester);
std::vector<transaction_id_type> ids;
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
......@@ -1907,8 +1871,7 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
),
transaction_exception,
[] (const transaction_exception &e)->bool {
std::string check_str = "3030000 transaction_exception: transaction validation exception\nauthorization imposes a delay (10 sec) greater than the delay specified in transaction header (7 sec)";
BOOST_REQUIRE_EQUAL(check_str, e.to_detail_string().substr(0, check_str.length()));
expect_assert_message(e, "transaction_exception: transaction validation exception\nauthorization imposes a delay (10 sec) greater than the delay specified in transaction header (7 sec)");
return true;
}
);
......@@ -2054,8 +2017,6 @@ BOOST_AUTO_TEST_CASE( canceldelay_test2 ) { try {
TESTER chain;
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(eosio.token));
......@@ -2324,9 +2285,6 @@ BOOST_AUTO_TEST_CASE( max_transaction_delay_create ) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.produce_blocks();
chain.create_account(N(tester));
chain.produce_blocks(10);
......@@ -2338,9 +2296,9 @@ BOOST_AUTO_TEST_CASE( max_transaction_delay_create ) { try {
("parent", "active")
("auth", authority(chain.get_public_key(tester_account, "first"), 50*86400)) ), // 50 days delay
chain::action_validate_exception,
[&](const chain::transaction_exception& ex) {
string expected = "message validation exception (3040000)\nCannot set delay longer than max_transacton_delay, which is 3888000 seconds";
return expected == string(ex.to_string()).substr(0, expected.size());
[&](const chain::transaction_exception& e) {
expect_assert_message(e, "Cannot set delay longer than max_transacton_delay");
return true;
}
);
} FC_LOG_AND_RETHROW() }
......@@ -2352,16 +2310,12 @@ BOOST_AUTO_TEST_CASE( max_transaction_delay_execute ) { try {
const auto& tester_account = N(tester);
chain.set_code(config::system_account_name, eosio_system_wast);
chain.set_abi(config::system_account_name, eosio_system_abi);
chain.create_account(N(eosio.token));
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));
chain.produce_blocks(10);
chain.produce_blocks();
chain.push_action(N(eosio.token), N(create), N(eosio.token), mutable_variant_object()
......@@ -2393,28 +2347,37 @@ BOOST_AUTO_TEST_CASE( max_transaction_delay_execute ) { try {
("requirement", "first"));
BOOST_REQUIRE_EQUAL(transaction_receipt::executed, trace->receipt.status);
chain.produce_blocks();
//change max_transaction_delay to 60 sec
chain.control->db().modify( chain.control->get_global_properties(),
[&]( auto& gprops ) {
gprops.configuration.max_transaction_delay = 60;
});
#ifndef NON_VALIDATING_TEST
chain.validating_node->db().modify( chain.validating_node->get_global_properties(),
[&]( auto& gprops ) {
gprops.configuration.max_transaction_delay = 60;
});
#endif
chain.produce_blocks();
//should be able to create transaction with delay 60 sec, despite permission delay being 30 days, because max_transaction_delay is 60 sec
trace = chain.push_action(N(eosio.token), name("transfer"), N(tester), fc::mutable_variant_object()
("from", "tester")
("to", "eosio.token")
("quantity", "9.0000 CUR")
("memo", "" ),
120, 60
);
chain.produce_block();
("from", "tester")
("to", "eosio.token")
("quantity", "9.0000 CUR")
("memo", "" ), 120, 60);
BOOST_REQUIRE_EQUAL(transaction_receipt::delayed, trace->receipt.status);
chain.produce_blocks();
auto gen_size = chain.control->db().get_index<generated_transaction_multi_index,by_trx_id>().size();
BOOST_REQUIRE_EQUAL(1, gen_size);
BOOST_REQUIRE_EQUAL(0, trace->action_traces.size());
//check that the delayed transaction executed after after 60 sec
chain.produce_block( fc::seconds(60) );
chain.produce_blocks(120);
gen_size = chain.control->db().get_index<generated_transaction_multi_index,by_trx_id>().size();
BOOST_CHECK_EQUAL(0, gen_size);
......
......@@ -37,18 +37,18 @@ public:
create_accounts( { N(eosio.token) } );
produce_blocks( 100 );
set_code( config::system_account_name, eosio_system_wast );
set_abi( config::system_account_name, eosio_system_abi );
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("1000000000.0000 EOS") );
issue(config::system_account_name, "100000000.0000 EOS");
create_currency( N(eosio.token), config::system_account_name, asset::from_string("10000000000.0000 EOS") );
issue(config::system_account_name, "1000000000.0000 EOS");
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 EOS"), get_balance( "eosio" ) );
set_code( config::system_account_name, eosio_system_wast );
set_abi( config::system_account_name, eosio_system_abi );
produce_blocks();
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 EOS"), get_balance( "eosio" ) );
create_account_with_resources( N(alice), N(eosio), asset::from_string("1.0000 EOS"), false );//{ N(alice), N(bob), N(carol) } );
create_account_with_resources( N(bob), N(eosio), asset::from_string("0.4500 EOS"), false );//{ N(alice), N(bob), N(carol) } );
create_account_with_resources( N(carol), N(eosio), asset::from_string("1.0000 EOS"), false );//{ N(alice), N(bob), N(carol) } );
......@@ -313,6 +313,7 @@ BOOST_FIXTURE_TEST_CASE( stake_unstake, eosio_system_tester ) try {
BOOST_REQUIRE_EQUAL( success(), buyram( "alice", "bob", "200.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyrambytes( "alice", "bob", 100 ) );
BOOST_REQUIRE_EQUAL( success(), sellram( "bob", 100 ) );
BOOST_REQUIRE_EQUAL( success(), buyrambytes( "alice", "bob", 10000 ) );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册