未验证 提交 bbce3d90 编写于 作者: W wanderingbort 提交者: GitHub

Merge branch 'release/1.1' into doxygen-cpp-sdk-slim

......@@ -60,7 +60,7 @@ RUN git clone --depth 1 https://github.com/cryptonomex/secp256k1-zkp \
&& make -j$(nproc) install \
&& cd .. && rm -rf secp256k1-zkp
RUN git clone --depth 1 -b releases/stable https://github.com/mongodb/mongo-cxx-driver \
RUN git clone --depth 1 -b releases/v3.2 https://github.com/mongodb/mongo-cxx-driver \
&& cd mongo-cxx-driver \
&& cmake -H. -Bbuild -G Ninja -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local\
&& cmake --build build --target install \
......
......@@ -2542,9 +2542,10 @@ namespace eosio {
chain_plug->accept_transaction(msg, [=](const static_variant<fc::exception_ptr, transaction_trace_ptr>& result) {
if (result.contains<fc::exception_ptr>()) {
auto e_ptr = result.get<fc::exception_ptr>();
if (e_ptr->code() != tx_duplicate::code_value && e_ptr->code() != expired_tx_exception::code_value)
if (e_ptr->code() != tx_duplicate::code_value && e_ptr->code() != expired_tx_exception::code_value) {
elog("accept txn threw ${m}",("m",result.get<fc::exception_ptr>()->to_detail_string()));
peer_elog(c, "bad packed_transaction : ${m}", ("m",result.get<fc::exception_ptr>()->what()));
}
} else {
auto trace = result.get<transaction_trace_ptr>();
if (!trace->except) {
......
......@@ -1408,16 +1408,19 @@ void get_account( const string& accountName, bool json_format ) {
std::cout << "net bandwidth: " << std::endl;
if ( res.total_resources.is_object() ) {
auto net_total = to_asset(res.total_resources.get_object()["net_weight"].as_string());
if( net_total.get_symbol() != unstaking.get_symbol() ) {
// Core symbol of nodeos responding to the request is different than core symbol built into cleos
unstaking = asset( 0, net_total.get_symbol() ); // Correct core symbol for unstaking asset.
staked = asset( 0, net_total.get_symbol() ); // Correct core symbol for staked asset.
}
if( res.self_delegated_bandwidth.is_object() ) {
asset net_own = asset::from_string( res.self_delegated_bandwidth.get_object()["net_weight"].as_string() );
staked = net_own;
if( staked.get_symbol() != unstaking.get_symbol() ) {
// Core symbol of nodeos responding to the request is different than core symbol built into cleos
unstaking = asset( 0, staked.get_symbol() ); // Correct core symbol for unstaking asset.
}
auto net_others = to_asset(res.total_resources.get_object()["net_weight"].as_string()) - net_own;
auto net_others = net_total - net_own;
std::cout << indent << "staked:" << std::setw(20) << net_own
<< std::string(11, ' ') << "(total stake delegated from account to self)" << std::endl
......@@ -1425,7 +1428,7 @@ void get_account( const string& accountName, bool json_format ) {
<< std::string(11, ' ') << "(total staked delegated to account from others)" << std::endl;
}
else {
auto net_others = to_asset(res.total_resources.get_object()["net_weight"].as_string());
auto net_others = net_total;
std::cout << indent << "delegated:" << std::setw(17) << net_others
<< std::string(11, ' ') << "(total staked delegated to account from others)" << std::endl;
}
......@@ -1475,18 +1478,20 @@ void get_account( const string& accountName, bool json_format ) {
std::cout << "cpu bandwidth:" << std::endl;
if ( res.total_resources.is_object() ) {
auto cpu_total = to_asset(res.total_resources.get_object()["cpu_weight"].as_string());
if( res.self_delegated_bandwidth.is_object() ) {
asset cpu_own = asset::from_string( res.self_delegated_bandwidth.get_object()["cpu_weight"].as_string() );
staked += cpu_own;
auto cpu_others = to_asset(res.total_resources.get_object()["cpu_weight"].as_string()) - cpu_own;
auto cpu_others = cpu_total - cpu_own;
std::cout << indent << "staked:" << std::setw(20) << cpu_own
<< std::string(11, ' ') << "(total stake delegated from account to self)" << std::endl
<< indent << "delegated:" << std::setw(17) << cpu_others
<< std::string(11, ' ') << "(total staked delegated to account from others)" << std::endl;
} else {
auto cpu_others = to_asset(res.total_resources.get_object()["cpu_weight"].as_string());
auto cpu_others = cpu_total;
std::cout << indent << "delegated:" << std::setw(17) << cpu_others
<< std::string(11, ' ') << "(total staked delegated to account from others)" << std::endl;
}
......@@ -1504,23 +1509,24 @@ void get_account( const string& accountName, bool json_format ) {
auto request_time = fc::time_point_sec::from_iso_string( obj["request_time"].as_string() );
fc::time_point refund_time = request_time + fc::days(3);
auto now = res.head_block_time;
std::cout << std::fixed << setprecision(3);
std::cout << "unstaking tokens:" << std::endl;
std::cout << indent << std::left << std::setw(25) << "time of unstake request:" << std::right << std::setw(20) << string(request_time);
if( now >= refund_time ) {
std::cout << " (available to claim now with 'eosio::refund' action)\n";
} else {
std::cout << " (funds will be available in " << to_pretty_time( (refund_time - now).count(), 0 ) << ")\n";
asset net = asset::from_string( obj["net_amount"].as_string() );
asset cpu = asset::from_string( obj["cpu_amount"].as_string() );
unstaking = net + cpu;
asset net = asset::from_string( obj["net_amount"].as_string() );
asset cpu = asset::from_string( obj["cpu_amount"].as_string() );
unstaking = net + cpu;
if( unstaking > asset( 0, unstaking.get_symbol() ) ) {
std::cout << std::fixed << setprecision(3);
std::cout << "unstaking tokens:" << std::endl;
std::cout << indent << std::left << std::setw(25) << "time of unstake request:" << std::right << std::setw(20) << string(request_time);
if( now >= refund_time ) {
std::cout << " (available to claim now with 'eosio::refund' action)\n";
} else {
std::cout << " (funds will be available in " << to_pretty_time( (refund_time - now).count(), 0 ) << ")\n";
}
std::cout << indent << std::left << std::setw(25) << "from net bandwidth:" << std::right << std::setw(18) << net << std::endl;
std::cout << indent << std::left << std::setw(25) << "from cpu bandwidth:" << std::right << std::setw(18) << cpu << std::endl;
std::cout << indent << std::left << std::setw(25) << "total:" << std::right << std::setw(18) << unstaking << std::endl;
std::cout << std::endl;
}
std::cout << std::endl;
}
if( res.core_liquid_balance.valid() ) {
......
......@@ -236,7 +236,27 @@
fi
printf "\\n\\tChecking MongoDB C++ driver installation.\\n"
if [ ! -e "/usr/local/lib/libmongocxx-static.a" ]; then
MONGO_INSTALL=true
if [ -e "/usr/local/lib/libmongocxx-static.a" ]; then
MONGO_INSTALL=false
if ! version=$( grep "Version:" /usr/local/lib/pkgconfig/libmongocxx-static.pc | tr -s ' ' | awk '{print $2}' )
then
printf "\\tUnable to determine mongodb-cxx-driver version.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
maj=$( echo "${version}" | cut -d'.' -f1 )
min=$( echo "${version}" | cut -d'.' -f2 )
if [ "${maj}" -gt 3 ]; then
MONGO_INSTALL=true
elif [ "${maj}" -eq 3 ] && [ "${min}" -lt 3 ]; then
MONGO_INSTALL=true
fi
fi
if [ $MONGO_INSTALL == "true" ]; then
if ! cd "${TEMP_DIR}"
then
printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
......@@ -258,35 +278,48 @@
exit 1;
fi
fi
STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz)
STATUS=$( curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.10.2/mongo-c-driver-1.10.2.tar.gz )
if [ "${STATUS}" -ne 200 ]; then
if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.9.3.tar.gz"
if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz"
then
printf "\\tUnable to remove file %s/mongo-c-driver-1.9.3.tar.gz.\\n" "${TEMP_DIR}"
printf "\\tUnable to remove file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}"
fi
printf "\\tUnable to download MongoDB C driver at this time.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! tar xf mongo-c-driver-1.9.3.tar.gz
if ! tar xf mongo-c-driver-1.10.2.tar.gz
then
printf "\\tUnable to unarchive file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz"
then
printf "\\tUnable to remove file mongo-c-driver-1.10.2.tar.gz.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}"/mongo-c-driver-1.10.2
then
printf "\\tUnable to unarchive file mongo-c-driver-1.9.3.tar.gz.\\n"
printf "\\tUnable to cd into directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.9.3.tar.gz"
if ! mkdir cmake-build
then
printf "\\tUnable to remove file mongo-c-driver-1.9.3.tar.gz.\\n"
printf "\\tUnable to create directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd mongo-c-driver-1.9.3
if ! cd cmake-build
then
printf "\\tUnable to cd into directory %s/mongo-c-driver-1.9.3.\\n" "${TEMP_DIR}"
printf "\\tUnable to enter directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! ./configure --enable-static --with-libbson=bundled --enable-ssl=darwin --disable-automatic-init-and-cleanup --prefix=/usr/local
if ! cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BSON=ON \
-DENABLE_SSL=DARWIN -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON ..
then
printf "\\tConfiguring MongoDB C driver has encountered the errors above.\\n"
printf "\\tExiting now.\\n\\n"
......@@ -310,13 +343,13 @@
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! rm -rf "${TEMP_DIR}/mongo-c-driver-1.9.3"
if ! rm -rf "${TEMP_DIR}/mongo-c-driver-1.10.2"
then
printf "\\tUnable to remove directory %s/mongo-c-driver-1.9.3.\\n" "${TEMP_DIR}"
printf "\\tUnable to remove directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/v3.2 --depth 1
if ! git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/v3.3 --depth 1
then
printf "\\tUnable to clone MongoDB C++ driver at this time.\\n"
printf "\\tExiting now.\\n\\n"
......@@ -505,4 +538,4 @@
printf "\\n\\t%s -f %s &\\n" "$( command -v mongod )" "${MONGOD_CONF}"
printf "\\tcd %s; make test\\n\\n" "${BUILD_DIR}"
return 0
}
}
\ No newline at end of file
......@@ -270,115 +270,146 @@ mongodconf
fi
printf "\\n\\tChecking MongoDB C++ driver installation.\\n"
if [ ! -e "/usr/local/lib/libmongocxx-static.a" ]; then
printf "\\n\\tInstalling MongoDB C & C++ drivers.\\n"
MONGO_INSTALL=true
if [ -e "/usr/local/lib/libmongocxx-static.a" ]; then
MONGO_INSTALL=false
if ! version=$( grep "Version:" /usr/local/lib/pkgconfig/libmongocxx-static.pc | tr -s ' ' | awk '{print $2}' )
then
printf "\\tUnable to determine mongodb-cxx-driver version.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
maj=$( echo "${version}" | cut -d'.' -f1 )
min=$( echo "${version}" | cut -d'.' -f2 )
if [ "${maj}" -gt 3 ]; then
MONGO_INSTALL=true
elif [ "${maj}" -eq 3 ] && [ "${min}" -lt 3 ]; then
MONGO_INSTALL=true
fi
fi
if [ $MONGO_INSTALL == "true" ]; then
if ! cd "${TEMP_DIR}"
then
printf "\\n\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz)
STATUS=$( curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.10.2/mongo-c-driver-1.10.2.tar.gz )
if [ "${STATUS}" -ne 200 ]; then
if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.9.3.tar.gz"
if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz"
then
printf "\\n\\tUnable to remove file %s/mongo-c-driver-1.9.3.tar.gz.\\n" "${TEMP_DIR}"
printf "\\tUnable to remove file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}"
fi
printf "\\tUnable to download MongoDB C driver at this time.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! tar xf "${TEMP_DIR}/mongo-c-driver-1.9.3.tar.gz"
if ! tar xf mongo-c-driver-1.10.2.tar.gz
then
printf "\\n\\tUnable to unarchive file %s/mongo-c-driver-1.9.3.tar.gz.\\n" "${TEMP_DIR}"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tUnable to unarchive file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.9.3.tar.gz"
if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz"
then
printf "\\n\\tUnable to remove file %s/mongo-c-driver-1.9.3.tar.gz.\\n" "${TEMP_DIR}"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tUnable to remove file mongo-c-driver-1.10.2.tar.gz.\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}/mongo-c-driver-1.9.3"
if ! cd "${TEMP_DIR}"/mongo-c-driver-1.10.2
then
printf "\\n\\tUnable to enter directory %s/mongo-c-driver-1.9.3.\\n" "${TEMP_DIR}"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tUnable to cd into directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! mkdir cmake-build
then
printf "\\tUnable to create directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd cmake-build
then
printf "\\tUnable to enter directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! ./configure --enable-static --with-libbson=bundled --enable-ssl=openssl --disable-automatic-init-and-cleanup --prefix=/usr/local
if ! cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BSON=ON \
-DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON ..
then
printf "\\tConfiguring MongoDB C driver has encountered the errors above.\\n"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! make -j"${JOBS}"
if ! make -j"${CPU_CORE}"
then
printf "\\tError compiling MongoDB C driver.\\n"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! sudo make install
then
printf "\\tError installing MongoDB C driver.\\nMake sure you have sudo privileges.\\n"
printf "\\tExiting now.\\n\\n"
exit;
exit 1;
fi
if ! cd "${TEMP_DIR}"
then
printf "\\n\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! rm -rf "${TEMP_DIR}/mongo-c-driver-1.9.3"
if ! rm -rf "${TEMP_DIR}/mongo-c-driver-1.10.2"
then
printf "\\n\\tUnable to remove directory %s/mongo-c-driver-1.9.3.\\n" "${TEMP_DIR}"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tUnable to remove directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/v3.2 --depth 1
if ! git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/v3.3 --depth 1
then
printf "\\tUnable to clone MongoDB C++ driver at this time.\\n"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${TEMP_DIR}/mongo-cxx-driver/build"
then
printf "\\n\\tUnable to enter directory %s/mongo-cxx-driver/build.\\n" "${TEMP_DIR}"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tUnable to enter directory %s/mongo-cxx-driver/build.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
then
printf "\\tCmake has encountered the above errors building the MongoDB C++ driver.\\n"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! sudo make -j"${JOBS}"
if ! sudo make -j"${CPU_CORE}"
then
printf "\\tError compiling MongoDB C++ driver.\\n"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! sudo make install
then
printf "\\tError installing MongoDB C++ driver.\\nMake sure you have sudo privileges.\\n"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! cd "${CWD}"
if ! cd "${TEMP_DIR}"
then
printf "\\n\\tUnable to enter directory %s.\\n" "${CWD}"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
if ! sudo rm -rf "${TEMP_DIR}/mongo-cxx-driver"
then
printf "\\n\\tUnable to remove directory %s/mongo-cxx-driver.\\n" "${TEMP_DIR}"
printf "\\n\\tExiting now.\\n\\n"
printf "\\tUnable to remove directory %s/mongo-cxx-driver.\\n" "${TEMP_DIR}" "${TEMP_DIR}"
printf "\\tExiting now.\\n\\n"
exit 1;
fi
printf "\\n\\tMongo C++ driver successfully installed @ /usr/local/lib/libmongocxx-static.a.\\n\\n"
printf "\\tMongo C++ driver installed at /usr/local/lib/libmongocxx-static.a.\\n"
else
printf "\\tMongo C++ driver found at /usr/local/lib/libmongocxx-static.a.\\n"
fi
......
......@@ -24,6 +24,9 @@ add_dependencies(plugin_test asserter test_api test_api_mem test_api_db test_api
#
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/core_symbol.py.in ${CMAKE_CURRENT_BINARY_DIR}/core_symbol.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testUtils.py ${CMAKE_CURRENT_BINARY_DIR}/testUtils.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/WalletMgr.py ${CMAKE_CURRENT_BINARY_DIR}/WalletMgr.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Node.py ${CMAKE_CURRENT_BINARY_DIR}/Node.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Cluster.py ${CMAKE_CURRENT_BINARY_DIR}/Cluster.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TestHelper.py ${CMAKE_CURRENT_BINARY_DIR}/TestHelper.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/p2p_tests/dawn_515/test.sh ${CMAKE_CURRENT_BINARY_DIR}/p2p_tests/dawn_515/test.sh COPYONLY)
......@@ -39,6 +42,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/validate-dirty-db.py ${CMAKE_CURRENT_
#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_sanity_test COMMAND tests/nodeos_run_test.py -v --sanity-test --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME nodeos_run_test COMMAND tests/nodeos_run_test.py -v --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME p2p_dawn515_test COMMAND tests/p2p_tests/dawn_515/test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
......
此差异已折叠。
此差异已折叠。
from testUtils import Utils
from testUtils import Cluster
from testUtils import WalletMgr
from Cluster import Cluster
from WalletMgr import WalletMgr
import argparse
......@@ -77,6 +77,8 @@ class TestHelper(object):
parser.add_argument("--only-bios", help="Limit testing to bios node.", action='store_true')
if "--clean-run" in includeArgs:
parser.add_argument("--clean-run", help="Kill all nodeos and kleos instances", action='store_true')
if "--sanity-test" in includeArgs:
parser.add_argument("--sanity-test", help="Validates nodeos and kleos are in path and can be started up.", action='store_true')
args = parser.parse_args()
return args
......
import subprocess
import time
import shutil
import signal
import os
from collections import namedtuple
import re
import sys
from testUtils import Utils
Wallet=namedtuple("Wallet", "name password host port")
# pylint: disable=too-many-instance-attributes
class WalletMgr(object):
__walletLogFile="test_keosd_output.log"
__walletDataDir="test_wallet_0"
# pylint: disable=too-many-arguments
# walletd [True|False] True=Launch wallet(keosd) process; False=Manage launch process externally.
def __init__(self, walletd, nodeosPort=8888, nodeosHost="localhost", port=8899, host="localhost"):
self.walletd=walletd
self.nodeosPort=nodeosPort
self.nodeosHost=nodeosHost
self.port=port
self.host=host
self.wallets={}
self.__walletPid=None
self.endpointArgs="--url http://%s:%d" % (self.nodeosHost, self.nodeosPort)
self.walletEndpointArgs=""
if self.walletd:
self.walletEndpointArgs += " --wallet-url http://%s:%d" % (self.host, self.port)
self.endpointArgs += self.walletEndpointArgs
def launch(self):
if not self.walletd:
Utils.Print("ERROR: Wallet Manager wasn't configured to launch keosd")
return False
cmd="%s --data-dir %s --config-dir %s --http-server-address=%s:%d --verbose-http-errors" % (
Utils.EosWalletPath, WalletMgr.__walletDataDir, WalletMgr.__walletDataDir, self.host, self.port)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
with open(WalletMgr.__walletLogFile, 'w') as sout, open(WalletMgr.__walletLogFile, 'w') as serr:
popen=subprocess.Popen(cmd.split(), stdout=sout, stderr=serr)
self.__walletPid=popen.pid
# Give keosd time to warm up
time.sleep(1)
return True
def create(self, name, accounts=None):
wallet=self.wallets.get(name)
if wallet is not None:
if Utils.Debug: Utils.Print("Wallet \"%s\" already exists. Returning same." % name)
return wallet
p = re.compile(r'\n\"(\w+)\"\n', re.MULTILINE)
cmd="%s %s wallet create --name %s" % (Utils.EosClientPath, self.endpointArgs, name)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
retStr=Utils.checkOutput(cmd.split())
#Utils.Print("create: %s" % (retStr))
m=p.search(retStr)
if m is None:
Utils.Print("ERROR: wallet password parser failure")
return None
p=m.group(1)
wallet=Wallet(name, p, self.host, self.port)
self.wallets[name] = wallet
if accounts:
for account in accounts:
Utils.Print("Importing keys for account %s into wallet %s." % (account.name, wallet.name))
if not self.importKey(account, wallet):
Utils.Print("ERROR: Failed to import key for account %s" % (account.name))
return False
return wallet
def importKey(self, account, wallet):
warningMsg="Key already in wallet"
cmd="%s %s wallet import --name %s %s" % (
Utils.EosClientPath, self.endpointArgs, wallet.name, account.ownerPrivateKey)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
try:
Utils.checkOutput(cmd.split())
except subprocess.CalledProcessError as ex:
msg=ex.output.decode("utf-8")
if warningMsg in msg:
Utils.Print("WARNING: This key is already imported into the wallet.")
else:
Utils.Print("ERROR: Failed to import account owner key %s. %s" % (account.ownerPrivateKey, msg))
return False
if account.activePrivateKey is None:
Utils.Print("WARNING: Active private key is not defined for account \"%s\"" % (account.name))
else:
cmd="%s %s wallet import --name %s %s" % (
Utils.EosClientPath, self.endpointArgs, wallet.name, account.activePrivateKey)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
try:
Utils.checkOutput(cmd.split())
except subprocess.CalledProcessError as ex:
msg=ex.output.decode("utf-8")
if warningMsg in msg:
Utils.Print("WARNING: This key is already imported into the wallet.")
else:
Utils.Print("ERROR: Failed to import account active key %s. %s" %
(account.activePrivateKey, msg))
return False
return True
def lockWallet(self, wallet):
cmd="%s %s wallet lock --name %s" % (Utils.EosClientPath, self.endpointArgs, wallet.name)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
if 0 != subprocess.call(cmd.split(), stdout=Utils.FNull):
Utils.Print("ERROR: Failed to lock wallet %s." % (wallet.name))
return False
return True
def unlockWallet(self, wallet):
cmd="%s %s wallet unlock --name %s" % (Utils.EosClientPath, self.endpointArgs, wallet.name)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
popen=subprocess.Popen(cmd.split(), stdout=Utils.FNull, stdin=subprocess.PIPE)
_, errs = popen.communicate(input=wallet.password.encode("utf-8"))
if 0 != popen.wait():
Utils.Print("ERROR: Failed to unlock wallet %s: %s" % (wallet.name, errs.decode("utf-8")))
return False
return True
def lockAllWallets(self):
cmd="%s %s wallet lock_all" % (Utils.EosClientPath, self.endpointArgs)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
if 0 != subprocess.call(cmd.split(), stdout=Utils.FNull):
Utils.Print("ERROR: Failed to lock all wallets.")
return False
return True
def getOpenWallets(self):
wallets=[]
p = re.compile(r'\s+\"(\w+)\s\*\",?\n', re.MULTILINE)
cmd="%s %s wallet list" % (Utils.EosClientPath, self.endpointArgs)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
retStr=Utils.checkOutput(cmd.split())
#Utils.Print("retStr: %s" % (retStr))
m=p.findall(retStr)
if m is None:
Utils.Print("ERROR: wallet list parser failure")
return None
wallets=m
return wallets
def getKeys(self, wallet):
keys=[]
p = re.compile(r'\n\s+\"(\w+)\"\n', re.MULTILINE)
cmd="%s %s wallet private_keys --name %s --password %s " % (Utils.EosClientPath, self.endpointArgs, wallet.name, wallet.password)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
retStr=Utils.checkOutput(cmd.split())
#Utils.Print("retStr: %s" % (retStr))
m=p.findall(retStr)
if m is None:
Utils.Print("ERROR: wallet private_keys parser failure")
return None
keys=m
return keys
def dumpErrorDetails(self):
Utils.Print("=================================================================")
if self.__walletPid is not None:
Utils.Print("Contents of %s:" % (WalletMgr.__walletLogFile))
Utils.Print("=================================================================")
with open(WalletMgr.__walletLogFile, "r") as f:
shutil.copyfileobj(f, sys.stdout)
def killall(self, allInstances=False):
"""Kill keos instances. allInstances will kill all keos instances running on the system."""
if self.__walletPid:
Utils.Print("Killing wallet manager process %d" % (self.__walletPid))
os.kill(self.__walletPid, signal.SIGKILL)
if allInstances:
cmd="pkill -9 %s" % (Utils.EosWalletName)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
subprocess.call(cmd.split())
@staticmethod
def cleanup():
dataDir=WalletMgr.__walletDataDir
if os.path.isdir(dataDir) and os.path.exists(dataDir):
shutil.rmtree(WalletMgr.__walletDataDir)
#!/usr/bin/env python3
import testUtils
from testUtils import Utils
from Cluster import Cluster
from TestHelper import TestHelper
import argparse
import subprocess
import tempfile
import os
......@@ -13,32 +14,20 @@ import os
# distributed-transactions-remote-test.py -v --clean-run --dump-error-detail
###############################################################
Print=testUtils.Utils.Print
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
pnodes=1
# nodesFile="tests/sample-cluster-map.json"
parser = argparse.ArgumentParser()
parser.add_argument("-p", type=int, help="producing nodes count", default=pnodes)
parser.add_argument("-v", help="verbose", action='store_true')
parser.add_argument("--leave-running", help="Leave cluster running after test finishes", action='store_true')
parser.add_argument("--dump-error-details",
help="Upon error print etc/eosio/node_*/config.ini and var/lib/node_*/stderr.log to stdout",
action='store_true')
parser.add_argument("--clean-run", help="Kill all nodeos and kleos instances", action='store_true')
args = parser.parse_args()
args = TestHelper.parse_args({"-p","--dump-error-details","-v","--leave-running","--clean-run"})
pnodes=args.p
# nodesFile=args.nodes_file
debug=args.v
dontKill=args.leave_running
dumpErrorDetails=args.dump_error_details
killAll=args.clean_run
testUtils.Utils.Debug=debug
Utils.Debug=debug
killEosInstances=not dontKill
topo="mesh"
......@@ -61,7 +50,7 @@ clusterMapJsonTemplate="""{
}
"""
cluster=testUtils.Cluster()
cluster=Cluster()
(fd, nodesFile) = tempfile.mkstemp()
try:
......@@ -80,7 +69,7 @@ try:
if not cluster.waitOnClusterBlockNumSync(3):
errorExit("Cluster never stabilized")
producerKeys=testUtils.Cluster.parseClusterKeys(total_nodes)
producerKeys=Cluster.parseClusterKeys(total_nodes)
defproduceraPrvtKey=producerKeys["defproducera"]["private"]
defproducerbPrvtKey=producerKeys["defproducerb"]["private"]
......@@ -100,13 +89,6 @@ try:
Print("\nEND")
finally:
os.remove(nodesFile)
if not testSuccessful and dumpErrorDetails:
cluster.dumpErrorDetails()
Print("== Errors see above ==")
if killEosInstances:
Print("Shut down the cluster and cleanup.")
cluster.killall(allInstances=killAll)
cluster.cleanup()
TestHelper.shutdown(cluster, None, testSuccessful, killEosInstances, False, False, killAll, dumpErrorDetails)
exit(0)
#!/usr/bin/env python3
import testUtils
from testUtils import Utils
from Cluster import Cluster
from WalletMgr import WalletMgr
from TestHelper import TestHelper
import random
Print=testUtils.Utils.Print
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
......@@ -30,12 +32,12 @@ killEosInstances=not dontKill
if nodesFile is not None:
killEosInstances=False
testUtils.Utils.Debug=debug
Utils.Debug=debug
testSuccessful=False
random.seed(seed) # Use a fixed seed for repeatability.
cluster=testUtils.Cluster(walletd=True)
walletMgr=testUtils.WalletMgr(True)
cluster=Cluster(walletd=True)
walletMgr=WalletMgr(True)
try:
cluster.setWalletMgr(walletMgr)
......
#!/usr/bin/env python3
import testUtils
from testUtils import Utils
from Cluster import Cluster
from TestHelper import TestHelper
import argparse
import subprocess
###############################################################
......@@ -11,29 +12,20 @@ import subprocess
# nodeos_run_remote_test.py -v --clean-run --dump-error-detail
###############################################################
Print=testUtils.Utils.Print
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
parser = argparse.ArgumentParser()
parser.add_argument("-v", help="verbose", action='store_true')
parser.add_argument("--leave-running", help="Leave cluster running after test finishes", action='store_true')
parser.add_argument("--only-bios", help="Limit testing to bios node.", action='store_true')
parser.add_argument("--dump-error-details",
help="Upon error print etc/eosio/node_*/config.ini and var/lib/node_*/stderr.log to stdout",
action='store_true')
parser.add_argument("--clean-run", help="Kill all nodeos and kleos instances", action='store_true')
args = parser.parse_args()
args = TestHelper.parse_args({"--dump-error-details","-v","--leave-running","--only-bios","--clean-run"})
debug=args.v
dontKill=args.leave_running
dumpErrorDetails=args.dump_error_details
onlyBios=args.only_bios
killAll=args.clean_run
testUtils.Utils.Debug=debug
Utils.Debug=debug
killEosInstances=not dontKill
topo="mesh"
......@@ -44,7 +36,7 @@ total_nodes=pnodes
actualTest="tests/nodeos_run_test.py"
testSuccessful=False
cluster=testUtils.Cluster()
cluster=Cluster()
try:
Print("BEGIN")
cluster.killall(allInstances=killAll)
......@@ -61,7 +53,7 @@ try:
if not cluster.waitOnClusterBlockNumSync(3):
errorExit("Cluster never stabilized")
producerKeys=testUtils.Cluster.parseClusterKeys(1)
producerKeys=Cluster.parseClusterKeys(1)
defproduceraPrvtKey=producerKeys["defproducera"]["private"]
defproducerbPrvtKey=producerKeys["defproducerb"]["private"]
......@@ -73,18 +65,6 @@ try:
testSuccessful=True
finally:
if testSuccessful:
Print("Test succeeded.")
else:
Print("Test failed.")
if not testSuccessful and dumpErrorDetails:
cluster.dumpErrorDetails()
Print("== Errors see above ==")
if killEosInstances:
Print("Shut down the cluster and cleanup.")
cluster.killall(allInstances=killAll)
cluster.cleanup()
TestHelper.shutdown(cluster, None, testSuccessful, killEosInstances, False, False, killAll, dumpErrorDetails)
exit(0)
#!/usr/bin/env python3
#from testUtils import Utils
import testUtils
from testUtils import Utils
from Cluster import Cluster
from WalletMgr import WalletMgr
from Node import Node
from TestHelper import TestHelper
import decimal
......@@ -13,8 +15,8 @@ import re
# --keep-logs <Don't delete var/lib/node_* folders upon test completion>
###############################################################
Print=testUtils.Utils.Print
errorExit=testUtils.Utils.errorExit
Print=Utils.Print
errorExit=Utils.errorExit
from core_symbol import CORE_SYMBOL
......@@ -26,7 +28,8 @@ def cmdError(name, cmdCode=0, exitNow=False):
Print(msg)
args = TestHelper.parse_args({"--host","--port","--prod-count","--defproducera_prvt_key","--defproducerb_prvt_key","--mongodb"
,"--dump-error-details","--dont-launch","--keep-logs","-v","--leave-running","--only-bios","--clean-run"})
,"--dump-error-details","--dont-launch","--keep-logs","-v","--leave-running","--only-bios","--clean-run"
,"--sanity-test"})
server=args.host
port=args.port
debug=args.v
......@@ -40,18 +43,20 @@ dontKill=args.leave_running
prodCount=args.prod_count
onlyBios=args.only_bios
killAll=args.clean_run
sanityTest=args.sanity_test
testUtils.Utils.Debug=debug
Utils.Debug=debug
localTest=True if server == TestHelper.LOCAL_HOST else False
cluster=testUtils.Cluster(walletd=True, enableMongo=enableMongo, defproduceraPrvtKey=defproduceraPrvtKey, defproducerbPrvtKey=defproducerbPrvtKey)
walletMgr=testUtils.WalletMgr(True)
cluster=Cluster(walletd=True, enableMongo=enableMongo, defproduceraPrvtKey=defproduceraPrvtKey, defproducerbPrvtKey=defproducerbPrvtKey)
walletMgr=WalletMgr(True)
testSuccessful=False
killEosInstances=not dontKill
killWallet=not dontKill
dontBootstrap=sanityTest
WalletdName="keosd"
ClientName="cleos"
# testUtils.Utils.setMongoSyncTime(50)
# Utils.setMongoSyncTime(50)
try:
Print("BEGIN")
......@@ -68,17 +73,21 @@ try:
cluster.killall(allInstances=killAll)
cluster.cleanup()
Print("Stand up cluster")
if cluster.launch(prodCount=prodCount, onlyBios=onlyBios, dontKill=dontKill) is False:
if cluster.launch(prodCount=prodCount, onlyBios=onlyBios, dontKill=dontKill, dontBootstrap=dontBootstrap) is False:
cmdError("launcher")
errorExit("Failed to stand up eos cluster.")
else:
cluster.initializeNodes(defproduceraPrvtKey=defproduceraPrvtKey, defproducerbPrvtKey=defproducerbPrvtKey)
killEosInstances=False
if sanityTest:
testSuccessful=True
exit(0)
Print("Validating system accounts after bootstrap")
cluster.validateAccounts(None)
accounts=testUtils.Cluster.createAccountKeys(3)
accounts=Cluster.createAccountKeys(3)
if accounts is None:
errorExit("FAILURE - create keys")
testeraAccount=accounts[0]
......@@ -283,7 +292,7 @@ try:
cmdError("%s transfer" % (ClientName))
errorExit("Failed to transfer funds %d from account %s to %s" % (
transferAmount, testeraAccount.name, currencyAccount.name))
transId=testUtils.Node.getTransId(trans)
transId=Node.getTransId(trans)
expectedAmount="98.0311 {0}".format(CORE_SYMBOL) # 5000 initial deposit
Print("Verify transfer, Expected: %s" % (expectedAmount))
......@@ -476,12 +485,12 @@ try:
if trans is None or not trans[0]:
cmdError("%s push message currency1111 transfer" % (ClientName))
errorExit("Failed to push message to currency1111 contract")
transId=testUtils.Node.getTransId(trans[1])
transId=Node.getTransId(trans[1])
Print("push duplicate transfer action to currency1111 contract")
transDuplicate=node.pushMessage(contract, action, data, opts, True)
if transDuplicate is not None and transDuplicate[0]:
transDuplicateId=testUtils.Node.getTransId(transDuplicate[1])
transDuplicateId=Node.getTransId(transDuplicate[1])
if transId != transDuplicateId:
cmdError("%s push message currency1111 duplicate transfer incorrectly accepted, but they were generated with different transaction ids, it is likely a timing issue, report if problem persists, \norig: %s \ndup: %s" % (ClientName, trans, transDuplicate))
else:
......@@ -599,7 +608,7 @@ try:
if trans is None or not trans[0]:
cmdError("%s push message currency1111 transfer" % (ClientName))
errorExit("Failed to push message to currency1111 contract")
transId=testUtils.Node.getTransId(trans[1])
transId=Node.getTransId(trans[1])
Print("read current contract balance")
amountStr=node.getCurrencyBalance("currency1111", defproduceraAccount.name, "CUR")
......@@ -733,7 +742,7 @@ try:
# TBD: getTransByBlockId() needs to handle multiple returned transactions
# trans=node.getTransByBlockId(blockId, retry=False)
# if trans is not None:
# transId=testUtils.Node.getTransId(trans)
# transId=Node.getTransId(trans)
# trans2=node.getMessageFromDb(transId)
# if trans2 is None:
# errorExit("mongo get messages by transaction id %s" % (transId))
......
#!/usr/bin/env python3
import testUtils
from testUtils import Utils
from Cluster import Cluster
from WalletMgr import WalletMgr
from TestHelper import TestHelper
import random
......@@ -22,7 +24,7 @@ import traceback
###############################################################
Print=testUtils.Utils.Print
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
......@@ -46,12 +48,12 @@ killAll=args.clean_run
p2pPlugin=args.p2p_plugin
seed=1
testUtils.Utils.Debug=debug
Utils.Debug=debug
testSuccessful=False
random.seed(seed) # Use a fixed seed for repeatability.
cluster=testUtils.Cluster(walletd=True)
walletMgr=testUtils.WalletMgr(True)
cluster=Cluster(walletd=True)
walletMgr=WalletMgr(True)
try:
cluster.setChainStrategy(chainSyncStrategyStr)
......
此差异已折叠。
#!/usr/bin/env python3
import testUtils
from testUtils import Utils
from Cluster import Cluster
from TestHelper import TestHelper
import random
......@@ -12,7 +13,7 @@ import signal
###############################################################
Print=testUtils.Utils.Print
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
......@@ -23,10 +24,10 @@ debug=args.v
pnodes=1
topo="mesh"
delay=1
chainSyncStrategyStr=testUtils.Utils.SyncResyncTag
chainSyncStrategyStr=Utils.SyncResyncTag
total_nodes = pnodes
killCount=1
killSignal=testUtils.Utils.SigKillTag
killSignal=Utils.SigKillTag
killEosInstances= not args.leave_running
dumpErrorDetails=args.dump_error_details
......@@ -34,7 +35,7 @@ keepLogs=args.keep_logs
killAll=args.clean_run
seed=1
testUtils.Utils.Debug=debug
Utils.Debug=debug
testSuccessful=False
def runNodeosAndGetOutput(myNodeId, myTimeout=3):
......@@ -58,7 +59,7 @@ def runNodeosAndGetOutput(myNodeId, myTimeout=3):
return (True, output)
random.seed(seed) # Use a fixed seed for repeatability.
cluster=testUtils.Cluster(walletd=True)
cluster=Cluster(walletd=True)
try:
cluster.setChainStrategy(chainSyncStrategyStr)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册