提交 399e879c 编写于 作者: A arhag

fix eosiod tests by swapping order of generic_currency's account fields to...

fix eosiod tests by swapping order of generic_currency's account fields to match balance serialization assumption in chain_plugin
上级 0d62c0ce
......@@ -58,12 +58,12 @@ namespace eosio {
};
struct account {
uint64_t symbol = token_type::symbol;
token_type balance;
uint64_t symbol = token_type::symbol;
auto primary_key() const { return symbol; }
EOSLIB_SERIALIZE( account, (symbol)(balance) )
EOSLIB_SERIALIZE( account, (balance)(symbol) )
};
struct currency_stats {
......@@ -115,7 +115,7 @@ namespace eosio {
set_balance( code, get_balance( code ) + act.quantity, code, 0 );
inline_transfer( code, act.to, act.quantity );
inline_transfer( code, act.to, act.quantity );
}
......@@ -127,7 +127,7 @@ namespace eosio {
set_balance( act.to, get_balance( act.to ) + act.quantity, act.from, 0 );
}
static void inline_transfer( account_name from, account_name to, token_type quantity,
static void inline_transfer( account_name from, account_name to, token_type quantity,
string memo = string() )
{
action act( permission_level(from,N(active)), transfer_memo( from, to, asset(quantity), move(memo) ));
......@@ -141,6 +141,3 @@ namespace eosio {
};
} /// namespace eosio
......@@ -31,7 +31,7 @@ namespace eosio { namespace testing {
}
public_key_type base_tester::get_public_key( name keyname, string role ) const {
return get_private_key( keyname, role ).get_public_key();
return get_private_key( keyname, role ).get_public_key();
}
private_key_type base_tester::get_private_key( name keyname, string role ) const {
......@@ -90,7 +90,7 @@ namespace eosio { namespace testing {
owner_auth = authority( get_public_key( a, "owner" ) );
}
trx.actions.emplace_back( vector<permission_level>{{creator,config::active_name}},
trx.actions.emplace_back( vector<permission_level>{{creator,config::active_name}},
contracts::newaccount{
.creator = creator,
.name = a,
......@@ -133,23 +133,23 @@ namespace eosio { namespace testing {
return success();
}
transaction_trace base_tester::push_action( const account_name& code,
const action_name& acttype,
const account_name& actor,
transaction_trace base_tester::push_action( const account_name& code,
const action_name& acttype,
const account_name& actor,
const variant_object& data
)
)
{ try {
chain::contracts::abi_serializer abis( control->get_database().get<account_object,by_name>(code).get_abi() );
chain::contracts::abi_serializer abis( control->get_database().get<account_object,by_name>(code).get_abi() );
string action_type_name = abis.get_action_type(acttype);
action act;
act.account = code;
act.name = acttype;
act.authorization = vector<permission_level>{{actor, config::active_name}};
act.data = abis.variant_to_binary(action_type_name, data);
wdump((act));
signed_transaction trx;
trx.actions.emplace_back(std::move(act));
set_tapos(trx);
......@@ -261,7 +261,7 @@ namespace eosio { namespace testing {
});
set_tapos( trx );
trx.sign( get_private_key( account, "active" ), chain_id_type() );
trx.sign( get_private_key( account, "active" ), chain_id_type() );
push_transaction( trx );
} FC_CAPTURE_AND_RETHROW( (account)(perm)(auth)(parent) ) }
......@@ -319,7 +319,7 @@ namespace eosio { namespace testing {
const auto *obj = db.find<contracts::key_value_object, contracts::by_scope_primary>(boost::make_tuple(tbl->id, asset_symbol.value()));
if (obj) {
//balance is the second field after symbol, so skip the symbol
fc::datastream<const char *> ds(obj->value.data()+sizeof(symbol), obj->value.size()-sizeof(symbol));
fc::datastream<const char *> ds(obj->value.data(), obj->value.size());
fc::raw::unpack(ds, result);
}
}
......
......@@ -168,7 +168,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
void chain_plugin::plugin_startup()
{ try {
FC_ASSERT( fc::exists( my->genesis_file ),
"unable to find genesis file '${f}', check --genesis-json argument",
"unable to find genesis file '${f}', check --genesis-json argument",
("f",my->genesis_file.generic_string()) );
my->chain_config->block_log_dir = my->block_log_dir;
my->chain_config->shared_memory_dir = app().data_dir() / default_shared_memory_dir;
......@@ -306,7 +306,7 @@ read_only::get_table_rows_result read_only::get_table_rows( const read_only::get
return get_table_rows_ex<contracts::key_value_index, contracts::by_scope_primary>(p,abi);
} else if( table_type == KEYstr ) {
return get_table_rows_ex<contracts::keystr_value_index, contracts::by_scope_primary>(p,abi);
} else if( table_type == KEYi128i128 ) {
} else if( table_type == KEYi128i128 ) {
if( table_key == PRIMARY )
return get_table_rows_ex<contracts::key128x128_value_index, contracts::by_scope_primary>(p,abi);
if( table_key == SECONDARY )
......@@ -330,12 +330,12 @@ vector<asset> read_only::get_currency_balance( const read_only::get_currency_bal
fc::raw::unpack(ds, balance);
auto cursor = asset(balance, symbol(obj.primary_key));
if (p.symbol || cursor.symbol_name().compare(*p.symbol) == 0) {
if( !p.symbol || cursor.symbol_name().compare(*p.symbol) == 0 ) {
results.emplace_back(balance, symbol(obj.primary_key));
}
// return false if we are looking for one and found it, true otherwise
return p.symbol || cursor.symbol_name().compare(*p.symbol) != 0;
return !p.symbol || cursor.symbol_name().compare(*p.symbol) != 0;
});
return results;
......@@ -429,9 +429,9 @@ read_write::push_transactions_results read_write::push_transactions(const read_w
result.reserve(params.size());
for( const auto& item : params ) {
try {
result.emplace_back( push_transaction( item ) );
result.emplace_back( push_transaction( item ) );
} catch ( const fc::exception& e ) {
result.emplace_back( read_write::push_transaction_results{ transaction_id_type(),
result.emplace_back( read_write::push_transaction_results{ transaction_id_type(),
fc::mutable_variant_object( "error", e.to_detail_string() ) } );
}
}
......@@ -468,7 +468,7 @@ read_only::get_account_results read_only::get_account( const get_account_params&
const auto& permissions = d.get_index<permission_index,by_owner>();
auto perm = permissions.lower_bound( boost::make_tuple( params.account_name ) );
while( perm != permissions.end() && perm->owner == params.account_name ) {
/// TODO: lookup perm->parent name
/// TODO: lookup perm->parent name
name parent;
// Don't lookup parent if null
......@@ -476,8 +476,8 @@ read_only::get_account_results read_only::get_account( const get_account_params&
const auto* p = d.find<permission_object,by_id>( perm->parent );
if( p ) {
FC_ASSERT(perm->owner == p->owner, "Invalid parent");
parent = p->name;
}
parent = p->name;
}
}
result.permissions.push_back( permission{ perm->name, parent, perm->auth.to_authority() } );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册