未验证 提交 b934c307 编写于 作者: D Daniel Larimer 提交者: GitHub

Merge branch 'master' into issue3189

......@@ -23,7 +23,7 @@ namespace eosio {
}
inline void print( const std::string& s) {
prints(s.c_str());
prints_l( s.c_str(), s.size() );
}
/**
......
......@@ -26,10 +26,27 @@ extern "C" {
* Aborts processing of this action and unwinds all pending changes if the test condition is true
* @brief Aborts processing of this action and unwinds all pending changes
* @param test - 0 to abort, 1 to ignore
* @param cstr - a null terminated action to explain the reason for failure
* @param msg - a null terminated string explaining the reason for failure
*/
void eosio_assert( uint32_t test, const char* msg );
/**
* Aborts processing of this action and unwinds all pending changes if the test condition is true
* @brief Aborts processing of this action and unwinds all pending changes
* @param test - 0 to abort, 1 to ignore
* @param msg - a pointer to the start of string explaining the reason for failure
* @param msg_len - length of the string
*/
void eosio_assert_message( uint32_t test, const char* msg, uint32_t msg_len );
/**
* Aborts processing of this action and unwinds all pending changes if the test condition is true
* @brief Aborts processing of this action and unwinds all pending changes
* @param test - 0 to abort, 1 to ignore
* @param code - the error code
*/
void eosio_assert( uint32_t test, const char* cstr );
void eosio_assert_code( uint32_t test, uint64_t code );
/**
* This method will abort execution of wasm without failing the contract. This
......@@ -51,7 +68,7 @@ extern "C" {
* @return time in seconds from 1970 of the current block
*/
uint32_t now() {
return (uint32_t)( current_time() / 1000000 );
return (uint32_t)( current_time() / 1000000 );
}
///@ } systemcapi
......
......@@ -218,3 +218,10 @@ void test_action::test_current_time() {
eosio_assert( total == sizeof(uint64_t), "total == sizeof(uint64_t)");
eosio_assert( tmp == current_time(), "tmp == current_time()" );
}
void test_action::test_assert_code() {
uint64_t code = 0;
uint32_t total = read_action_data(&code, sizeof(uint64_t));
eosio_assert( total == sizeof(uint64_t), "total == sizeof(uint64_t)");
eosio_assert_code( false, code );
}
......@@ -78,6 +78,7 @@ extern "C" {
WASM_TEST_HANDLER(test_action, test_abort);
WASM_TEST_HANDLER_EX(test_action, test_current_receiver);
WASM_TEST_HANDLER(test_action, test_publication_time);
WASM_TEST_HANDLER(test_action, test_assert_code);
// test named actions
// We enforce action name matches action data type name, so name mangling will not work for these tests.
......
......@@ -71,6 +71,7 @@ struct test_action {
static void test_abort() __attribute__ ((noreturn)) ;
static void test_current_receiver(uint64_t receiver, uint64_t code, uint64_t action);
static void test_publication_time();
static void test_assert_code();
};
struct test_db {
......
......@@ -100,6 +100,7 @@ namespace eosio { namespace chain {
structs.clear();
actions.clear();
tables.clear();
error_messages.clear();
for( const auto& st : abi.structs )
structs[st.name] = st;
......@@ -115,6 +116,9 @@ namespace eosio { namespace chain {
for( const auto& t : abi.tables )
tables[t.name] = t.type;
for( const auto& e : abi.error_messages )
error_messages[e.error_code] = e.error_msg;
/**
* The ABI vector may contain duplicates which would make it
* an invalid ABI
......@@ -123,6 +127,7 @@ namespace eosio { namespace chain {
FC_ASSERT( structs.size() == abi.structs.size() );
FC_ASSERT( actions.size() == abi.actions.size() );
FC_ASSERT( tables.size() == abi.tables.size() );
FC_ASSERT( error_messages.size() == abi.error_messages.size() );
}
bool abi_serializer::is_builtin_type(const type_name& type)const {
......@@ -345,4 +350,12 @@ namespace eosio { namespace chain {
return type_name();
}
optional<string> abi_serializer::get_error_message( uint64_t error_code )const {
auto itr = error_messages.find( error_code );
if( itr == error_messages.end() )
return optional<string>();
return itr->second;
}
} }
......@@ -84,19 +84,36 @@ struct clause_pair {
string body;
};
struct error_message {
error_message() = default;
error_message( uint64_t error_code, const string& error_msg )
: error_code(error_code), error_msg(error_msg)
{}
uint64_t error_code;
string error_msg;
};
struct abi_def {
abi_def() = default;
abi_def(const vector<type_def>& types, const vector<struct_def>& structs, const vector<action_def>& actions, const vector<table_def>& tables, const vector<clause_pair>& clauses)
:version("eosio::abi/1.0"), types(types), structs(structs), actions(actions), tables(tables), ricardian_clauses(clauses)
abi_def(const vector<type_def>& types, const vector<struct_def>& structs, const vector<action_def>& actions, const vector<table_def>& tables, const vector<clause_pair>& clauses, const vector<error_message>& error_msgs)
:version("eosio::abi/1.0")
,types(types)
,structs(structs)
,actions(actions)
,tables(tables)
,ricardian_clauses(clauses)
,error_messages(error_msgs)
{}
string version;
vector<type_def> types;
vector<struct_def> structs;
vector<action_def> actions;
vector<table_def> tables;
vector<clause_pair> ricardian_clauses;
extensions_type abi_extensions;
string version;
vector<type_def> types;
vector<struct_def> structs;
vector<action_def> actions;
vector<table_def> tables;
vector<clause_pair> ricardian_clauses;
vector<error_message> error_messages;
extensions_type abi_extensions;
};
abi_def eosio_contract_abi(const abi_def& eosio_system_abi);
......@@ -107,6 +124,8 @@ FC_REFLECT( eosio::chain::type_def , (new_type_name)(typ
FC_REFLECT( eosio::chain::field_def , (name)(type) )
FC_REFLECT( eosio::chain::struct_def , (name)(base)(fields) )
FC_REFLECT( eosio::chain::action_def , (name)(type)(ricardian_contract) )
FC_REFLECT( eosio::chain::clause_pair , (id)(body) )
FC_REFLECT( eosio::chain::table_def , (name)(index_type)(key_names)(key_types)(type) )
FC_REFLECT( eosio::chain::abi_def , (version)(types)(structs)(actions)(tables)(ricardian_clauses)(abi_extensions) )
FC_REFLECT( eosio::chain::clause_pair , (id)(body) )
FC_REFLECT( eosio::chain::error_message , (error_code)(error_msg) )
FC_REFLECT( eosio::chain::abi_def , (version)(types)(structs)(actions)(tables)
(ricardian_clauses)(error_messages)(abi_extensions) )
......@@ -29,6 +29,7 @@ struct abi_serializer {
map<type_name, struct_def> structs;
map<name,type_name> actions;
map<name,type_name> tables;
map<uint64_t, string> error_messages;
typedef std::function<fc::variant(fc::datastream<const char*>&, bool, bool)> unpack_function;
typedef std::function<void(const fc::variant&, fc::datastream<char*>&, bool, bool)> pack_function;
......@@ -54,6 +55,8 @@ struct abi_serializer {
type_name get_action_type(name action)const;
type_name get_table_type(name action)const;
optional<string> get_error_message( uint64_t error_code )const;
fc::variant binary_to_variant(const type_name& type, const bytes& binary)const;
bytes variant_to_binary(const type_name& type, const fc::variant& var)const;
......
......@@ -167,6 +167,10 @@ namespace eosio { namespace chain {
3050001, "account name already exists" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_action_args_exception, action_validate_exception,
3050002, "Invalid Action Arguments" )
FC_DECLARE_DERIVED_EXCEPTION( eosio_assert_message_exception, action_validate_exception,
3050003, "eosio_assert_message assertion failure" )
FC_DECLARE_DERIVED_EXCEPTION( eosio_assert_code_exception, action_validate_exception,
3050004, "eosio_assert_code assertion failure" )
FC_DECLARE_DERIVED_EXCEPTION( database_exception, chain_exception,
3060000, "database exception" )
......
......@@ -44,6 +44,7 @@ namespace eosio { namespace chain { namespace resource_limits {
void initialize_account( const account_name& account );
void set_block_parameters( const elastic_limit_parameters& cpu_limit_parameters, const elastic_limit_parameters& net_limit_parameters );
void update_account_usage( const flat_set<account_name>& accounts, uint32_t ordinal );
void add_transaction_usage( const flat_set<account_name>& accounts, uint64_t cpu_usage, uint64_t net_usage, uint32_t ordinal );
void add_pending_ram_usage( const account_name account, int64_t ram_delta );
......
......@@ -79,6 +79,17 @@ void resource_limits_manager::set_block_parameters(const elastic_limit_parameter
});
}
void resource_limits_manager::update_account_usage(const flat_set<account_name>& accounts, uint32_t time_slot ) {
const auto& config = _db.get<resource_limits_config_object>();
for( const auto& a : accounts ) {
const auto& usage = _db.get<resource_usage_object,by_owner>( a );
_db.modify( usage, [&]( auto& bu ){
bu.net_usage.add( 0, time_slot, config.account_net_usage_average_window );
bu.cpu_usage.add( 0, time_slot, config.account_cpu_usage_average_window );
});
}
}
void resource_limits_manager::add_transaction_usage(const flat_set<account_name>& accounts, uint64_t cpu_usage, uint64_t net_usage, uint32_t time_slot ) {
const auto& state = _db.get<resource_limits_state_object>();
const auto& config = _db.get<resource_limits_config_object>();
......@@ -406,7 +417,7 @@ account_resource_limit resource_limits_manager::get_account_cpu_limit_ex( const
auto max_user_use_in_window = (uint128_t(virtual_cpu_capacity_in_window) * user_weight) / all_user_weight;
auto cpu_used_in_window = (usage.cpu_usage.value_ex * window_size) / config::rate_limiting_precision;
if( max_user_use_in_window <= cpu_used_in_window )
if( max_user_use_in_window <= cpu_used_in_window )
arl.available = 0;
else
arl.available = max_user_use_in_window - cpu_used_in_window;
......@@ -469,7 +480,7 @@ account_resource_limit resource_limits_manager::get_account_net_limit_ex( const
auto max_user_use_in_window = (virtual_network_capacity_in_window * user_weight) / all_user_weight;
auto net_used_in_window = (usage.net_usage.value_ex * window_size) / config::rate_limiting_precision;
if( max_user_use_in_window <= net_used_in_window )
if( max_user_use_in_window <= net_used_in_window )
arl.available = 0;
else
arl.available = max_user_use_in_window - net_used_in_window;
......
......@@ -82,7 +82,7 @@ namespace eosio { namespace chain {
validate_ram_usage.reserve( bill_to_accounts.size() );
// Update usage values of accounts to reflect new time
rl.add_transaction_usage( bill_to_accounts, 0, 0, block_timestamp_type(control.pending_block_time()).slot );
rl.update_account_usage( bill_to_accounts, block_timestamp_type(control.pending_block_time()).slot );
// Calculate the highest network usage and CPU time that all of the billed accounts can afford to be billed
int64_t account_net_limit = large_number_no_overflow;
......
......@@ -722,22 +722,22 @@ class crypto_api : public context_aware_api {
void assert_sha256(array_ptr<char> data, size_t datalen, const fc::sha256& hash_val) {
auto result = fc::sha256::hash( data, datalen );
FC_ASSERT( result == hash_val, "hash miss match" );
FC_ASSERT( result == hash_val, "hash mismatch" );
}
void assert_sha1(array_ptr<char> data, size_t datalen, const fc::sha1& hash_val) {
auto result = fc::sha1::hash( data, datalen );
FC_ASSERT( result == hash_val, "hash miss match" );
FC_ASSERT( result == hash_val, "hash mismatch" );
}
void assert_sha512(array_ptr<char> data, size_t datalen, const fc::sha512& hash_val) {
auto result = fc::sha512::hash( data, datalen );
FC_ASSERT( result == hash_val, "hash miss match" );
FC_ASSERT( result == hash_val, "hash mismatch" );
}
void assert_ripemd160(array_ptr<char> data, size_t datalen, const fc::ripemd160& hash_val) {
auto result = fc::ripemd160::hash( data, datalen );
FC_ASSERT( result == hash_val, "hash miss match" );
FC_ASSERT( result == hash_val, "hash mismatch" );
}
void sha1(array_ptr<char> data, size_t datalen, fc::sha1& hash_val) {
......@@ -902,11 +902,28 @@ public:
FC_ASSERT( false, "abort() called");
}
void eosio_assert(bool condition, null_terminated_ptr str) {
if( !condition ) {
std::string message( str );
// Kept as intrinsic rather than implementing on WASM side (using eosio_assert_message and strlen) because strlen is faster on native side.
void eosio_assert( bool condition, null_terminated_ptr msg ) {
if( BOOST_UNLIKELY( !condition ) ) {
std::string message( msg );
edump((message));
FC_ASSERT( condition, "assertion failed: ${s}", ("s",message));
EOS_THROW( eosio_assert_message_exception, "assertion failure with message: ${s}", ("s",message) );
}
}
void eosio_assert_message( bool condition, array_ptr<const char> msg, size_t msg_len ) {
if( BOOST_UNLIKELY( !condition ) ) {
std::string message( msg, msg_len );
edump((message));
EOS_THROW( eosio_assert_message_exception, "assertion failure with message: ${s}", ("s",message) );
}
}
void eosio_assert_code( bool condition, uint64_t error_code ) {
if( BOOST_UNLIKELY( !condition ) ) {
edump((error_code));
EOS_THROW( eosio_assert_code_exception,
"assertion failure with error code: ${error_code}", ("error_code", error_code) );
}
}
......@@ -945,6 +962,7 @@ class console_api : public context_aware_api {
console_api( apply_context& ctx )
:context_aware_api(ctx,true){}
// Kept as intrinsic rather than implementing on WASM side (using prints_l and strlen) because strlen is faster on native side.
void prints(null_terminated_ptr str) {
context.console_append<const char*>(str);
}
......@@ -1708,9 +1726,11 @@ REGISTER_INTRINSICS(system_api,
);
REGISTER_INTRINSICS(context_free_system_api,
(abort, void() )
(eosio_assert, void(int, int) )
(eosio_exit, void(int) )
(abort, void() )
(eosio_assert, void(int, int) )
(eosio_assert_message, void(int, int, int) )
(eosio_assert_code, void(int, int64_t) )
(eosio_exit, void(int) )
);
REGISTER_INTRINSICS(action_api,
......
......@@ -89,7 +89,7 @@ namespace eosio { namespace testing {
void produce_blocks_until_end_of_round();
void produce_blocks_for_n_rounds(const uint32_t num_of_rounds = 1);
// Produce minimal number of blocks as possible to spend the given time without having any producer become inactive
void produce_min_num_of_blocks_to_spend_time_wo_inactive_prod(const fc::microseconds target_elapsed_time = fc::microseconds());
void produce_min_num_of_blocks_to_spend_time_wo_inactive_prod(const fc::microseconds target_elapsed_time = fc::microseconds());
signed_block_ptr push_block(signed_block_ptr b);
transaction_trace_ptr push_transaction( packed_transaction& trx, fc::time_point deadline = fc::time_point::maximum(), uint32_t billed_cpu_time_us = DEFAULT_BILLED_CPU_TIME_US );
......@@ -209,7 +209,11 @@ namespace eosio { namespace testing {
static action_result success() { return string(); }
static action_result error(const string& msg) { return msg; }
static action_result error( const string& msg ) { return msg; }
static action_result wasm_assert_msg( const string& msg ) { return "assertion failure with message: " + msg; }
static action_result wasm_assert_code( uint64_t error_code ) { return "assertion failure with error code: " + std::to_string(error_code); }
auto get_resolver() {
return [this]( const account_name& name ) -> optional<abi_serializer> {
......@@ -426,11 +430,11 @@ namespace eosio { namespace testing {
*/
struct eosio_assert_message_is {
eosio_assert_message_is( const string& msg )
: expected( "assertion failed: " ) {
: expected( "assertion failure with message: " ) {
expected.append( msg );
}
bool operator()( const fc::assert_exception& ex );
bool operator()( const eosio_assert_message_exception& ex );
string expected;
};
......@@ -440,11 +444,25 @@ namespace eosio { namespace testing {
*/
struct eosio_assert_message_starts_with {
eosio_assert_message_starts_with( const string& msg )
: expected( "assertion failed: " ) {
: expected( "assertion failure with message: " ) {
expected.append( msg );
}
bool operator()( const fc::assert_exception& ex );
bool operator()( const eosio_assert_message_exception& ex );
string expected;
};
/**
* Utility predicate to check whether an eosio_assert_code error code is equivalent to a given number
*/
struct eosio_assert_code_is {
eosio_assert_code_is( uint64_t error_code )
: expected( "assertion failure with error code: " ) {
expected.append( std::to_string(error_code) );
}
bool operator()( const eosio_assert_code_exception& ex );
string expected;
};
......
......@@ -832,28 +832,27 @@ namespace eosio { namespace testing {
return match;
}
bool eosio_assert_message_is::operator()( const fc::assert_exception& ex ) {
bool eosio_assert_message_is::operator()( const eosio_assert_message_exception& ex ) {
auto message = ex.get_log().at( 0 ).get_message();
bool match = false;
auto pos = message.find( ": " );
if( pos != std::string::npos ) {
message = message.substr( pos + 2 );
match = (message == expected);
}
bool match = (message == expected);
if( !match ) {
BOOST_TEST_MESSAGE( "LOG: expected: " << expected << ", actual: " << message );
}
return match;
}
bool eosio_assert_message_starts_with::operator()( const fc::assert_exception& ex ) {
bool eosio_assert_message_starts_with::operator()( const eosio_assert_message_exception& ex ) {
auto message = ex.get_log().at( 0 ).get_message();
bool match = false;
auto pos = message.find( ": " );
if( pos != std::string::npos ) {
message = message.substr( pos + 2 );
match = boost::algorithm::starts_with( message, expected );
bool match = boost::algorithm::starts_with( message, expected );
if( !match ) {
BOOST_TEST_MESSAGE( "LOG: expected: " << expected << ", actual: " << message );
}
return match;
}
bool eosio_assert_code_is::operator()( const eosio_assert_code_exception& ex ) {
auto message = ex.get_log().at( 0 ).get_message();
bool match = (message == expected);
if( !match ) {
BOOST_TEST_MESSAGE( "LOG: expected: " << expected << ", actual: " << message );
}
......
......@@ -1179,7 +1179,8 @@ struct regproxy_subcommand {
register_proxy->set_callback([this] {
fc::variant act_payload = fc::mutable_variant_object()
("proxy", proxy);
("proxy", proxy)
("isproxy", true);
send_actions({create_action({permission_level{proxy,config::active_name}}, config::system_account_name, N(regproxy), act_payload)});
});
}
......@@ -1195,30 +1196,31 @@ struct unregproxy_subcommand {
unregister_proxy->set_callback([this] {
fc::variant act_payload = fc::mutable_variant_object()
("proxy", proxy);
send_actions({create_action({permission_level{proxy,config::active_name}}, config::system_account_name, N(unregproxy), act_payload)});
("proxy", proxy)
("isproxy", false);
send_actions({create_action({permission_level{proxy,config::active_name}}, config::system_account_name, N(regproxy), act_payload)});
});
}
};
struct canceldelay_subcommand {
string cancelling_account;
string cancelling_permission;
string canceling_account;
string canceling_permission;
string trx_id;
canceldelay_subcommand(CLI::App* actionRoot) {
auto cancel_delay = actionRoot->add_subcommand("canceldelay", localized("Cancel a delayed transaction"));
cancel_delay->add_option("cancelling_account", cancelling_account, localized("Account from authorization on the original delayed transaction"))->required();
cancel_delay->add_option("cancelling_permission", cancelling_permission, localized("Permission from authorization on the original delayed transaction"))->required();
cancel_delay->add_option("canceling_account", canceling_account, localized("Account from authorization on the original delayed transaction"))->required();
cancel_delay->add_option("canceling_permission", canceling_permission, localized("Permission from authorization on the original delayed transaction"))->required();
cancel_delay->add_option("trx_id", trx_id, localized("The transaction id of the original delayed transaction"))->required();
add_standard_transaction_options(cancel_delay);
cancel_delay->set_callback([this] {
const auto cancelling_auth = permission_level{cancelling_account, cancelling_permission};
const auto canceling_auth = permission_level{canceling_account, canceling_permission};
fc::variant act_payload = fc::mutable_variant_object()
("cancelling_auth", cancelling_auth)
("canceling_auth", canceling_auth)
("trx_id", trx_id);
send_actions({create_action({cancelling_auth}, config::system_account_name, N(canceldelay), act_payload)});
send_actions({create_action({canceling_auth}, config::system_account_name, N(canceldelay), act_payload)});
});
}
};
......
......@@ -302,11 +302,8 @@ BOOST_FIXTURE_TEST_CASE(action_tests, TESTER) { try {
CALL_TEST_FUNCTION( *this, "test_action", "assert_true", {});
//test assert_false
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( *this, "test_action", "assert_false", {}), assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "test_action::assert_false");
}
);
BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( *this, "test_action", "assert_false", {} ),
eosio_assert_message_exception, eosio_assert_message_is("test_action::assert_false") );
// test read_action_normal
dummy_action dummy13{DUMMY_ACTION_DEFAULT_A, DUMMY_ACTION_DEFAULT_B, DUMMY_ACTION_DEFAULT_C};
......@@ -413,11 +410,8 @@ BOOST_FIXTURE_TEST_CASE(action_tests, TESTER) { try {
// test current_time
produce_block();
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( *this, "test_action", "test_current_time", fc::raw::pack(now)), assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "assertion failed: tmp == current_time()");
}
);
BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( *this, "test_action", "test_current_time", fc::raw::pack(now) ),
eosio_assert_message_exception, eosio_assert_message_is("tmp == current_time()") );
// test test_current_receiver
CALL_TEST_FUNCTION( *this, "test_action", "test_current_receiver", fc::raw::pack(N(testapi)));
......@@ -547,11 +541,9 @@ BOOST_FIXTURE_TEST_CASE(cf_action_tests, TESTER) { try {
BOOST_CHECK_EQUAL(ttrace->action_traces[0].inline_traces[0].act.name, account_name("event1"));
BOOST_CHECK_EQUAL(ttrace->action_traces[0].inline_traces[0].act.authorization.size(), 0);
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( *this, "test_transaction", "send_cf_action_fail", {} ), assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "context free actions cannot have authorizations");
}
);
BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( *this, "test_transaction", "send_cf_action_fail", {} ),
eosio_assert_message_exception,
eosio_assert_message_is("context free actions cannot have authorizations") );
BOOST_REQUIRE_EQUAL( validate(), true );
} FC_LOG_AND_RETHROW() }
......@@ -851,11 +843,9 @@ BOOST_FIXTURE_TEST_CASE(transaction_tests, TESTER) { try {
);
// test send_action_inline_fail
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION(*this, "test_transaction", "send_action_inline_fail", {}), assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "test_action::assert_false");
}
);
BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION(*this, "test_transaction", "send_action_inline_fail", {}),
eosio_assert_message_exception,
eosio_assert_message_is("test_action::assert_false") );
// test send_transaction
CALL_TEST_FUNCTION(*this, "test_transaction", "send_transaction", {});
......@@ -1223,33 +1213,33 @@ BOOST_FIXTURE_TEST_CASE(multi_index_tests, TESTER) { try {
CALL_TEST_FUNCTION( *this, "test_multi_index", "idx_double_general", {});
CALL_TEST_FUNCTION( *this, "test_multi_index", "idx_long_double_general", {});
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_pk_iterator_exceed_end", {},
assert_exception, "cannot increment end iterator");
eosio_assert_message_exception, "cannot increment end iterator");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_sk_iterator_exceed_end", {},
assert_exception, "cannot increment end iterator");
eosio_assert_message_exception, "cannot increment end iterator");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_pk_iterator_exceed_begin", {},
assert_exception, "cannot decrement iterator at beginning of table");
eosio_assert_message_exception, "cannot decrement iterator at beginning of table");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_sk_iterator_exceed_begin", {},
assert_exception, "cannot decrement iterator at beginning of index");
eosio_assert_message_exception, "cannot decrement iterator at beginning of index");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_pass_pk_ref_to_other_table", {},
assert_exception, "object passed to iterator_to is not in multi_index");
eosio_assert_message_exception, "object passed to iterator_to is not in multi_index");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_pass_sk_ref_to_other_table", {},
assert_exception, "object passed to iterator_to is not in multi_index");
eosio_assert_message_exception, "object passed to iterator_to is not in multi_index");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_pass_pk_end_itr_to_iterator_to", {},
assert_exception, "object passed to iterator_to is not in multi_index");
eosio_assert_message_exception, "object passed to iterator_to is not in multi_index");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_pass_pk_end_itr_to_modify", {},
assert_exception, "cannot pass end iterator to modify");
eosio_assert_message_exception, "cannot pass end iterator to modify");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_pass_pk_end_itr_to_erase", {},
assert_exception, "cannot pass end iterator to erase");
eosio_assert_message_exception, "cannot pass end iterator to erase");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_pass_sk_end_itr_to_iterator_to", {},
assert_exception, "object passed to iterator_to is not in multi_index");
eosio_assert_message_exception, "object passed to iterator_to is not in multi_index");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_pass_sk_end_itr_to_modify", {},
assert_exception, "cannot pass end iterator to modify");
eosio_assert_message_exception, "cannot pass end iterator to modify");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_pass_sk_end_itr_to_erase", {},
assert_exception, "cannot pass end iterator to erase");
eosio_assert_message_exception, "cannot pass end iterator to erase");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_modify_primary_key", {},
assert_exception, "updater cannot change primary key when modifying an object");
eosio_assert_message_exception, "updater cannot change primary key when modifying an object");
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_multi_index", "idx64_run_out_of_avl_pk", {},
assert_exception, "next primary key in table is at autoincrement limit");
eosio_assert_message_exception, "next primary key in table is at autoincrement limit");
CALL_TEST_FUNCTION( *this, "test_multi_index", "idx64_sk_cache_pk_lookup", {});
CALL_TEST_FUNCTION( *this, "test_multi_index", "idx64_pk_cache_sk_lookup", {});
......@@ -1271,11 +1261,8 @@ BOOST_FIXTURE_TEST_CASE(fixedpoint_tests, TESTER) { try {
CALL_TEST_FUNCTION( *this, "test_fixedpoint", "test_subtraction", {});
CALL_TEST_FUNCTION( *this, "test_fixedpoint", "test_multiplication", {});
CALL_TEST_FUNCTION( *this, "test_fixedpoint", "test_division", {});
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( *this, "test_fixedpoint", "test_division_by_0", {}), assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "divide by zero");
}
);
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_fixedpoint", "test_division_by_0", {},
eosio_assert_message_exception, "divide by zero" );
BOOST_REQUIRE_EQUAL( validate(), true );
} FC_LOG_AND_RETHROW() }
......@@ -1308,11 +1295,8 @@ BOOST_FIXTURE_TEST_CASE(crypto_tests, TESTER) { try {
CALL_TEST_FUNCTION( *this, "test_crypto", "test_recover_key", payload );
CALL_TEST_FUNCTION( *this, "test_crypto", "test_recover_key_assert_true", payload );
payload[payload.size()-1] = 0;
BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( *this, "test_crypto", "test_recover_key_assert_false", payload ), assert_exception,
[](const fc::exception& e) {
return expect_assert_message( e, "check == p: Error expected key different than recovered key" );
}
);
BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( *this, "test_crypto", "test_recover_key_assert_false", payload ),
fc::assert_exception, fc_assert_exception_message_is("Error expected key different than recovered key") );
}
CALL_TEST_FUNCTION( *this, "test_crypto", "test_sha1", {} );
......@@ -1324,43 +1308,23 @@ BOOST_FIXTURE_TEST_CASE(crypto_tests, TESTER) { try {
CALL_TEST_FUNCTION( *this, "test_crypto", "sha512_no_data", {} );
CALL_TEST_FUNCTION( *this, "test_crypto", "ripemd160_no_data", {} );
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( *this, "test_crypto", "assert_sha256_false", {} ), assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "hash miss match");
}
);
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_crypto", "assert_sha256_false", {},
assert_exception, "hash mismatch" );
CALL_TEST_FUNCTION( *this, "test_crypto", "assert_sha256_true", {} );
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( *this, "test_crypto", "assert_sha1_false", {} ), assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "hash miss match");
}
);
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_crypto", "assert_sha1_false", {},
assert_exception, "hash mismatch" );
CALL_TEST_FUNCTION( *this, "test_crypto", "assert_sha1_true", {} );
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( *this, "test_crypto", "assert_sha1_false", {} ), assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "hash miss match");
}
);
CALL_TEST_FUNCTION( *this, "test_crypto", "assert_sha1_true", {} );
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( *this, "test_crypto", "assert_sha512_false", {} ), assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "hash miss match");
}
);
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_crypto", "assert_sha512_false", {},
assert_exception, "hash mismatch" );
CALL_TEST_FUNCTION( *this, "test_crypto", "assert_sha512_true", {} );
BOOST_CHECK_EXCEPTION(CALL_TEST_FUNCTION( *this, "test_crypto", "assert_ripemd160_false", {} ), assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "hash miss match");
}
);
CALL_TEST_FUNCTION_AND_CHECK_EXCEPTION( *this, "test_crypto", "assert_ripemd160_false", {},
assert_exception, "hash mismatch" );
CALL_TEST_FUNCTION( *this, "test_crypto", "assert_ripemd160_true", {} );
......@@ -1867,7 +1831,7 @@ BOOST_FIXTURE_TEST_CASE(permission_usage_tests, TESTER) { try {
N(testapi), config::active_name,
control->head_block_time() + fc::milliseconds(config::block_interval_ms)
})
), fc::assert_exception );
), eosio_assert_message_exception );
produce_blocks(5);
......@@ -1909,7 +1873,7 @@ BOOST_FIXTURE_TEST_CASE(permission_usage_tests, TESTER) { try {
N(bob), N(perm1),
permission_creation_time
})
), fc::assert_exception );
), eosio_assert_message_exception );
CALL_TEST_FUNCTION( *this, "test_permission", "test_permission_last_used",
fc::raw::pack(test_permission_last_used_action{
......@@ -1950,4 +1914,57 @@ BOOST_FIXTURE_TEST_CASE(account_creation_time_tests, TESTER) { try {
BOOST_REQUIRE_EQUAL( validate(), true );
} FC_LOG_AND_RETHROW() }
/*************************************************************************************
* eosio_assert_code_tests test cases
*************************************************************************************/
BOOST_FIXTURE_TEST_CASE(eosio_assert_code_tests, TESTER) { try {
produce_block();
create_account( N(testapi) );
produce_block();
set_code(N(testapi), test_api_wast);
const char* abi_string = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [],
"actions": [],
"tables": [],
"ricardian_clauses": [],
"error_messages": [
{"error_code": 1, "error_msg": "standard error message" },
{"error_code": 42, "error_msg": "The answer to life, the universe, and everything."}
]
"abi_extensions": []
}
)=====";
set_abi( N(testapi), abi_string );
auto var = fc::json::from_string(abi_string);
abi_serializer abis(var.as<abi_def>());
produce_blocks(10);
BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( *this, "test_action", "test_assert_code", fc::raw::pack((uint64_t)42) ),
eosio_assert_code_exception, eosio_assert_code_is(42) );
produce_block();
auto omsg1 = abis.get_error_message(1);
BOOST_REQUIRE_EQUAL( omsg1.valid(), true );
BOOST_CHECK_EQUAL( *omsg1, "standard error message" );
auto omsg2 = abis.get_error_message(2);
BOOST_CHECK_EQUAL( omsg2.valid(), false );
auto omsg3 = abis.get_error_message(42);
BOOST_REQUIRE_EQUAL( omsg3.valid(), true );
BOOST_CHECK_EQUAL( *omsg3, "The answer to life, the universe, and everything." );
produce_block();
BOOST_REQUIRE_EQUAL( validate(), true );
} FC_LOG_AND_RETHROW() }
BOOST_AUTO_TEST_SUITE_END()
......@@ -273,7 +273,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
// Spend some time so the producer pay pool is filled by the inflation rate
produce_min_num_of_blocks_to_spend_time_wo_inactive_prod(fc::seconds(30 * 24 * 3600)); // 30 days
// Since the total activated stake is less than 150,000,000, it shouldn't be possible to claim rewards
BOOST_REQUIRE_THROW(claim_rewards(N(runnerup1)), assert_exception);
BOOST_REQUIRE_THROW(claim_rewards(N(runnerup1)), eosio_assert_message_exception);
// This will increase the total vote stake by (40,000,000 - 1,000)
votepro( N(whale4), {N(prodq), N(prodr), N(prods), N(prodt), N(produ)} );
......@@ -317,7 +317,8 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
BOOST_REQUIRE(control->head_block_time().time_since_epoch() < first_june_2028);
// This should thrown an error, since block one can only unstake all his stake after 10 years
BOOST_REQUIRE_THROW(undelegate_bandwidth(N(b1), N(b1), core_from_string("49999500.0000"), core_from_string("49999500.0000")), assert_exception);
BOOST_REQUIRE_THROW(undelegate_bandwidth(N(b1), N(b1), core_from_string("49999500.0000"), core_from_string("49999500.0000")), eosio_assert_message_exception);
// Skip 10 years
produce_block(first_june_2028 - control->head_block_time().time_since_epoch());
......
......@@ -217,7 +217,7 @@ BOOST_FIXTURE_TEST_CASE( test_overspend, currency_tester ) try {
("memo", "overspend! Alice");
BOOST_CHECK_EXCEPTION( push_action(N(alice), N(transfer), data),
fc::assert_exception, eosio_assert_message_is("overdrawn balance") );
eosio_assert_message_exception, eosio_assert_message_is("overdrawn balance") );
produce_block();
BOOST_REQUIRE_EQUAL(get_balance(N(alice)), asset::from_string( "100.0000 CUR" ));
......@@ -581,7 +581,7 @@ BOOST_FIXTURE_TEST_CASE( test_input_quantity, currency_tester ) try {
// transfer using different symbol name fails
{
BOOST_REQUIRE_THROW(transfer(N(alice), N(carl), "20.50 USD"), fc::assert_exception);
BOOST_REQUIRE_THROW(transfer(N(alice), N(carl), "20.50 USD"), eosio_assert_message_exception);
}
// issue to alice using right precision
......
此差异已折叠。
......@@ -114,7 +114,7 @@ BOOST_FIXTURE_TEST_CASE( create_tests, eosio_token_tester ) try {
BOOST_FIXTURE_TEST_CASE( create_negative_max_supply, eosio_token_tester ) try {
BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: max-supply must be positive" ),
BOOST_REQUIRE_EQUAL( wasm_assert_msg( "max-supply must be positive" ),
create( N(alice), asset::from_string("-1000.000 TKN"))
);
......@@ -131,7 +131,7 @@ BOOST_FIXTURE_TEST_CASE( symbol_already_exists, eosio_token_tester ) try {
);
produce_blocks(1);
BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: token with symbol already exists" ),
BOOST_REQUIRE_EQUAL( wasm_assert_msg( "token with symbol already exists" ),
create( N(alice), asset::from_string("100 TKN"))
);
......@@ -198,11 +198,11 @@ BOOST_FIXTURE_TEST_CASE( issue_tests, eosio_token_tester ) try {
("balance", "500.000 TKN")
);
BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: quantity exceeds available supply" ),
BOOST_REQUIRE_EQUAL( wasm_assert_msg( "quantity exceeds available supply" ),
issue( N(alice), N(alice), asset::from_string("500.001 TKN"), "hola" )
);
BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: must issue positive quantity" ),
BOOST_REQUIRE_EQUAL( wasm_assert_msg( "must issue positive quantity" ),
issue( N(alice), N(alice), asset::from_string("-1.000 TKN"), "hola" )
);
......@@ -248,11 +248,11 @@ BOOST_FIXTURE_TEST_CASE( transfer_tests, eosio_token_tester ) try {
("whitelist", 1)
);
BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: overdrawn balance" ),
BOOST_REQUIRE_EQUAL( wasm_assert_msg( "overdrawn balance" ),
transfer( N(alice), N(bob), asset::from_string("701 CERO"), "hola" )
);
BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: must transfer positive quantity" ),
BOOST_REQUIRE_EQUAL( wasm_assert_msg( "must transfer positive quantity" ),
transfer( N(alice), N(bob), asset::from_string("-1000 CERO"), "hola" )
);
......
......@@ -229,8 +229,8 @@ BOOST_FIXTURE_TEST_CASE( identity_create, identity_tester ) try {
BOOST_REQUIRE_EQUAL( "alice", idnt["creator"].as_string());
//attempts to create already existing identity should fail
BOOST_REQUIRE_EQUAL(error("condition: assertion failed: identity already exists"), create_identity("alice", identity_val));
BOOST_REQUIRE_EQUAL(error("condition: assertion failed: identity already exists"), create_identity("bob", identity_val));
BOOST_REQUIRE_EQUAL(wasm_assert_msg("identity already exists"), create_identity("alice", identity_val));
BOOST_REQUIRE_EQUAL(wasm_assert_msg("identity already exists"), create_identity("bob", identity_val));
//alice can create more identities
BOOST_REQUIRE_EQUAL(success(), create_identity("alice", 2));
......@@ -242,7 +242,7 @@ BOOST_FIXTURE_TEST_CASE( identity_create, identity_tester ) try {
BOOST_REQUIRE_EQUAL(success(), create_identity("bob", 1));
//identity == 0 has special meaning, should be impossible to create
BOOST_REQUIRE_EQUAL(error("condition: assertion failed: identity=0 is not allowed"), create_identity("alice", 0));
BOOST_REQUIRE_EQUAL(wasm_assert_msg("identity=0 is not allowed"), create_identity("alice", 0));
//creating adentity without authentication is not allowed
BOOST_REQUIRE_EQUAL(error("missing authority of alice"), create_identity("alice", 3, false));
......@@ -301,7 +301,7 @@ BOOST_FIXTURE_TEST_CASE( certify_decertify, identity_tester ) try {
//certifying non-existent identity is not allowed
uint64_t non_existent = 11;
BOOST_REQUIRE_EQUAL(error("condition: assertion failed: identity does not exist"),
BOOST_REQUIRE_EQUAL(wasm_assert_msg("identity does not exist"),
certify("alice", non_existent, vector<fc::variant>{ mutable_variant_object()
("property", "name")
("type", "string")
......@@ -312,7 +312,7 @@ BOOST_FIXTURE_TEST_CASE( certify_decertify, identity_tester ) try {
);
//parameter "type" should be not longer than 32 bytes
BOOST_REQUIRE_EQUAL(error("condition: assertion failed: certrow::type should be not longer than 32 bytes"),
BOOST_REQUIRE_EQUAL(wasm_assert_msg("certrow::type should be not longer than 32 bytes"),
certify("alice", identity_val, vector<fc::variant>{ mutable_variant_object()
("property", "height")
("type", "super_long_type_name_wich_is_not_allowed")
......
......@@ -209,7 +209,7 @@ BOOST_FIXTURE_TEST_CASE( propose_approve_execute, eosio_msig_tester ) try {
("proposal_name", "first")
("executer", "alice")
),
fc::assert_exception,
eosio_assert_message_exception,
eosio_assert_message_is("transaction authorization failed")
);
......@@ -261,7 +261,7 @@ BOOST_FIXTURE_TEST_CASE( propose_approve_unapprove, eosio_msig_tester ) try {
("proposal_name", "first")
("executer", "alice")
),
fc::assert_exception,
eosio_assert_message_exception,
eosio_assert_message_is("transaction authorization failed")
);
......@@ -290,7 +290,7 @@ BOOST_FIXTURE_TEST_CASE( propose_approve_by_two, eosio_msig_tester ) try {
("proposal_name", "first")
("executer", "alice")
),
fc::assert_exception,
eosio_assert_message_exception,
eosio_assert_message_is("transaction authorization failed")
);
......@@ -325,7 +325,7 @@ BOOST_FIXTURE_TEST_CASE( propose_with_wrong_requested_auth, eosio_msig_tester )
("trx", trx)
("requested", vector<permission_level>{ { N(alice), config::active_name } } )
),
fc::assert_exception,
eosio_assert_message_exception,
eosio_assert_message_is("transaction authorization failed")
);
......@@ -406,9 +406,9 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
// / | \ <--- implicitly updated in onblock action
// alice active bob active carol active
set_authority(N(eosio), "active", authority(1,
vector<key_weight>{{get_private_key("eosio", "active").get_public_key(), 1}},
vector<permission_level_weight>{{{N(eosio.prods), config::active_name}, 1}}), "owner",
set_authority(N(eosio), "active", authority(1,
vector<key_weight>{{get_private_key("eosio", "active").get_public_key(), 1}},
vector<permission_level_weight>{{{N(eosio.prods), config::active_name}, 1}}), "owner",
{ { N(eosio), "active" } }, { get_private_key( N(eosio), "active" ) });
set_producers( {N(alice),N(bob),N(carol)} );
......@@ -433,7 +433,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance( "eosio" ) );
vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name },
vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name },
{N(carol), config::active_name} };
vector<permission_level> action_perm = {{N(eosio), config::active_name}};
......@@ -505,20 +505,19 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
BOOST_REQUIRE_EQUAL( transaction_receipt::executed, trace->receipt->status );
// can't create account because system contract was replace by the test_api contract
BOOST_REQUIRE_EXCEPTION(create_account_with_resources( N(alice1111112), N(eosio), core_from_string("1.0000"), false ),
fc::assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "condition: assertion failed: Unknown Test");
}
BOOST_REQUIRE_EXCEPTION( create_account_with_resources( N(alice1111112), N(eosio), core_from_string("1.0000"), false ),
eosio_assert_message_exception, eosio_assert_message_is("Unknown Test")
);
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester ) try {
// set up the link between (eosio active) and (eosio.prods active)
set_authority(N(eosio), "active", authority(1,
vector<key_weight>{{get_private_key("eosio", "active").get_public_key(), 1}},
vector<permission_level_weight>{{{N(eosio.prods), config::active_name}, 1}}), "owner",
set_authority(N(eosio), "active", authority(1,
vector<key_weight>{{get_private_key("eosio", "active").get_public_key(), 1}},
vector<permission_level_weight>{{{N(eosio.prods), config::active_name}, 1}}), "owner",
{ { N(eosio), "active" } }, { get_private_key( N(eosio), "active" ) });
create_accounts( { N(apple) } );
......@@ -544,7 +543,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
BOOST_REQUIRE_EQUAL( core_from_string("1000000000.0000"), get_balance( "eosio" ) );
vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name },
vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name },
{N(carol), config::active_name}, {N(apple), config::active_name}};
vector<permission_level> action_perm = {{N(eosio), config::active_name}};
......@@ -603,10 +602,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
("proposal_name", "first")
("executer", "alice")
),
fc::assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "condition: assertion failed: transaction authorization failed");
}
eosio_assert_message_exception, eosio_assert_message_is("transaction authorization failed")
);
//approve by apple
......@@ -631,11 +627,10 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
BOOST_REQUIRE_EQUAL( transaction_receipt::executed, trace->receipt->status );
// can't create account because system contract was replace by the test_api contract
BOOST_REQUIRE_EXCEPTION(create_account_with_resources( N(alice1111112), N(eosio), core_from_string("1.0000"), false ),
fc::assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "condition: assertion failed: Unknown Test");
}
BOOST_REQUIRE_EXCEPTION( create_account_with_resources( N(alice1111112), N(eosio), core_from_string("1.0000"), false ),
eosio_assert_message_exception, eosio_assert_message_is("Unknown Test")
);
} FC_LOG_AND_RETHROW()
......
......@@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE( tic_tac_toe_game ) try {
("host", "player1")
("by", "player1")
("mvt", mvt)
), assert_exception, eosio_assert_message_starts_with("it's not your turn yet"));
), eosio_assert_message_exception, eosio_assert_message_starts_with("it's not your turn yet"));
mvt = mutable_variant_object()
("row", 1)
......@@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE( tic_tac_toe_game ) try {
("host", "player1")
("by", "player2")
("mvt", mvt)
), assert_exception, eosio_assert_message_starts_with("not a valid movement"));
), eosio_assert_message_exception, eosio_assert_message_starts_with("not a valid movement"));
mvt = mutable_variant_object()
("row", 0)
......@@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE( tic_tac_toe_game ) try {
("host", "player1")
("by", "player2")
("mvt", mvt)
), assert_exception, eosio_assert_message_starts_with("the game has ended"));
), eosio_assert_message_exception, eosio_assert_message_starts_with("the game has ended"));
game current;
chain.get_table_entry(current, N(tic.tac.toe), N(player1), N(games), N(player2));
......@@ -181,13 +181,13 @@ BOOST_AUTO_TEST_CASE( tic_tac_toe_game ) try {
("host", "player1")
("by", "player2")
("mvt", mvt)
), assert_exception, eosio_assert_message_starts_with("game doesn't exists"));
), eosio_assert_message_exception, eosio_assert_message_starts_with("game doesn't exists"));
BOOST_CHECK_EXCEPTION(chain.push_action(N(tic.tac.toe), N(restart), N(player2), mutable_variant_object()
("challenger", "player2")
("host", "player1")
("by", "player2")
), assert_exception, eosio_assert_message_starts_with("game doesn't exists"));
), eosio_assert_message_exception, eosio_assert_message_starts_with("game doesn't exists"));
chain.push_action(N(tic.tac.toe), N(create), N(player2), mutable_variant_object()
("challenger", "player1")
......@@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE( tic_tac_toe_game ) try {
("host", "player2")
("by", "player2")
("mvt", mvt)
), assert_exception, eosio_assert_message_starts_with("it's not your turn yet"));
), eosio_assert_message_exception, eosio_assert_message_starts_with("it's not your turn yet"));
} FC_LOG_AND_RETHROW()
BOOST_AUTO_TEST_SUITE_END()
......@@ -120,7 +120,7 @@ BOOST_FIXTURE_TEST_CASE( basic_test, TESTER ) try {
trx.sign( get_private_key( N(asserter), "active" ), chain_id_type() );
yes_assert_id = trx.id();
BOOST_CHECK_THROW(push_transaction( trx ), assert_exception);
BOOST_CHECK_THROW(push_transaction( trx ), eosio_assert_message_exception);
}
produce_blocks(1);
......@@ -616,7 +616,7 @@ BOOST_FIXTURE_TEST_CASE(weighted_cpu_limit_tests, tester ) try {
while (count < 4) {
signed_transaction trx;
for (int i = 0; i < 10; ++i) {
for (int i = 0; i < 2; ++i) {
action act;
act.account = N(f_tests);
act.name = N() + (i * 16);
......@@ -629,7 +629,7 @@ BOOST_FIXTURE_TEST_CASE(weighted_cpu_limit_tests, tester ) try {
try {
push_transaction(trx, fc::time_point::maximum(), 0);
produce_blocks(1);
produce_block();
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id()));
pass = true;
count++;
......@@ -640,7 +640,7 @@ BOOST_FIXTURE_TEST_CASE(weighted_cpu_limit_tests, tester ) try {
BOOST_REQUIRE_EQUAL(true, validate());
if (count == 2) { // add a big weight on acc2, making f_tests out of resource
mgr.set_account_limits(N(acc2), -1, -1, 1000);
mgr.set_account_limits(N(acc2), -1, -1, 100000000);
}
}
BOOST_REQUIRE_EQUAL(count, 3);
......@@ -1130,7 +1130,7 @@ BOOST_FIXTURE_TEST_CASE( check_table_maximum, TESTER ) try {
trx.sign(get_private_key( N(tbl), "active" ), chain_id_type());
//should fail, a check to make sure assert() in wasm is being evaluated correctly
BOOST_CHECK_THROW(push_transaction(trx), assert_exception);
BOOST_CHECK_THROW(push_transaction(trx), eosio_assert_message_exception);
}
produce_blocks(1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册