提交 eee5c1da 编写于 作者: K Kevin Heifner

Additional tests for context free action access

上级 0dde5ef0
......@@ -101,6 +101,16 @@ void test_action::test_cf_action() {
memccpy(&v, &i, sizeof(i), sizeof(i));
// verify transaction api access
eosio_assert(transaction_size() > 0, "transaction_size failed");
// verify softfloat api access
float f1 = 1.0f, f2 = 2.0f;
float f3 = f1 + f2;
eosio_assert( f3 > 2.0f, "Unable to add float.");
// verify compiler builtin api access
__int128 ret;
__divti3(ret, 2, 2, 2, 2);
// verify context_free_system_api
eosio_assert( true, "verify eosio_assert can be called" );
} else if ( cfa.payload == 200 ) {
// attempt to access non context free api, privileged_api
......@@ -120,10 +130,31 @@ void test_action::test_cf_action() {
db_idx64_store( N(testapi), N(testapi), N(testapi), 0, &i );
eosio_assert( false, "db_api should not be allowed" );
} else if ( cfa.payload == 204 ) {
db_find_i64( N(testapi), N(testapi), N(testapi), 1);
eosio_assert( false, "db_api should not be allowed" );
} else if ( cfa.payload == 205 ) {
// attempt to access non context free api, send action
eosio::action dum_act;
dum_act.send();
eosio_assert( false, "action send should not be allowed" );
} else if ( cfa.payload == 206 ) {
eosio::require_auth(N(test));
eosio_assert( false, "authorization_api should not be allowed" );
} else if ( cfa.payload == 207 ) {
now();
eosio_assert( false, "system_api should not be allowed" );
} else if ( cfa.payload == 208 ) {
current_time();
eosio_assert( false, "system_api should not be allowed" );
} else if ( cfa.payload == 209 ) {
publication_time();
eosio_assert( false, "system_api should not be allowed" );
} else if ( cfa.payload == 210 ) {
send_inline( "hello", 6 );
eosio_assert( false, "transaction_api should not be allowed" );
} else if ( cfa.payload == 211 ) {
send_deferred( N(testapi), N(testapi), "hello", 6 );
eosio_assert( false, "transaction_api should not be allowed" );
}
}
......
......@@ -441,7 +441,7 @@ BOOST_FIXTURE_TEST_CASE(cf_action_tests, TESTER) { try {
trx.actions.clear();
trx.actions.push_back(act2);
set_transaction_headers(trx);
// run normal passing case
// run (dummy_action.b = 200) case looking for invalid use of context_free api
sigs = trx.sign(get_private_key(N(testapi), "active"), chain_id_type());
BOOST_CHECK_EXCEPTION(push_transaction(trx), assert_exception,
[](const fc::exception& e) {
......@@ -458,7 +458,7 @@ BOOST_FIXTURE_TEST_CASE(cf_action_tests, TESTER) { try {
trx.actions.push_back(act1);
// attempt to access non context free api
for (uint32_t i = 200; i <= 204; ++i) {
for (uint32_t i = 200; i <= 211; ++i) {
trx.context_free_actions.clear();
trx.context_free_data.clear();
cfa.payload = i;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册