Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Unittest for old wasm host ptr fix #6581

Merged
merged 1 commit into from Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions unittests/contracts/test_wasts.hpp
Expand Up @@ -633,3 +633,17 @@ static const char memory_growth_memset_test[] = R"=====(
)
)
)=====";

static const char large_maligned_host_ptr[] = R"=====(
(module
(export "apply" (func $$apply))
(import "env" "get_active_producers" (func $$get_active_producers (param i32 i32) (result i32)))
(memory $$0 ${MAX_WASM_PAGES})
(func $$apply (param i64) (param i64) (param i64)
(drop (call $$get_active_producers
(i32.const 1)
(i32.const ${MAX_NAME_ARRAY})
))
)
)
)=====";
23 changes: 23 additions & 0 deletions unittests/wasm_tests.cpp
Expand Up @@ -1781,6 +1781,29 @@ BOOST_FIXTURE_TEST_CASE( getcode_checks, TESTER ) try {
wasm_to_wast( wasmx.data(), wasmx.size(), true );
} FC_LOG_AND_RETHROW()

BOOST_FIXTURE_TEST_CASE( big_maligned_host_ptr, TESTER ) try {
produce_blocks(2);
create_accounts( {N(bigmaligned)} );
produce_block();

string large_maligned_host_ptr_wast_f = fc::format_string(large_maligned_host_ptr, fc::mutable_variant_object()
("MAX_WASM_PAGES", eosio::chain::wasm_constraints::maximum_linear_memory/(64*1024))
("MAX_NAME_ARRAY", (eosio::chain::wasm_constraints::maximum_linear_memory-1)/sizeof(chain::account_name)));

set_code(N(bigmaligned), large_maligned_host_ptr_wast_f.c_str());
produce_blocks(1);

signed_transaction trx;
action act;
act.account = N(bigmaligned);
act.name = N();
act.authorization = vector<permission_level>{{N(bigmaligned),config::active_name}};
trx.actions.push_back(act);
set_transaction_headers(trx);
trx.sign(get_private_key( N(bigmaligned), "active" ), control->get_chain_id());
push_transaction(trx);
produce_blocks(1);
} FC_LOG_AND_RETHROW()

// TODO: restore net_usage_tests
#if 0
Expand Down