提交 376a29db 编写于 作者: B Bucky Kittinger

Merge branch 'fix/eos3012' of github.com:larryk85/eos into fix/eos3012

......@@ -249,8 +249,8 @@ namespace eosio { namespace chain {
3110001, "Missing Chain API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_wallet_api_plugin_exception, missing_plugin_exception,
3110002, "Missing Wallet API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_account_history_api_plugin_exception, missing_plugin_exception,
3110003, "Missing Account History API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_history_api_plugin_exception, missing_plugin_exception,
3110003, "Missing History API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_net_api_plugin_exception, missing_plugin_exception,
3110004, "Missing Net API Plugin" )
......
......@@ -90,16 +90,14 @@ namespace fc { namespace crypto {
static private_key::storage_type parse_base58(const string& base58str)
{
if (base58str.find('_') == std::string::npos) {
const auto pivot = base58str.find('_');
if (pivot == std::string::npos) {
// wif import
using default_type = private_key::storage_type::template type_at<0>;
return private_key::storage_type(from_wif<default_type>(base58str));
} else {
constexpr auto prefix = config::private_key_base_prefix;
const auto pivot = base58str.find('_');
FC_ASSERT(pivot != std::string::npos, "No delimiter in string, cannot determine type: ${str}", ("str", base58str));
const auto prefix_str = base58str.substr(0, pivot);
FC_ASSERT(prefix == prefix_str, "Private Key has invalid prefix: ${str}", ("str", base58str)("prefix_str", prefix_str));
......
......@@ -20,6 +20,3 @@ if(MSVC)
set_source_files_properties( db_init.cpp db_block.cpp database.cpp block_log.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
endif(MSVC)
add_executable( chain_tester test.cpp )
target_link_libraries( chain_tester
PRIVATE eosio_testing eosio_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ${Intl_LIBRARIES} )
#include <eosio/testing/tester.hpp>
#include <fc/io/json.hpp>
#include <eosio.token/eosio.token.wast.hpp>
#include <eosio.token/eosio.token.abi.hpp>
using namespace eosio::chain;
using namespace eosio::testing;
private_key_type get_private_key( name keyname, string role ) {
return private_key_type::regenerate<fc::ecc::private_key_shim>(fc::sha256::hash(string(keyname)+role));
}
public_key_type get_public_key( name keyname, string role ){
return get_private_key( keyname, role ).get_public_key();
}
int main( int argc, char** argv ) {
try { try {
tester c;
c.produce_block();
c.produce_block();
auto r = c.create_accounts( {N(dan),N(sam),N(pam)} );
wdump((fc::json::to_pretty_string(r)));
c.produce_block();
auto res = c.set_producers( {N(dan),N(sam),N(pam)} );
vector<producer_key> sch = { {N(dan),get_public_key(N(dan), "active")},
{N(sam),get_public_key(N(sam), "active")},
{N(pam),get_public_key(N(pam), "active")}};
wdump((fc::json::to_pretty_string(res)));
wlog("set producer schedule to [dan,sam,pam]");
c.produce_blocks(30);
auto r2 = c.create_accounts( {N(eosio.token)} );
wdump((fc::json::to_pretty_string(r2)));
c.set_code( N(eosio.token), eosio_token_wast );
c.set_abi( N(eosio.token), eosio_token_abi );
c.produce_blocks(10);
auto cr = c.push_action( N(eosio.token), N(create), N(eosio.token), mutable_variant_object()
("issuer", "eosio" )
("maximum_supply", "10000000.0000 EOS")
("can_freeze", 0)
("can_recall", 0)
("can_whitelist", 0)
);
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 EOS")
("memo", "")
);
wdump((fc::json::to_pretty_string(cr)));
tester c2;
wlog( "push c1 blocks to c2" );
while( c2.control->head_block_num() < c.control->head_block_num() ) {
auto fb = c.control->fetch_block_by_number( c2.control->head_block_num()+1 );
c2.control->push_block( fb );
}
wlog( "end push c1 blocks to c2" );
wlog( "c1 blocks:" );
c.produce_blocks(3);
signed_block_ptr b;
b = c.produce_block();
account_name expected_producer = N(dan);
FC_ASSERT( b->producer == expected_producer,
"expected block ${n} to be produced by ${expected_producer} but was instead produced by ${actual_producer}",
("n", b->block_num())("expected_producer", expected_producer.to_string())("actual_producer", b->producer.to_string()) );
b = c.produce_block();
expected_producer = N(sam);
FC_ASSERT( b->producer == expected_producer,
"expected block ${n} to be produced by ${expected_producer} but was instead produced by ${actual_producer}",
("n", b->block_num())("expected_producer", expected_producer.to_string())("actual_producer", b->producer.to_string()) );
c.produce_blocks(10);
c.create_accounts( {N(cam)} );
c.set_producers( {N(dan),N(sam),N(pam),N(cam)} );
wlog("set producer schedule to [dan,sam,pam,cam]");
c.produce_block();
// The next block should be produced by pam.
// Sync second chain with first chain.
wlog( "push c1 blocks to c2" );
while( c2.control->head_block_num() < c.control->head_block_num() ) {
auto fb = c.control->fetch_block_by_number( c2.control->head_block_num()+1 );
c2.control->push_block( fb );
}
wlog( "end push c1 blocks to c2" );
// Now sam and pam go on their own fork while dan is producing blocks by himself.
wlog( "sam and pam go off on their own fork on c2 while dan produces blocks by himself in c1" );
auto fork_block_num = c.control->head_block_num();
wlog( "c2 blocks:" );
c2.produce_blocks(12); // pam produces 12 blocks
b = c2.produce_block( fc::milliseconds(config::block_interval_ms * 13) ); // sam skips over dan's blocks
expected_producer = N(sam);
FC_ASSERT( b->producer == expected_producer,
"expected block ${n} to be produced by ${expected_producer} but was instead produced by ${actual_producer}",
("n", b->block_num())("expected_producer", expected_producer.to_string())("actual_producer", b->producer.to_string()) );
c2.produce_blocks(11 + 12);
wlog( "c1 blocks:" );
b = c.produce_block( fc::milliseconds(config::block_interval_ms * 13) ); // dan skips over pam's blocks
expected_producer = N(dan);
FC_ASSERT( b->producer == expected_producer,
"expected block ${n} to be produced by ${expected_producer} but was instead produced by ${actual_producer}",
("n", b->block_num())("expected_producer", expected_producer.to_string())("actual_producer", b->producer.to_string()) );
c.produce_blocks(11);
// dan on chain 1 now gets all of the blocks from chain 2 which should cause fork switch
wlog( "push c2 blocks to c1" );
for( uint32_t start = fork_block_num + 1, end = c2.control->head_block_num(); start <= end; ++start ) {
auto fb = c2.control->fetch_block_by_number( start );
c.control->push_block( fb );
}
wlog( "end push c2 blocks to c1" );
wlog( "c1 blocks:" );
c.produce_blocks(24);
b = c.produce_block(); // Switching active schedule to version 2 happens in this block.
expected_producer = N(pam);
FC_ASSERT( b->producer == expected_producer,
"expected block ${n} to be produced by ${expected_producer} but was instead produced by ${actual_producer}",
("n", b->block_num())("expected_producer", expected_producer.to_string())("actual_producer", b->producer.to_string()) );
b = c.produce_block();
expected_producer = N(cam);
FC_ASSERT( b->producer == expected_producer,
"expected block ${n} to be produced by ${expected_producer} but was instead produced by ${actual_producer}",
("n", b->block_num())("expected_producer", expected_producer.to_string())("actual_producer", b->producer.to_string()) );
c.produce_blocks(10);
wlog( "push c1 blocks to c2" );
while( c2.control->head_block_num() < c.control->head_block_num() ) {
auto fb = c.control->fetch_block_by_number( c2.control->head_block_num()+1 );
c2.control->push_block( fb );
}
wlog( "end push c1 blocks to c2" );
// Now with four block producers active and two identical chains (for now),
// we can test out the case that would trigger the bug in the old fork db code:
fork_block_num = c.control->head_block_num();
wlog( "cam and dan go off on their own fork on c1 while sam and pam go off on their own fork on c2" );
wlog( "c1 blocks:" );
c.produce_blocks(12); // dan produces 12 blocks
c.produce_block( fc::milliseconds(config::block_interval_ms * 25) ); // cam skips over sam and pam's blocks
c.produce_blocks(23); // cam finishes the remaining 11 blocks then dan produces his 12 blocks
wlog( "c2 blocks:" );
c2.produce_block( fc::milliseconds(config::block_interval_ms * 25) ); // pam skips over dan and sam's blocks
c2.produce_blocks(11); // pam finishes the remaining 11 blocks
c2.produce_block( fc::milliseconds(config::block_interval_ms * 25) ); // sam skips over cam and dan's blocks
c2.produce_blocks(11); // sam finishes the remaining 11 blocks
wlog( "now cam and dan rejoin sam and pam on c2" );
c2.produce_block( fc::milliseconds(config::block_interval_ms * 13) ); // cam skips over pam's blocks (this block triggers a block on this branch to become irreversible)
c2.produce_blocks(11); // cam produces the remaining 11 blocks
b = c2.produce_block(); // dan produces a block
// a node on chain 1 now gets all but the last block from chain 2 which should cause a fork switch
wlog( "push c2 blocks (except for the last block by dan) to c1" );
for( uint32_t start = fork_block_num + 1, end = c2.control->head_block_num() - 1; start <= end; ++start ) {
auto fb = c2.control->fetch_block_by_number( start );
c.control->push_block( fb );
}
wlog( "end push c2 blocks to c1" );
wlog( "now push dan's block to c1 but first corrupt it so it is a bad block" );
auto bad_block = *b;
//bad_block.producer = N(sam);
//bad_block.schedule_version = 12;
bad_block.transaction_mroot = bad_block.previous;
try {
c.control->push_block( std::make_shared<signed_block>(bad_block) );
} catch( const fc::exception& e ) {
elog(e.to_detail_string());
}
c.produce_blocks(3);
cr = c.push_action( N(eosio.token), N(issue), N(eosio), mutable_variant_object()
("to", "unregistered" )
("quantity", "100.0000 EOS")
("memo", "")
);
wdump((fc::json::to_pretty_string(cr)));
} FC_CAPTURE_AND_RETHROW()
} catch ( const fc::exception& e ) {
edump((e.to_detail_string()));
}
}
......@@ -577,6 +577,14 @@ read_only::get_account_results read_only::get_account( const get_account_params&
return result;
}
static variant action_abi_to_variant( const abi_def& abi, type_name action_type ) {
variant v;
auto it = std::find_if(abi.structs.begin(), abi.structs.end(), [&](auto& x){return x.name == action_type;});
if( it != abi.structs.end() )
to_variant( it->fields, v );
return v;
};
read_only::abi_json_to_bin_result read_only::abi_json_to_bin( const read_only::abi_json_to_bin_params& params )const try {
abi_json_to_bin_result result;
const auto code_account = db.db().find<account_object,by_name>( params.code );
......@@ -585,11 +593,13 @@ read_only::abi_json_to_bin_result read_only::abi_json_to_bin( const read_only::a
abi_def abi;
if( abi_serializer::to_abi(code_account->abi, abi) ) {
abi_serializer abis( abi );
auto action_type = abis.get_action_type(params.action);
EOS_ASSERT(!action_type.empty(), action_validate_exception, "Unknown action ${action} in contract ${contract}", ("action", params.action)("contract", params.code));
try {
result.binargs = abis.variant_to_binary(abis.get_action_type(params.action), params.args);
result.binargs = abis.variant_to_binary(action_type, params.args);
} EOS_RETHROW_EXCEPTIONS(chain::invalid_action_args_exception,
"'${args}' is invalid args for action '${action}' code '${code}'",
("args", params.args)("action", params.action)("code", params.code))
"'${args}' is invalid args for action '${action}' code '${code}'. expected '${proto}'",
("args", params.args)("action", params.action)("code", params.code)("proto", action_abi_to_variant(abi, action_type)))
}
return result;
} FC_CAPTURE_AND_RETHROW( (params.code)(params.action)(params.args) )
......
......@@ -453,20 +453,19 @@ namespace eosio {
};
deque<queued_write> write_queue;
deque<queued_write> out_queue;
fc::sha256 node_id;
handshake_message last_handshake_recv;
handshake_message last_handshake_sent;
int16_t sent_handshake_count;
bool connecting;
bool syncing;
uint16_t protocol_version;
int16_t sent_handshake_count = 0;
bool connecting = false;
bool syncing = false;
uint16_t protocol_version = 0;
string peer_addr;
unique_ptr<boost::asio::steady_timer> response_expected;
optional<request_message> pending_fetch;
go_away_reason no_retry;
go_away_reason no_retry = no_reason;
block_id_type fork_head;
uint32_t fork_head_num;
uint32_t fork_head_num = 0;
optional<request_message> last_req;
connection_status get_status()const {
......@@ -947,12 +946,12 @@ namespace eosio {
bool trigger_send,
std::function<void(boost::system::error_code, std::size_t)> callback) {
write_queue.push_back({buff, callback});
if(write_queue.size() == 1 && trigger_send)
if(out_queue.empty() && trigger_send)
do_queue_write();
}
void connection::do_queue_write() {
if(write_queue.empty())
if(write_queue.empty() || !out_queue.empty())
return;
connection_wptr c(shared_from_this());
if(!socket->is_open()) {
......
......@@ -97,78 +97,15 @@ auto smatch_to_variant(const std::smatch& smatch) {
return result;
};
const char* error_advice_3010001 = "Most likely, the given account/ permission doesn't exist in the blockchain.";
const char* error_advice_3010002 = "Most likely, the given account doesn't exist in the blockchain.";
const char* error_advice_3010003 = "Most likely, the given table doesnt' exist in the blockchain.";
const char* error_advice_3010004 = "Most likely, the given contract doesnt' exist in the blockchain.";
const char* error_advice_3030000 = "Ensure that your transaction satisfy the contract's constraint!";
const char* error_advice_3030001 = R"=====(Ensure that you have the related authority inside your transaction!;
If you are currently using 'cleos push action' command, try to add the relevant authority using -p option.)=====";
const char* error_advice_3030002 = "Ensure that you have the related private keys inside your wallet and your wallet is unlocked.";
const char* error_advice_3030003 = "Please remove the unnecessary authority from your action!";
const char* error_advice_3030004 = "Please remove the unnecessary signature from your transaction!";
const char* error_advice_3030011 = "You can try embedding eosio nonce action inside your transaction to ensure uniqueness.";
const char* error_advice_3030022 = "Please increase the expiration time of your transaction!";
const char* error_advice_3030023 = "Please decrease the expiration time of your transaction!";
const char* error_advice_3030024 = "Ensure that the reference block exist in the blockchain!";
const char* error_advice_3040002 = R"=====(Ensure that your arguments follow the contract abi!
You can check the contract's abi by using 'cleos get code' command.)=====";
const char* error_advice_3120001 = R"=====(Name should be less than 13 characters and only contains the following symbol .12345abcdefghijklmnopqrstuvwxyz)=====";
const char* error_advice_3120002 = R"=====(Public key should be encoded in base58 and starts with EOS prefix)=====";
const char* error_advice_3120003 = R"=====(Private key should be encoded in base58 WIF)=====";
const char* error_advice_3120004 = R"=====(Ensure that your authority JSON follows the following format!
{
"threshold":"uint32_t",
"keys":[{ "key":"public_key", "weight":"uint16_t" }],
"accounts":[{
"permission":{ "actor":"account_name", "permission":"permission_name" },
"weight":"uint16_t"
}]
}
e.g.
{
"threshold":"1",
"keys":[{ "key":"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", "weight":"1" }],
"accounts":[{
"permission":{ "actor":"initb", "permission":"social" },
"weight":"1
}]
})=====";
const char* error_advice_3120005 = R"=====(Ensure that your action JSON follows the contract's abi!)=====";
const char* error_advice_3120006 = R"=====(Ensure that your transaction JSON follows the following format!\n"
{
"ref_block_num":"uint16_t",
"ref_block_prefix":"uint32_t",
"expiration":"YYYY-MM-DDThh:mm",
"region": "uint16_t",
"read_scope":[ "account_name" ],
"write_scope":[ "account_name" ],
"actions":[{
"account":"account_name",
"name":"action_name",
"authorization":[{ "actor":"account_name","permission":"permission_name" }],
"data":"bytes"
}]
}"
e.g.
{
"ref_block_num":"1000",
"ref_block_prefix":"3463702842",
"expiration":"2018-01-23T01:51:05",
"region": "0",
"read_scope":[ "initb", "initc" ],
"write_scope":[ "initb", "initc" ],
"actions":[{
"account":"eosio",
"name":"transfer",
"authorization":[{ "actor":"initb","permission":"active" }],
"data":"000000008093dd74000000000094dd74e80300000000000000"
}]
})=====";
const char* error_advice_3120007 = R"=====(Ensure that your abi JSON follows the following format!
const char* error_advice_3010001 = R"=====(Name should be less than 13 characters and only contains the following symbol .12345abcdefghijklmnopqrstuvwxyz)=====";
const char* error_advice_3010002 = R"=====(Public key should be encoded in base58 and starts with EOS prefix)=====";
const char* error_advice_3010003 = R"=====(Private key should be encoded in base58 WIF)=====";
const char* error_advice_3010004 = R"=====(Ensure that your authority JSON follows the right authority structure!
You can refer to contracts/eosiolib/native.hpp for reference)=====";
const char* error_advice_3010005 = R"=====(Ensure that your action JSON follows the contract's abi!)=====";
const char* error_advice_3010006 = R"=====(Ensure that your transaction JSON follows the right transaction format!
You can refer to contracts/eosiolib/transaction.hpp for reference)=====";
const char* error_advice_3010007 = R"=====(Ensure that your abi JSON follows the following format!
{
"types" : [{ "new_type_name":"type_name", "type":"type_name" }],
"structs" : [{ "name":"type_name", "base":"type_name", "fields": [{ "name":"field_name", "type": "type_name" }] }],
......@@ -179,13 +116,14 @@ const char* error_advice_3120007 = R"=====(Ensure that your abi JSON follows th
"key_names":[ "field_name" ],
"key_types":[ "type_name" ],
"type":"type_name" "
}]
}],
"ricardian_clauses": [{ "id": "string", "body": "string" }]
}
e.g.
{
"types" : [{ "new_type_name":"account_name", "type":"name" }],
"structs" : [
{ "name":"foo", "base":"", "fields": [{ "name":"by", "type": "account_name" }] },\n "
{ "name":"foo", "base":"", "fields": [{ "name":"by", "type": "account_name" }] },
{ "name":"foobar", "base":"", "fields": [{ "name":"by", "type": "account_name" }] }
],
"actions" : [{ "name":"foo","type":"foo"}],
......@@ -194,36 +132,59 @@ e.g.
"index_type":"i64",
"key_names":[ "by" ],
"key_types":[ "account_name" ],
"type":"foobar" "
}]
"type":"foobar"
}],
"ricardian_clauses": [{ "id": "foo", "body": "bar" }]
})=====";
const char* error_advice_3120008 = "Ensure that the block ID is a SHA-256 hexadecimal string!";
const char* error_advice_3120009 = "Ensure that the transaction ID is a SHA-256 hexadecimal string!";
const char* error_advice_3120010 = R"=====(Ensure that your packed transaction JSON follows the following format!
const char* error_advice_3010008 = "Ensure that the block ID is a SHA-256 hexadecimal string!";
const char* error_advice_3010009 = "Ensure that the transaction ID is a SHA-256 hexadecimal string!";
const char* error_advice_3010010 = R"=====(Ensure that your packed transaction JSON follows the following format!
{
"signatures" : [ "signature" ],
"compression" : enum("none", "zlib"),
"hex_transaction" : "bytes"
"packed_context_free_data" : "bytes",
"packed_trx" : "bytes";
}
e.g.
{
"signatures" : [ "SIG_K1_Jze4m1ZHQ4UjuHpBcX6uHPN4Xyggv52raQMTBZJghzDLepaPcSGCNYTxaP2NiaF4yRF5RaYwqsQYAwBwFtfuTJr34Z5GJX" ],
"compression" : "none",
"hex_transaction" : "6c36a25a00002602626c5e7f0000000000010000001e4d75af460000000000a53176010000000000ea305500000000a8ed3232180000001e4d75af4680969800000000000443555200000000"
"packed_context_free_data" : "6c36a25a00002602626c5e7f0000000000010000001e4d75af460000000000a53176010000000000ea305500000000a8ed3232180000001e4d75af4680969800000000000443555200000000",
"packed_trx" : "6c36a25a00002602626c5e7f0000000000010000001e4d75af460000000000a53176010000000000ea305500000000a8ed3232180000001e4d75af4680969800000000000443555200000000"
})=====";
const char* error_advice_3130001 = "Ensure that you have \033[2meosio::chain_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3130002 = "Ensure that you have \033[2meosio::wallet_api_plugin\033[0m\033[32m added to your node's configuration!\n"\
const char* error_advice_3040000 = "Ensure that your transaction satisfy the contract's constraint!";
const char* error_advice_3040005 = "Please increase the expiration time of your transaction!";
const char* error_advice_3040006 = "Please decrease the expiration time of your transaction!";
const char* error_advice_3040007 = "Ensure that the reference block exist in the blockchain!";
const char* error_advice_3040008 = "You can try embedding eosio nonce action inside your transaction to ensure uniqueness.";
const char* error_advice_3050002 = R"=====(Ensure that your arguments follow the contract abi!
You can check the contract's abi by using 'cleos get code' command.)=====";
const char* error_advice_3060001 = "Most likely, the given account/ permission doesn't exist in the blockchain.";
const char* error_advice_3060002 = "Most likely, the given account doesn't exist in the blockchain.";
const char* error_advice_3060003 = "Most likely, the given table doesnt' exist in the blockchain.";
const char* error_advice_3060004 = "Most likely, the given contract doesnt' exist in the blockchain.";
const char* error_advice_3090002 = "Please remove the unnecessary signature from your transaction!";
const char* error_advice_3090003 = "Ensure that you have the related private keys inside your wallet and your wallet is unlocked.";
const char* error_advice_3090004 = R"=====(Ensure that you have the related authority inside your transaction!;
If you are currently using 'cleos push action' command, try to add the relevant authority using -p option.)=====";
const char* error_advice_3090005 = "Please remove the unnecessary authority from your action!";
const char* error_advice_3110001 = "Ensure that you have \033[2meosio::chain_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3110002 = "Ensure that you have \033[2meosio::wallet_api_plugin\033[0m\033[32m added to your node's configuration!\n"\
"Otherwise specify your wallet location with \033[2m--wallet-url\033[0m\033[32m argument!";
const char* error_advice_3130003 = "Ensure that you have \033[2meosio::account_history_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3130004 = "Ensure that you have \033[2meosio::net_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3110003 = "Ensure that you have \033[2meosio::history_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3110004 = "Ensure that you have \033[2meosio::net_api_plugin\033[0m\033[32m added to your node's configuration!";
const char* error_advice_3140001 = "Try to use different wallet name.";
const char* error_advice_3140002 = "Are you sure you typed the wallet name correctly?";
const char* error_advice_3140003 = "Ensure that your wallet is unlocked before using it!";
const char* error_advice_3140004 = "Ensure that you have the relevant private key imported!";
const char* error_advice_3140005 = "Are you sure you are using the right password?";
const char* error_advice_3140006 = "Ensure that you have created a wallet and have it open";
const char* error_advice_3120001 = "Try to use different wallet name.";
const char* error_advice_3120002 = "Are you sure you typed the wallet name correctly?";
const char* error_advice_3120003 = "Ensure that your wallet is unlocked before using it!";
const char* error_advice_3120004 = "Ensure that you have the relevant private key imported!";
const char* error_advice_3120005 = "Are you sure you are using the right password?";
const char* error_advice_3120006 = "Ensure that you have created a wallet and have it open";
const std::map<int64_t, std::string> error_advice = {
......@@ -231,42 +192,42 @@ const std::map<int64_t, std::string> error_advice = {
{ 3010002, error_advice_3010002 },
{ 3010003, error_advice_3010003 },
{ 3010004, error_advice_3010004 },
{ 3030000, error_advice_3030000 },
{ 3030001, error_advice_3030001 },
{ 3030002, error_advice_3030002 },
{ 3030003, error_advice_3030003 },
{ 3030004, error_advice_3030004 },
{ 3030011, error_advice_3030011 },
{ 3030022, error_advice_3030022 },
{ 3030023, error_advice_3030023 },
{ 3030024, error_advice_3030024 },
{ 3040002, error_advice_3040002 },
{ 3010005, error_advice_3010005 },
{ 3010006, error_advice_3010006 },
{ 3010007, error_advice_3010007 },
{ 3010008, error_advice_3010008 },
{ 3010009, error_advice_3010009 },
{ 3010010, error_advice_3010010 },
{ 3040000, error_advice_3040000 },
{ 3040008, error_advice_3040008 },
{ 3040005, error_advice_3040005 },
{ 3040006, error_advice_3040006 },
{ 3040007, error_advice_3040007 },
{ 3050002, error_advice_3050002 },
{ 3060001, error_advice_3060001 },
{ 3060002, error_advice_3060002 },
{ 3060003, error_advice_3060003 },
{ 3060004, error_advice_3060004 },
{ 3090002, error_advice_3090002 },
{ 3090003, error_advice_3090003 },
{ 3090004, error_advice_3090004 },
{ 3090005, error_advice_3090005 },
{ 3110001, error_advice_3110001 },
{ 3110002, error_advice_3110002 },
{ 3110003, error_advice_3110003 },
{ 3110004, error_advice_3110004 },
{ 3120001, error_advice_3120001 },
{ 3120002, error_advice_3120002 },
{ 3120003, error_advice_3120003 },
{ 3120004, error_advice_3120004 },
{ 3120005, error_advice_3120005 },
{ 3120006, error_advice_3120006 },
{ 3120007, error_advice_3120007 },
{ 3120008, error_advice_3120008 },
{ 3120009, error_advice_3120009 },
{ 3120010, error_advice_3120010 },
{ 3130001, error_advice_3130001 },
{ 3130002, error_advice_3130002 },
{ 3130003, error_advice_3130003 },
{ 3130004, error_advice_3130004 },
{ 3140001, error_advice_3140001 },
{ 3140002, error_advice_3140002 },
{ 3140003, error_advice_3140003 },
{ 3140004, error_advice_3140004 },
{ 3140005, error_advice_3140005 },
{ 3140006, error_advice_3140006 }
{ 3120006, error_advice_3120006 }
};
......
......@@ -159,7 +159,7 @@ namespace eosio { namespace client { namespace http {
} else if (path.compare(0, wallet_func_base.size(), wallet_func_base) == 0) {
throw chain::missing_wallet_api_plugin_exception(FC_LOG_MESSAGE(error, "Wallet is not available"));
} else if (path.compare(0, account_history_func_base.size(), account_history_func_base) == 0) {
throw chain::missing_account_history_api_plugin_exception(FC_LOG_MESSAGE(error, "Account History API plugin is not enabled"));
throw chain::missing_history_api_plugin_exception(FC_LOG_MESSAGE(error, "History API plugin is not enabled"));
} else if (path.compare(0, net_func_base.size(), net_func_base) == 0) {
throw chain::missing_net_api_plugin_exception(FC_LOG_MESSAGE(error, "Net API plugin is not enabled"));
}
......
......@@ -223,10 +223,6 @@ try:
if node is None:
errorExit("Cluster in bad state, received None node")
# Exit early untill test is fully functional
testSuccessful=True
exit(0)
Print("Create new account %s via %s" % (testeraAccount.name, defproduceraAccount.name))
transId=node.createInitializeAccount(testeraAccount, defproduceraAccount, stakedDeposit=0, waitForTransBlock=False)
if transId is None:
......
......@@ -478,10 +478,55 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try {
bought_bytes = bytes - init_bytes;
wdump((init_bytes)(bought_bytes)(bytes) );
BOOST_REQUIRE_EQUAL( true, total["ram_bytes"].as_uint64() == init_bytes );
BOOST_REQUIRE_EQUAL( asset::from_string("100000999.9993 EOS"), get_balance( "alice1111111" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "30.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( asset::from_string("100000439.9993 EOS"), get_balance( "alice1111111" ) );
auto newtotal = get_total_stake( "alice1111111" );
auto newbytes = newtotal["ram_bytes"].as_uint64();
bought_bytes = newbytes - bytes;
wdump((newbytes)(bytes)(bought_bytes) );
BOOST_REQUIRE_EQUAL( success(), sellram( "alice1111111", bought_bytes ) );
BOOST_REQUIRE_EQUAL( asset::from_string("100000999.9991 EOS"), get_balance( "alice1111111" ) );
newtotal = get_total_stake( "alice1111111" );
auto startbytes = newtotal["ram_bytes"].as_uint64();
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "100000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "300000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( asset::from_string("49400999.9991 EOS"), get_balance( "alice1111111" ) );
auto finaltotal = get_total_stake( "alice1111111" );
auto endbytes = finaltotal["ram_bytes"].as_uint64();
bought_bytes = endbytes - startbytes;
wdump((startbytes)(endbytes)(bought_bytes) );
BOOST_REQUIRE_EQUAL( success(), sellram( "alice1111111", bought_bytes ) );
BOOST_REQUIRE_EQUAL( asset::from_string("100000999.9943 EOS"), get_balance( "alice1111111" ) );
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( stake_unstake, eosio_system_tester ) try {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册