|
| 1 | +#include <boost/test/unit_test.hpp> |
| 2 | +#include <eosio/testing/tester.hpp> |
| 3 | +#include <eosio/chain/abi_serializer.hpp> |
| 4 | + |
| 5 | +#include <Runtime/Runtime.h> |
| 6 | + |
| 7 | +#include <fc/variant_object.hpp> |
| 8 | + |
| 9 | +#include <contracts.hpp> |
| 10 | + |
| 11 | +using namespace eosio; |
| 12 | +using namespace eosio::testing; |
| 13 | +using namespace eosio::chain; |
| 14 | +using namespace fc; |
| 15 | + |
| 16 | +using mvo = fc::mutable_variant_object; |
| 17 | + |
| 18 | +struct code_hash { |
| 19 | + uint64_t id; |
| 20 | + fc::sha256 hash; |
| 21 | + uint64_t primary_key() const { return id; } |
| 22 | +}; |
| 23 | +FC_REFLECT(code_hash, (id)(hash)) |
| 24 | + |
| 25 | +BOOST_AUTO_TEST_SUITE(get_code_hash_tests_suite) |
| 26 | + |
| 27 | +BOOST_FIXTURE_TEST_CASE( get_code_hash_tests, tester ) try { |
| 28 | + create_accounts( { "test"_n } ); |
| 29 | + produce_block(); |
| 30 | + |
| 31 | + set_code( "test"_n, contracts::get_code_hash_write_test_wasm() ); |
| 32 | + set_abi( "test"_n, contracts::get_code_hash_write_test_abi().data() ); |
| 33 | + |
| 34 | + produce_blocks(); |
| 35 | + push_action("test"_n, "theaction"_n, "test"_n, mvo()); |
| 36 | + code_hash entry; |
| 37 | + get_table_entry(entry, "test"_n, "test"_n, "code.hash"_n, 0); |
| 38 | + wdump((entry.hash)); |
| 39 | + |
| 40 | + set_code( "test"_n, contracts::get_code_hash_read_test_wasm() ); |
| 41 | + produce_blocks(); |
| 42 | + |
| 43 | + push_action("test"_n, "theaction"_n, "test"_n, mvo()); |
| 44 | +} FC_LOG_AND_RETHROW() |
| 45 | + |
| 46 | +BOOST_AUTO_TEST_SUITE_END() |
0 commit comments