提交 a94c1b7d 编写于 作者: A Anton Perkov

Merge branch 'master' into clang-stl

......@@ -78,7 +78,7 @@ script:
- mkdir build && cd build
- ${CMAKE_DIR}cmake -G Ninja -DWASM_LLVM_CONFIG=$TRAVIS_BUILD_DIR/ext/wasm-compiler/bin/llvm-config -DSecp256k1_ROOT_DIR=$TRAVIS_BUILD_DIR/ext -DBINARYEN_ROOT=$TRAVIS_BUILD_DIR/ext/wasm-compiler -DCMAKE_PREFIX_PATH=$TRAVIS_BUILD_DIR/ext -DCMAKE_BUILD_TYPE=Release -DBUILD_MONGO_DB_PLUGIN=true $EOS_CMAKE_OPTIONS ..
- ninja -j4
- '[ "$TRAVIS_OS_NAME" == "osx" ] || ctest --output-on-failure'
- '[ "$TRAVIS_OS_NAME" == "osx" ] || (export EOSLIB=$TRAVIS_BUILD_DIR/contracts; ctest --output-on-failure)'
- cpack
deploy:
......
......@@ -19,20 +19,26 @@ namespace eosio {
static bool exists( scope_name scope = Code ) {
uint64_t key = SingletonName;
auto read = load_i64( scope, Code, key, (char*)&key, sizeof(key) );
auto read = load_i64( Code, scope, key, (char*)&key, sizeof(key) );
return read > 0;
}
static T get( scope_name scope = Code ) {
char temp[1024+8];
*reinterpret_cast<uint64_t *>(temp) = SingletonName;
auto read = load_i64( scope, Code, SingletonName, temp, sizeof(temp) );
auto read = load_i64( Code, scope, SingletonName, temp, sizeof(temp) );
eos_assert( read > 0, "singleton does not exist" );
datastream<const char*> ds(temp + sizeof(SingletonName), read);
return unpack<T>( temp + sizeof(SingletonName), read );
}
T result;
unpack( ds, result );
return result;
static T get_or_default( scope_name scope = Code, const T& def = T() ) {
char temp[1024+8];
*reinterpret_cast<uint64_t *>(temp) = SingletonName;
auto read = load_i64( Code, scope, SingletonName, temp, sizeof(temp) );
if ( read < 0 ) {
return def;
}
return unpack<T>( temp + sizeof(SingletonName), read );
}
static T get_or_create( scope_name scope = Code, const T& def = T() ) {
......@@ -40,16 +46,12 @@ namespace eosio {
*reinterpret_cast<uint64_t *>(temp) = SingletonName;
auto read = load_i64( scope, Code, SingletonName, temp, sizeof(temp) );
auto read = load_i64( Code, scope, SingletonName, temp, sizeof(temp) );
if( read < 0 ) {
set( def, scope );
return def;
}
datastream<const char*> ds(temp + sizeof(SingletonName), read);
T result;
ds >> result;
return result;
return unpack<T>( temp + sizeof(SingletonName), read );
}
static void set( const T& value = T(), scope_name scope = Code, account_name b = BillToAccount ) {
......@@ -64,6 +66,11 @@ namespace eosio {
store_i64( scope, SingletonName, b, buf, sizeof(buf) );
}
static void remove( scope_name scope = Code ) {
uint64_t key = SingletonName;
remove_i64( scope, SingletonName, &key );
}
};
} /// namespace eosio
......@@ -93,7 +93,7 @@ namespace eosio {
temp[1] = secondary;
temp[2] = tertiary;
auto read = lower_bound_primary_i64i64i64( Code, _scope, TableName,
auto read = lower_bound_primary_i64i64i64( Code, _scope, TableName,
(char*)temp, sizeof(temp) );
if( read <= 0 ) {
return false;
......@@ -104,21 +104,31 @@ namespace eosio {
return true;
}
bool next_primary( T& result, const T& current ) {
bool primary_upper_bound( T& result,
uint64_t primary = 0,
uint64_t secondary = 0,
uint64_t tertiary = 0 ) {
uint64_t temp[1024/8];
memcpy( temp, (const char*)&current, 3*sizeof(uint64_t) );
auto read = next_primary_i64i64i64( Code, _scope, TableName,
temp[0] = primary;
temp[1] = secondary;
temp[2] = tertiary;
auto read = upper_bound_primary_i64i64i64( Code, _scope, TableName,
(char*)temp, sizeof(temp) );
if( read <= 0 ) {
return false;
}
datastream<const char*> ds( (char*)temp, sizeof(temp) );
ds >> result;
result = unpack<T>( (char*)temp, sizeof(temp) );
return true;
}
bool next_primary( T& result, const T& current ) {
const uint64_t* keys = reinterpret_cast<const uint64_t*>(&current);
return primary_upper_bound(result, keys[0], keys[1], keys[2]);
}
void store( const T& value, account_name bill_to = BillToAccount ) {
char temp[1024];
datastream<char*> ds(temp, sizeof(temp) );
......
......@@ -62,18 +62,12 @@
{"name":"identity", "type":"uint64"},
{"name":"creator", "type":"account_name"}
]
},{
"name": "trustrow",
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"trusted", "type":"uint8"}
]
},{
"name": "accountrow",
"base": "",
"fields": [
{"name":"account", "type":"account_name"}
{"name":"singleton_name", "type":"uint64"},
{"name":"identity", "type":"uint64"}
]
}
],
......@@ -110,7 +104,7 @@
"key_types": [ "uint64" ]
},{
"name": "trust",
"type": "trustrow",
"type": "account_name",
"index_type": "i64",
"key_names" : [ "account" ],
"key_types": [ "account_name" ]
......
......@@ -2,6 +2,7 @@
#include <eosiolib/chain.h>
#include <eosiolib/dispatcher.hpp>
#include <eosiolib/singleton.hpp>
#include <eosiolib/table.hpp>
#include <eosiolib/vector.hpp>
#include <eosiolib/string.hpp>
......@@ -10,6 +11,7 @@ namespace identity {
using eosio::action_meta;
using eosio::table_i64i64i64;
using eosio::table64;
using eosio::singleton;
using eosio::string;
using eosio::vector;
......@@ -195,8 +197,8 @@ namespace identity {
typedef table_i64i64i64<code, N(certs), code, certrow> certs_table;
typedef table64<code, N(ident), code, identrow> idents_table;
typedef table64<code, N(account), code, identity_name> accounts_table;
typedef table64<code, N(trust), code, trustrow> trust_table;
typedef singleton<code, N(account), code, identity_name> accounts_table;
typedef table64<code, N(trust), code, account_name> trust_table;
static identity_name get_claimed_identity( account_name acnt ) {
return accounts_table::get_or_default(acnt, 0);
......@@ -209,13 +211,19 @@ namespace identity {
certs_table certs( ident );
certrow row;
bool ok = certs.primary_lower_bound(row, N(owner), 1, 0);
account_name owner = 0;
while (ok && row.property == N(owner) && row.trusted) {
if (sizeof(account_name) == row.data.size()) {
account_name account = *reinterpret_cast<account_name*>(row.data.data());
if (ident == get_claimed_identity(account)) {
if (is_trusted(row.certifier) ) {
// the certifier is still trusted
return account;
if (!owner || owner == account) {
owner = account;
} else {
//contradiction found: different owners certified for the same identity
return 0;
}
} else if (DeployToAccount == current_receiver()){
//the certifier is no longer trusted, need to unset the flag
row.trusted = 0;
......@@ -227,8 +235,13 @@ namespace identity {
} else {
// bad row - skip it
}
//ok = certs.primary_upper_bound(row, row.property, row.trusted, row.certifier);
ok = certs.next_primary(row, row);
}
if (owner) {
//owner found, no contradictions among certifications flaged as trusted
return owner;
}
// trusted certification not found
// let's see if some of untrusted certifications became trusted
ok = certs.primary_lower_bound(row, N(owner), 0, 0);
......@@ -236,18 +249,25 @@ namespace identity {
if (sizeof(account_name) == row.data.size()) {
account_name account = *reinterpret_cast<account_name*>(row.data.data());
if (ident == get_claimed_identity(account) && is_trusted(row.certifier)) {
// the certifier became trusted, need to set the flag
row.trusted = 1;
certs.store( row, 0 ); //assuming 0 means bill to the same account
return *reinterpret_cast<account_name*>(row.data.data());
if (DeployToAccount == current_receiver()) {
// the certifier became trusted and we have permissions to update the flag
row.trusted = 1;
certs.store( row, 0 ); //assuming 0 means bill to the same account
}
if (!owner || owner == account) {
owner = account;
} else {
//contradiction found: different owners certified for the same identity
return 0;
}
}
} else {
// bad row - skip it
}
//ok = certs.primary_upper_bound(row, row.property, row.trusted, row.certifier);
ok = certs.next_primary(row, row);
}
return 0;
return owner;
}
static identity_name get_identity_for_account( account_name acnt ) {
......@@ -258,10 +278,7 @@ namespace identity {
}
static bool is_trusted_by( account_name trusted, account_name by ) {
trustrow def;
def.trusted = 0;
trustrow row = trust_table::get_or_default( trusted, by, def );
return def.trusted;
return trust_table::exists(trusted, by);
}
static bool is_trusted( account_name acnt ) {
......@@ -283,13 +300,9 @@ namespace identity {
require_recipient( t.trusting );
if( t.trust != 0 ) {
trustrow row{ .account = t.trusting,
.trusted = t.trust };
trust_table::set( row, t.trustor );
trust_table::set( t.trusting, t.trustor );
} else {
trustrow row{ .account = t.trusting,
.trusted = t.trust };
trust_table::remove( row.account, t.trustor );
trust_table::remove( t.trusting, t.trustor );
}
}
......@@ -318,7 +331,7 @@ namespace identity {
row.trusted = is_trusted( cert.certifier );
row.certifier = cert.certifier;
row.confidence = value.confidence;
eos_assert(value.type.get_size() <= 32, "certrow::type shouldn't be longer than 32 bytes");
eos_assert(value.type.get_size() <= 32, "certrow::type should be not longer than 32 bytes");
row.type = value.type;
row.data = value.data;
......@@ -330,17 +343,21 @@ namespace identity {
if (value.property == N(owner)) {
eos_assert(sizeof(account_name) == value.data.size(), "data size doesn't match account_name size");
account_name acnt = *reinterpret_cast<const account_name*>(value.data.data());
accounts_table::set( acnt, cert.identity );
if (cert.certifier == acnt) { //only self-certitication affects accounts_table
accounts_table::set( cert.identity, acnt );
}
}
} else {
//remove both tursted and untrusted because we cannot now if it was trusted back at creation time
//remove both tursted and untrusted because we cannot know if it was trusted back at creation time
certs.remove(value.property, 0, cert.certifier);
certs.remove(value.property, 1, cert.certifier);
//special handling for owner
if (value.property == N(owner)) {
eos_assert(sizeof(account_name) == value.data.size(), "data size doesn't match account_name size");
account_name acnt = *reinterpret_cast<const account_name*>(value.data.data());
accounts_table::remove( acnt, cert.identity );
if (cert.certifier == acnt) { //only self-certitication affects accounts_table
accounts_table::remove( acnt );
}
}
}
}
......
......@@ -9,6 +9,20 @@
namespace proxy {
using namespace eosio;
namespace configs {
bool get(config &out, const account_name &self) {
auto read = load_i64(self, self, N(config), (char*)&out, sizeof(config));
if (read < 0) {
return false;
}
return true;
}
void store(const config &in, const account_name &self) {
store_i64(self, N(config), self, (const char *)&in, sizeof(config));
}
};
template<typename T>
void apply_transfer(account_name code, const T& transfer) {
config code_config;
......
......@@ -3,7 +3,6 @@
* @copyright defined in eos/LICENSE.txt
*/
#include <eosiolib/eosio.hpp>
#include <eosiolib/db.hpp>
namespace proxy {
......@@ -22,6 +21,4 @@ namespace proxy {
uint32_t next_id = 0;
};
using configs = eosio::table<N(proxy),N(proxy),N(configs),N(proxy),config,uint64_t>;
} /// namespace proxy
......@@ -655,57 +655,25 @@ using apply_handler = std::function<void(apply_context&)>;
template< typename ObjectType >
using key_helper = key_helper_impl<ObjectType, ObjectType::number_of_keys - 1>;
/// find_tuple helper
template <typename KeyType, int KeyIndex, typename ...Args>
struct exact_tuple_impl {
static auto get(const contracts::table_id_object& tid, const KeyType* keys, Args... args ) {
return exact_tuple_impl<KeyType, KeyIndex - 1, const KeyType &, Args...>::get(tid, keys, raw_key_value(keys, KeyIndex), args...);
}
};
template <typename KeyType, typename ...Args>
struct exact_tuple_impl<KeyType, -1, Args...> {
static auto get(const contracts::table_id_object& tid, const KeyType*, Args... args) {
return boost::make_tuple(tid.id, args...);
}
};
template <typename ObjectType>
using exact_tuple = exact_tuple_impl<typename ObjectType::key_type, ObjectType::number_of_keys - 1>;
template< typename KeyType, int NullKeyCount, typename Scope, typename ... Args >
struct lower_bound_tuple_impl {
template< typename KeyType, int KeyIndex, size_t Offset, typename ... Args >
struct partial_tuple_impl {
static auto get(const contracts::table_id_object& tid, const KeyType* keys, Args... args) {
return lower_bound_tuple_impl<KeyType, NullKeyCount - 1, Scope, KeyType, Args...>::get(tid, keys, KeyType(0), args...);
return partial_tuple_impl<KeyType, KeyIndex - 1, Offset, KeyType, Args...>::get(tid, keys, raw_key_value(keys, Offset + KeyIndex), args...);
}
};
template< typename KeyType, typename Scope, typename ... Args >
struct lower_bound_tuple_impl<KeyType, 0, Scope, Args...> {
template< typename KeyType, size_t Offset, typename ... Args >
struct partial_tuple_impl<KeyType, 0, Offset, Args...> {
static auto get(const contracts::table_id_object& tid, const KeyType* keys, Args... args) {
return boost::make_tuple( tid.id, raw_key_value(keys, scope_to_key_index_v<Scope>), args...);
return boost::make_tuple( tid.id, raw_key_value(keys, Offset), args...);
}
};
template< typename IndexType, typename Scope >
using lower_bound_tuple = lower_bound_tuple_impl<typename IndexType::value_type::key_type, IndexType::value_type::number_of_keys - scope_to_key_index_v<Scope> - 1, Scope>;
using partial_tuple = partial_tuple_impl<typename IndexType::value_type::key_type, IndexType::value_type::number_of_keys - impl::scope_to_key_index_v<Scope> - 1, impl::scope_to_key_index_v<Scope>>;
template< typename KeyType, int NullKeyCount, typename Scope, typename ... Args >
struct upper_bound_tuple_impl {
static auto get(const contracts::table_id_object& tid, const KeyType* keys, Args... args) {
return upper_bound_tuple_impl<KeyType, NullKeyCount - 1, Scope, KeyType, Args...>::get(tid, keys, KeyType(-1), args...);
}
};
template< typename KeyType, typename Scope, typename ... Args >
struct upper_bound_tuple_impl<KeyType, 0, Scope, Args...> {
static auto get(const contracts::table_id_object& tid, const KeyType* keys, Args... args) {
return boost::make_tuple( tid.id, raw_key_value(keys, scope_to_key_index_v<Scope>), args...);
}
};
template< typename IndexType, typename Scope >
using upper_bound_tuple = upper_bound_tuple_impl<typename IndexType::value_type::key_type, IndexType::value_type::number_of_keys - scope_to_key_index_v<Scope> - 1, Scope>;
template <typename ObjectType>
using exact_tuple = partial_tuple_impl<typename ObjectType::key_type, ObjectType::number_of_keys - 1, 0>;
template <typename IndexType, typename Scope>
struct record_scope_compare {
......@@ -790,7 +758,7 @@ using apply_handler = std::function<void(apply_context&)>;
require_read_lock( t_id.code, t_id.scope );
const auto& idx = db.get_index<IndexType, Scope>();
auto tuple = impl::lower_bound_tuple<IndexType, Scope>::get(t_id, keys);
auto tuple = impl::partial_tuple<IndexType, Scope>::get(t_id, keys);
auto itr = idx.lower_bound(tuple);
if( itr == idx.end() ||
......@@ -862,49 +830,6 @@ using apply_handler = std::function<void(apply_context&)>;
}
}
template <typename IndexType, typename Scope>
int32_t apply_context::next_record( const table_id_object& t_id, typename IndexType::value_type::key_type* keys, char* value, size_t valuelen ) {
require_read_lock( t_id.code, t_id.scope );
const auto& pidx = db.get_index<IndexType, contracts::by_scope_primary>();
auto tuple = impl::exact_tuple<typename IndexType::value_type>::get(t_id, keys);
auto pitr = pidx.find(tuple);
if(pitr == pidx.end())
return -1;
const auto& fidx = db.get_index<IndexType>();
auto itr = fidx.indicies().template project<Scope>(pitr);
const auto& idx = db.get_index<IndexType, Scope>();
if( itr == idx.end() ||
itr->t_id != t_id.id ||
!impl::key_helper<typename IndexType::value_type>::compare(*itr, keys) ) {
return -1;
}
++itr;
if( itr == idx.end() ||
itr->t_id != t_id.id ) {
return -1;
}
impl::key_helper<typename IndexType::value_type>::get(keys, *itr);
if (valuelen) {
auto copylen = std::min<size_t>(itr->value.size(), valuelen);
if (copylen) {
itr->value.copy(value, copylen);
}
return copylen;
} else {
return itr->value.size();
}
}
template <typename IndexType, typename Scope>
int32_t apply_context::previous_record( const table_id_object& t_id, typename IndexType::value_type::key_type* keys, char* value, size_t valuelen ) {
require_read_lock( t_id.code, t_id.scope );
......@@ -949,7 +874,7 @@ using apply_handler = std::function<void(apply_context&)>;
require_read_lock( t_id.code, t_id.scope );
const auto& idx = db.get_index<IndexType, Scope>();
auto tuple = impl::lower_bound_tuple<IndexType, Scope>::get(t_id, keys);
auto tuple = impl::partial_tuple<IndexType, Scope>::get(t_id, keys);
auto itr = idx.lower_bound(tuple);
if( itr == idx.end() ||
......@@ -973,7 +898,7 @@ using apply_handler = std::function<void(apply_context&)>;
require_read_lock( t_id.code, t_id.scope );
const auto& idx = db.get_index<IndexType, Scope>();
auto tuple = impl::upper_bound_tuple<IndexType, Scope>::get(t_id, keys);
auto tuple = impl::partial_tuple<IndexType, Scope>::get(t_id, keys);
auto itr = idx.upper_bound(tuple);
if( itr == idx.end() ||
......
......@@ -103,22 +103,6 @@ struct abi_def {
vector<table_def> tables;
};
struct transfer {
account_name from;
account_name to;
uint64 amount;
string memo;
static account_name get_account() {
return config::system_account_name;
}
static name get_name() {
return N(transfer);
}
};
struct newaccount {
account_name creator;
account_name name;
......
......@@ -527,9 +527,10 @@ class producer_api : public context_aware_api {
int get_active_producers(array_ptr<chain::account_name> producers, size_t datalen) {
auto active_producers = context.get_active_producers();
size_t len = std::min(datalen / sizeof(chain::account_name), active_producers.size());
memcpy(producers, active_producers.data(), len);
return active_producers.size() * sizeof(chain::account_name);
size_t len = active_producers.size() * sizeof(chain::account_name);
size_t cpy_len = std::min(datalen, len);
memcpy(producers, active_producers.data(), cpy_len);
return len;
}
};
......@@ -784,7 +785,7 @@ class db_index_api : public context_aware_api {
int call(ContextMethodType method, const account_name& code, const scope_name& scope, const name& table, array_ptr<char> data, size_t data_len) {
auto maybe_t_id = context.find_table(context.receiver, scope, table);
auto maybe_t_id = context.find_table(code, scope, table);
if (maybe_t_id == nullptr) {
return -1;
}
......@@ -1058,7 +1059,6 @@ REGISTER_INTRINSICS(memory_api,
(load, int32_t(int64_t, int64_t, int64_t, int, int), "load_"#SUFFIX )\
(front, int32_t(int64_t, int64_t, int64_t, int, int), "front_"#SUFFIX )\
(back, int32_t(int64_t, int64_t, int64_t, int, int), "back_"#SUFFIX )\
(next, int32_t(int64_t, int64_t, int64_t, int, int), "next_"#SUFFIX )\
(previous, int32_t(int64_t, int64_t, int64_t, int, int), "previous_"#SUFFIX )\
(lower_bound, int32_t(int64_t, int64_t, int64_t, int, int), "lower_bound_"#SUFFIX )\
(upper_bound, int32_t(int64_t, int64_t, int64_t, int, int), "upper_bound_"#SUFFIX )\
......
......@@ -102,6 +102,11 @@ namespace fc
*/
std::string to_string( log_level ll = log_level::info )const;
/**
* Generates a user-friendly error report.
*/
std::string top_message( )const;
/**
* Throw this exception as its most derived type.
*
......
......@@ -185,6 +185,21 @@ namespace fc
return ss.str();
}
/**
* Generates a user-friendly error report.
*/
string exception::top_message( )const
{
for( auto itr = my->_elog.begin(); itr != my->_elog.end(); ++itr )
{
auto s = fc::format_string( itr->get_format(), itr->get_data() );
if (!s.empty()) {
return s;
}
}
return string();
}
void NO_RETURN exception_factory::rethrow( const exception& e )const
{
auto itr = _registered_exceptions.find( e.code() );
......
......@@ -2,6 +2,7 @@
#include <eosio/chain/chain_controller.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <iostream>
namespace eosio { namespace testing {
......@@ -14,6 +15,8 @@ namespace eosio { namespace testing {
*/
class tester {
public:
typedef string action_result;
tester(bool process_genesis = true);
void close();
......@@ -25,6 +28,7 @@ namespace eosio { namespace testing {
transaction_trace push_transaction( packed_transaction& trx );
transaction_trace push_transaction( signed_transaction& trx );
action_result push_action(action&& cert_act, uint64_t authorizer);
void set_tapos( signed_transaction& trx ) const;
void create_accounts( vector<account_name> names, asset init_bal, bool multisig = false ) {
......@@ -65,6 +69,18 @@ namespace eosio { namespace testing {
const symbol& asset_symbol,
const account_name& account ) const;
static vector<uint8_t> to_uint8_vector(const string& s);
static vector<uint8_t> to_uint8_vector(uint64_t x);
static uint64_t to_uint64(fc::variant x);
static string to_string(fc::variant x);
static action_result success() { return string(); }
static action_result error(const string& msg) { return msg; }
private:
fc::temp_directory tempdir;
chain_controller::controller_config cfg;
......@@ -88,4 +104,5 @@ namespace eosio { namespace testing {
string expected;
};
} } /// eosio::testing
#include <boost/test/unit_test.hpp>
#include <eosio/testing/tester.hpp>
#include <eosio/chain/asset.hpp>
#include <eosio/chain/contracts/types.hpp>
......@@ -157,6 +158,26 @@ namespace eosio { namespace testing {
return push_transaction( ptrx );
}
tester::action_result tester::push_action(action&& cert_act, uint64_t authorizer) {
signed_transaction trx;
if (authorizer) {
cert_act.authorization = vector<permission_level>{{authorizer, config::active_name}};
}
trx.actions.emplace_back(std::move(cert_act));
set_tapos(trx);
if (authorizer) {
trx.sign(get_private_key(authorizer, "active"), chain_id_type());
}
try {
push_transaction(trx);
} catch (const fc::exception& ex) {
return error(ex.top_message());
}
produce_block();
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id()));
return success();
}
void tester::create_account( account_name a, string initial_balance, account_name creator, bool multisig ) {
create_account( a, asset::from_string(initial_balance), creator, multisig );
}
......@@ -357,5 +378,31 @@ namespace eosio { namespace testing {
return asset(result, asset_symbol);
}
vector<uint8_t> tester::to_uint8_vector(const string& s) {
vector<uint8_t> v(s.size());
copy(s.begin(), s.end(), v.begin());
return v;
};
vector<uint8_t> tester::to_uint8_vector(uint64_t x) {
vector<uint8_t> v(sizeof(x));
*reinterpret_cast<uint64_t*>(v.data()) = x;
return v;
};
uint64_t tester::to_uint64(fc::variant x) {
vector<uint8_t> blob;
fc::from_variant<uint8_t>(x, blob);
FC_ASSERT(8 == blob.size());
return *reinterpret_cast<uint64_t*>(blob.data());
}
string tester::to_string(fc::variant x) {
vector<uint8_t> v;
fc::from_variant<uint8_t>(x, v);
string s(v.size(), 0);
copy(v.begin(), v.end(), s.begin());
return s;
}
} } /// eosio::test
......@@ -196,13 +196,13 @@ public:
fc::variant get_currency_stats( const get_currency_stats_params& params )const;
void copy_row(const chain::contracts::key_value_object& obj, vector<char>& data)const {
static void copy_row(const chain::contracts::key_value_object& obj, vector<char>& data) {
data.resize( sizeof(uint64_t) + obj.value.size() );
memcpy( data.data(), &obj.primary_key, sizeof(uint64_t) );
memcpy( data.data()+sizeof(uint64_t), obj.value.data(), obj.value.size() );
}
void copy_row(const chain::contracts::keystr_value_object& obj, vector<char>& data)const {
static void copy_row(const chain::contracts::keystr_value_object& obj, vector<char>& data) {
data.resize( obj.primary_key.size() + obj.value.size() + 8 );
fc::datastream<char*> ds(data.data(), data.size());
fc::raw::pack(ds, obj.primary_key);
......@@ -210,14 +210,14 @@ public:
data.resize(ds.tellp());
}
void copy_row(const chain::contracts::key128x128_value_object& obj, vector<char>& data)const {
static void copy_row(const chain::contracts::key128x128_value_object& obj, vector<char>& data) {
data.resize( 2*sizeof(uint128_t) + obj.value.size() );
memcpy( data.data(), &obj.primary_key, sizeof(uint128_t) );
memcpy( data.data()+sizeof(uint128_t), &obj.secondary_key, sizeof(uint128_t) );
memcpy( data.data()+2*sizeof(uint128_t), obj.value.data(), obj.value.size() );
}
void copy_row(const chain::contracts::key64x64x64_value_object& obj, vector<char>& data)const {
static void copy_row(const chain::contracts::key64x64x64_value_object& obj, vector<char>& data) {
data.resize( 3*sizeof(uint64_t) + obj.value.size() );
memcpy( data.data(), &obj.primary_key, sizeof(uint64_t) );
memcpy( data.data()+sizeof(uint64_t), &obj.secondary_key, sizeof(uint64_t) );
......
此差异已折叠。
......@@ -38,7 +38,7 @@ target_link_libraries( chain_test eosio_testing eosio_chain chainbase eos_utilit
if(WASM_TOOLCHAIN)
target_include_directories( chain_test PUBLIC ${CMAKE_BINARY_DIR}/contracts ${CMAKE_CURRENT_BINARY_DIR}/tests/contracts )
target_include_directories( chain_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/wasm_tests )
add_dependencies(chain_test asserter test_api currency proxy stltest)
add_dependencies(chain_test asserter test_api currency proxy identity stltest)
endif()
......@@ -70,21 +70,22 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testUtils.py ${CMAKE_CURRENT_BINARY_D
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/eosiod_run_test.py ${CMAKE_CURRENT_BINARY_DIR}/eosiod_run_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/eosiod_run_remote_test.py ${CMAKE_CURRENT_BINARY_DIR}/eosiod_run_remote_test.py COPYONLY)
add_test(NAME eosiod_run_test COMMAND tests/eosiod_run_test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME p2p_sync_test COMMAND tests/p2p_tests/sync/test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME p2p_sync_test_p2_d10 COMMAND tests/p2p_tests/sync/test.sh -p 2 -d 10 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME message_storm COMMAND tests/p2p_tests/sync/test.sh -m -p 21 -n 21 -d 5 -l WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME p2p_dawn515_test COMMAND tests/p2p_tests/dawn_515/test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME eosiod_run_remote_test COMMAND tests/eosiod_run_remote_test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
if(BUILD_MONGO_DB_PLUGIN)
add_test(NAME eosiod_run_test-mongodb COMMAND tests/eosiod_run_test.py --mongodb --exit-early --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
add_test(chain_test chain_test)
add_test(NAME trans_sync_across_mixed_cluster_test COMMAND tests/trans_sync_across_mixed_cluster_test.sh -p 1 -n 2 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME distributed-transactions-test COMMAND tests/distributed-transactions-test.py -p 1 -n 4 --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME distributed-transactions-remote-test COMMAND tests/distributed-transactions-remote-test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME restart-scenarios-test_resync COMMAND tests/restart-scenarios-test.py -c resync -p3 --dumpErrorDetails WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME restart-scenarios-test_replay COMMAND tests/restart-scenarios-test.py -c replay -p3 --dumpErrorDetails WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(chain_test chain_test --report_level=detailed)
# TODO: Tests removed until working again on master.
# TODO: add_test(NAME eosiod_run_test COMMAND tests/eosiod_run_test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME p2p_sync_test COMMAND tests/p2p_tests/sync/test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME p2p_sync_test_p2_d10 COMMAND tests/p2p_tests/sync/test.sh -p 2 -d 10 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME message_storm COMMAND tests/p2p_tests/sync/test.sh -m -p 21 -n 21 -d 5 -l WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME p2p_dawn515_test COMMAND tests/p2p_tests/dawn_515/test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME eosiod_run_remote_test COMMAND tests/eosiod_run_remote_test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: if(BUILD_MONGO_DB_PLUGIN)
# TODO: add_test(NAME eosiod_run_test-mongodb COMMAND tests/eosiod_run_test.py --mongodb --exit-early --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: endif()
# TODO: add_test(NAME trans_sync_across_mixed_cluster_test COMMAND tests/trans_sync_across_mixed_cluster_test.sh -p 1 -n 2 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME distributed-transactions-test COMMAND tests/distributed-transactions-test.py -p 1 -n 4 --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME distributed-transactions-remote-test COMMAND tests/distributed-transactions-remote-test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME restart-scenarios-test_resync COMMAND tests/restart-scenarios-test.py -c resync -p3 --dumpErrorDetails WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME restart-scenarios-test_replay COMMAND tests/restart-scenarios-test.py -c replay -p3 --dumpErrorDetails WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
if(ENABLE_COVERAGE_TESTING)
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册