提交 53d1ce1e 编写于 作者: A Anton Perkov

Merge branch 'slim' into payment

......@@ -139,6 +139,7 @@
{"name":"owner", "type":"account_name"},
{"name":"total_votes", "type":"float64"},
{"name":"producer_key", "type":"public_key"},
{"name":"url", "type":"string"},
{"name":"produced_blocks", "type":"uint32"},
{"name":"last_claim_time", "type":"uint64"},
{"name":"location", "type":"uint16"},
......@@ -255,7 +256,7 @@
}
],
"tables": [{
"name": "producerinfo",
"name": "producers",
"type": "producer_info",
"index_type": "i64",
"key_names" : ["owner"],
......
......@@ -50,6 +50,7 @@ namespace eosiosystem {
account_name owner;
double total_votes = 0;
eosio::public_key producer_key; /// a packed public key object
std::string url;
uint32_t produced_blocks;
uint64_t last_claim_time = 0;
uint16_t location = 0;
......@@ -61,7 +62,7 @@ namespace eosiosystem {
bool active() const { return producer_key != public_key(); }
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE( producer_info, (owner)(total_votes)(producer_key)
EOSLIB_SERIALIZE( producer_info, (owner)(total_votes)(producer_key)(url)
(produced_blocks)(last_claim_time)(location)
(time_became_active)(last_produced_block_time) )
};
......
......@@ -45,6 +45,7 @@ namespace eosiosystem {
if( producer_key != prod->producer_key ) {
_producers.modify( prod, producer, [&]( producer_info& info ){
info.producer_key = producer_key;
info.url = url;
});
}
} else {
......@@ -52,6 +53,7 @@ namespace eosiosystem {
info.owner = producer;
info.total_votes = 0;
info.producer_key = producer_key;
info.url = url;
});
}
}
......
{
"types": [{
"new_type_name": "account_name",
"type": "name"
}
],
"structs": [{
"name": "transfer",
"base": "",
"fields": [
{"name":"from", "type":"account_name"},
{"name":"to", "type":"account_name"},
{"name":"amount", "type":"uint64"}
]
},{
"name": "account",
"base": "",
"fields": [
{"name":"account", "type":"name"},
{"name":"balance", "type":"uint64"}
]
}
],
"actions": [{
"name": "transfer",
"type": "transfer",
"ricardian_contract": ""
}
],
"tables": [{
"name": "account",
"type": "account",
"index_type": "i64",
"key_names" : ["account"],
"key_types" : ["name"]
}
],
"ricardian_clauses": []
}
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <skeleton.hpp>
#include <eosiolib/eosio.hpp>
/**
* The init() and apply() methods must have C calling convention so that the blockchain can lookup and
* call these methods.
*/
extern "C" {
using namespace eosio;
/// The apply method implements the dispatch of events to this contract
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
eosio::print( "Hello World: ", eosio::name(code), "->", eosio::name(action), "\n" );
}
class hello : public eosio::contract {
public:
using contract::contract;
} // extern "C"
/// @abi action
void hi( account_name user ) {
print( "Hello, ", name{user} );
}
};
EOSIO_ABI( hello, (hi) )
......@@ -330,14 +330,13 @@ void print_action_tree( const fc::variant& action ) {
void print_result( const fc::variant& result ) { try {
const auto& processed = result["processed"];
const auto& transaction_id = processed["id"].as_string();
const auto& receipt = processed["receipt"].get_object() ;
const auto& status = receipt["status"].as_string() ;
auto net = receipt["net_usage_words"].as_int64()*8;
auto cpu = receipt["kcpu_usage"].as_int64();
string status = processed["receipt"].is_object() ? processed["receipt"]["status"].as_string() : "failed";
auto net = processed["net_usage"].as_int64()*8;
auto cpu = processed["cpu_usage"].as_int64() / 1024;
cerr << status << " transaction: " << transaction_id << " " << net << " bytes " << cpu << "k cycles\n";
if( status == "hard_fail" ) {
if( status == "failed" ) {
auto soft_except = processed["except"].as<optional<fc::exception>>();
if( soft_except ) {
edump((soft_except->to_detail_string()));
......@@ -859,6 +858,59 @@ struct vote_producers_subcommand {
}
};
struct list_producers_subcommand {
bool print_json = false;
bool sort_names = false;
list_producers_subcommand(CLI::App* actionRoot) {
auto list_producers = actionRoot->add_subcommand("listproducers", localized("List producers"));
list_producers->add_flag("--json,-j", print_json, localized("Output in JSON format") );
list_producers->add_flag("--sort-account-names,-n", sort_names, localized("Sort by account names (default order is by votes)") );
list_producers->set_callback([this] {
auto result = call(get_table_func, fc::mutable_variant_object("json", true)
("code", name(config::system_account_name).to_string())
("scope", name(config::system_account_name).to_string())
("table", "producers")
);
if ( !print_json ) {
auto res = result.as<eosio::chain_apis::read_only::get_table_rows_result>();
std::vector<std::tuple<std::string, std::string, std::string, std::string>> v;
for ( auto& row : res.rows ) {
auto& r = row.get_object();
v.emplace_back( r["owner"].as_string(), r["total_votes"].as_string(), r["producer_key"].as_string(), r["url"].as_string() );
}
if ( !v.empty() ) {
if ( sort_names ) {
std::sort( v.begin(), v.end(), [](auto a, auto b) { return std::get<0>(a) < std::get<0>(b); } );
} else {
std::sort( v.begin(), v.end(), [](auto a, auto b) {
return std::get<1>(a) < std::get<1>(b) || (std::get<1>(a) == std::get<1>(b) && std::get<0>(a) < std::get<0>(b)); }
);
}
std::cout << std::left << std::setw(14) << "Producer" << std::setw(55) << "Producer key"
<< std::setw(50) << "Url" << "Total votes" << std::endl;
for ( auto& x : v ) {
std::cout << std::left << std::setw(14) << std::get<0>(x) << std::setw(55) << std::get<2>(x)
<< std::setw(50) << std::get<3>(x) << std::get<1>(x) << std::endl;
}
} else {
std::cout << "No producers found" << std::endl;
}
} else {
if ( sort_names ) {
FC_THROW("Sorting producers is not supported for JSON format");
}
std::cout << fc::json::to_pretty_string(result)
<< std::endl;
}
}
);
}
};
struct delegate_bandwidth_subcommand {
string from_str;
string receiver_str;
......@@ -1118,8 +1170,8 @@ void get_account( const string& accountName, bool json_format ) {
<< indent << "quota: " << std::setw(15) << res.ram_quota << " bytes used: " << std::setw(15) << res.ram_usage << " bytes" << std::endl << std::endl;
std::cout << "net bandwidth:" << std::endl;
if ( res.total_resources.is_object() && res.delegated_bandwidth.is_object() ) {
asset net_own( stoll( res.delegated_bandwidth.get_object()["net_weight"].as_string() ) );
if ( res.total_resources.is_object() ) {
asset net_own( res.delegated_bandwidth.is_object() ? stoll( res.delegated_bandwidth.get_object()["net_weight"].as_string() ) : 0 );
auto net_others = to_asset(res.total_resources.get_object()["net_weight"].as_string()) - net_own;
std::cout << indent << "staked:" << std::setw(20) << net_own
<< std::string(11, ' ') << "(total stake delegated from account to self)" << std::endl
......@@ -1136,8 +1188,8 @@ void get_account( const string& accountName, bool json_format ) {
std::cout << "cpu bandwidth:" << std::endl;
if ( res.total_resources.is_object() && res.delegated_bandwidth.is_object() ) {
asset cpu_own( stoll( res.delegated_bandwidth.get_object()["cpu_weight"].as_string() ) );
if ( res.total_resources.is_object() ) {
asset cpu_own( res.delegated_bandwidth.is_object() ? stoll( res.delegated_bandwidth.get_object()["cpu_weight"].as_string() ) : 0 );
auto cpu_others = to_asset(res.total_resources.get_object()["cpu_weight"].as_string()) - cpu_own;
std::cout << indent << "staked:" << std::setw(20) << cpu_own
<< std::string(11, ' ') << "(total stake delegated from account to self)" << std::endl
......@@ -2153,6 +2205,8 @@ int main( int argc, char** argv ) {
auto voteProxy = vote_producer_proxy_subcommand(voteProducer);
auto voteProducers = vote_producers_subcommand(voteProducer);
auto listProducers = list_producers_subcommand(system);
auto delegateBandWidth = delegate_bandwidth_subcommand(system);
auto undelegateBandWidth = undelegate_bandwidth_subcommand(system);
......
......@@ -38,7 +38,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/consensus-validation-malicious-produc
#To run plugin_test with all log from blockchain displayed, put --verbose after --, i.e. plugin_test -- --verbose
add_test(NAME plugin_test COMMAND plugin_test --report_level=detailed --color_output)
add_test(NAME nodeos_run_test COMMAND tests/nodeos_run_test.py -v --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME nodeos_run_test COMMAND tests/nodeos_run_test.py -v --only-bios --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO removed on slim: add_test(NAME nodeos_run_remote_test COMMAND tests/nodeos_run_remote_test.py -v --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO removed on slim: add_test(NAME p2p_dawn515_test COMMAND tests/p2p_tests/dawn_515/test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
#if(BUILD_MONGO_DB_PLUGIN)
......
......@@ -4,7 +4,6 @@ import testUtils
import decimal
import argparse
import random
import re
###############################################################
......@@ -17,8 +16,8 @@ Print=testUtils.Utils.Print
errorExit=testUtils.Utils.errorExit
def cmdError(name, code=0, exitNow=False):
msg="FAILURE - %s%s" % (name, ("" if code == 0 else (" returned error code %d" % code)))
def cmdError(name, cmdCode=0, exitNow=False):
msg="FAILURE - %s%s" % (name, ("" if cmdCode == 0 else (" returned error code %d" % cmdCode)))
if exitNow:
errorExit(msg, True)
else:
......@@ -50,7 +49,7 @@ parser.add_argument("--keep-logs", help="Don't delete var/lib/node_* folders upo
action='store_true')
parser.add_argument("-v", help="verbose logging", action='store_true')
parser.add_argument("--dont-kill", help="Leave cluster running after test finishes", action='store_true')
parser.add_argument("--only-bios", help="Limit testing to bios node.", action='store_false')
parser.add_argument("--only-bios", help="Limit testing to bios node.", action='store_true')
args = parser.parse_args()
testOutputFile=args.output
......@@ -65,6 +64,7 @@ keepLogs=args.keep_logs
dontLaunch=args.dont_launch
dontKill=args.dont_kill
prodCount=args.prod_count
onlyBios=args.only_bios
testUtils.Utils.Debug=debug
localTest=True if server == LOCAL_HOST else False
......@@ -94,7 +94,7 @@ try:
cluster.killall()
cluster.cleanup()
Print("Stand up cluster")
if cluster.launch(prodCount=prodCount, onlyBios=True, dontKill=dontKill) is False:
if cluster.launch(prodCount=prodCount, onlyBios=onlyBios, dontKill=dontKill) is False:
cmdError("launcher")
errorExit("Failed to stand up eos cluster.")
else:
......@@ -193,7 +193,7 @@ try:
expectedkeys.append(account.activePrivateKey)
noMatch=list(set(expectedkeys) - set(actualKeys))
if len(noMatch) > 0:
errorExit("FAILURE - wallet keys did not include %s" % (noMatch), raw=true)
errorExit("FAILURE - wallet keys did not include %s" % (noMatch), raw=True)
Print("Locking all wallets.")
if not walletMgr.lockAllWallets():
......@@ -215,14 +215,14 @@ try:
expectedkeys=[initaAccount.ownerPrivateKey]
noMatch=list(set(expectedkeys) - set(actualKeys))
if len(noMatch) > 0:
errorExit("FAILURE - wallet keys did not include %s" % (noMatch), raw=true)
errorExit("FAILURE - wallet keys did not include %s" % (noMatch), raw=True)
node=cluster.getNode(0)
if node is None:
errorExit("Cluster in bad state, received None node")
Print("Create new account %s via %s" % (testeraAccount.name, initaAccount.name))
transId=node.createAccount(testeraAccount, initaAccount, stakedDeposit=0, waitForTransBlock=False)
transId=node.createInitializeAccount(testeraAccount, initaAccount, stakedDeposit=0, waitForTransBlock=False)
if transId is None:
cmdError("%s create account" % (ClientName))
errorExit("Failed to create account %s" % (testeraAccount.name))
......@@ -238,14 +238,12 @@ try:
errorExit("Failed to transfer funds %d from account %s to %s" % (
transferAmount, initaAccount.name, testeraAccount.name))
# TBD: Known issue (Issue 2043) that 'get currency balance' doesn't return balance.
# Uncomment when functional
# expectedAmount=transferAmount
# Print("Verify transfer, Expected: %d" % (expectedAmount))
# actualAmount=node.getAccountBalance(testeraAccount.name)
# if expectedAmount != actualAmount:
# cmdError("FAILURE - transfer failed")
# errorExit("Transfer verification failed. Excepted %d, actual: %d" % (expectedAmount, actualAmount))
expectedAmount=transferAmount
Print("Verify transfer, Expected: %s" % (expectedAmount))
actualAmount=node.getAccountEosBalanceStr(testeraAccount.name)
if expectedAmount != actualAmount:
cmdError("FAILURE - transfer failed")
errorExit("Transfer verification failed. Excepted %s, actual: %s" % (expectedAmount, actualAmount))
transferAmount="0.0100 EOS"
Print("Force transfer funds %s from account %s to %s" % (
......@@ -255,23 +253,21 @@ try:
errorExit("Failed to force transfer funds %d from account %s to %s" % (
transferAmount, initaAccount.name, testeraAccount.name))
# TBD: Known issue (Issue 2043) that 'get currency balance' doesn't return balance.
# Uncomment when functional
# expectedAmount=975421
# Print("Verify transfer, Expected: %d" % (expectedAmount))
# actualAmount=node.getAccountBalance(testeraAccount.name)
# if expectedAmount != actualAmount:
# cmdError("FAILURE - transfer failed")
# errorExit("Transfer verification failed. Excepted %d, actual: %d" % (expectedAmount, actualAmount))
expectedAmount="97.5421 EOS"
Print("Verify transfer, Expected: %s" % (expectedAmount))
actualAmount=node.getAccountEosBalanceStr(testeraAccount.name)
if expectedAmount != actualAmount:
cmdError("FAILURE - transfer failed")
errorExit("Transfer verification failed. Excepted %s, actual: %s" % (expectedAmount, actualAmount))
Print("Create new account %s via %s" % (currencyAccount.name, initbAccount.name))
transId=node.createAccount(currencyAccount, initbAccount, stakedDeposit=5000)
transId=node.createInitializeAccount(currencyAccount, initbAccount, stakedDeposit=5000)
if transId is None:
cmdError("%s create account" % (ClientName))
errorExit("Failed to create account %s" % (currencyAccount.name))
Print("Create new account %s via %s" % (exchangeAccount.name, initaAccount.name))
transId=node.createAccount(exchangeAccount, initaAccount, waitForTransBlock=True)
transId=node.createInitializeAccount(exchangeAccount, initaAccount, waitForTransBlock=True)
if transId is None:
cmdError("%s create account" % (ClientName))
errorExit("Failed to create account %s" % (exchangeAccount.name))
......@@ -296,17 +292,12 @@ try:
transferAmount, initaAccount.name, testeraAccount.name))
transId=testUtils.Node.getTransId(trans)
# TBD: Known issue (Issue 2043) that 'get currency balance' doesn't return balance.
# Uncomment when functional
# expectedAmount=975311+5000 # 5000 initial deposit
# Print("Verify transfer, Expected: %d" % (expectedAmount))
# actualAmount=node.getAccountBalance(currencyAccount.name)
# if actualAmount is None:
# cmdError("%s get account currency" % (ClientName))
# errorExit("Failed to retrieve balance for account %s" % (currencyAccount.name))
# if expectedAmount != actualAmount:
# cmdError("FAILURE - transfer failed")
# errorExit("Transfer verification failed. Excepted %d, actual: %d" % (expectedAmount, actualAmount))
expectedAmount="98.0311 EOS" # 5000 initial deposit
Print("Verify transfer, Expected: %s" % (expectedAmount))
actualAmount=node.getAccountEosBalanceStr(currencyAccount.name)
if expectedAmount != actualAmount:
cmdError("FAILURE - transfer failed")
errorExit("Transfer verification failed. Excepted %s, actual: %s" % (expectedAmount, actualAmount))
# Pre-mature exit on slim branch. This will pushed futher out as code stablizes.
testSuccessful=True
......@@ -493,7 +484,6 @@ try:
cmdError("%s get transaction trans_id" % (ClientName))
errorExit("Failed to verify push message transaction id.")
# TODO need to update eosio.system contract to use new currency and update cleos and chain_plugin for interaction
Print("read current contract balance")
contract="currency"
table="accounts"
......
此差异已折叠。
#!/bin/sh
# run ctest, disregard failure code
ctest $@
ctest --output-on-failure $@
exit 0
......@@ -73,7 +73,7 @@ if(ENABLE_COVERAGE_TESTING)
COMMAND ${LCOV_PATH} --directory . --capture --gcov-tool ./tools/llvm-gcov.sh --output-file ${Coverage_NAME}.info
COMMAND ${LCOV_PATH} -remove ${Coverage_NAME}.info 'boost/*' '/usr/lib/*' '/usr/include/*' '/externals/*' 'fc/*' 'wasm-jit/*' --output-file ${Coverage_NAME}_filtered.info
COMMAND ${LCOV_PATH} -remove ${Coverage_NAME}.info '*/boost/*' '/usr/lib/*' '/usr/include/*' '*/externals/*' '*/fc/*' '*/wasm-jit/*' --output-file ${Coverage_NAME}_filtered.info
COMMAND ${GENHTML_PATH} -o ${Coverage_NAME} ${PROJECT_BINARY_DIR}/${Coverage_NAME}_filtered.info
COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.base ${Coverage_NAME}.info ${Coverage_NAME}_filtered.info ${Coverage_NAME}.total ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned ${PROJECT_BINARY_DIR}/${Coverage_NAME}_filtered.info.cleaned
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册