From fcde0ee30046a11e4ddf27ff1f73900748fa8c04 Mon Sep 17 00:00:00 2001 From: Frank-AFN Date: Wed, 11 Mar 2020 17:35:55 +0800 Subject: [PATCH] Fix: test build bug and docker build failed --- tests/chain_plugin_tests.cpp | 15 ++++---- tests/get_table_tests.cpp | 68 +++++++++++++++++------------------- 2 files changed, 40 insertions(+), 43 deletions(-) diff --git a/tests/chain_plugin_tests.cpp b/tests/chain_plugin_tests.cpp index 9d94e384708..af44e2a2950 100644 --- a/tests/chain_plugin_tests.cpp +++ b/tests/chain_plugin_tests.cpp @@ -9,8 +9,7 @@ #include #include -#include -#include +#include #include @@ -42,18 +41,18 @@ BOOST_FIXTURE_TEST_CASE( get_block_with_invalid_abi, TESTER ) try { produce_block(); // setup contract and abi - set_code(N(asserter), asserter_wast); - set_abi(N(asserter), asserter_abi); + set_code( N(asserter), contracts::asserter_wasm() ); + set_abi( N(asserter), contracts::asserter_abi().data() ); produce_blocks(1); - auto resolver = [&,this]( const account_name& name ) -> optional { + auto resolver = [&,this]( const account_name& name ) -> fc::optional { try { const auto& accnt = this->control->db().get( name ); abi_def abi; if (abi_serializer::to_abi(accnt.abi, abi)) { return abi_serializer(abi, abi_serializer_max_time); } - return optional(); + return fc::optional(); } FC_RETHROW_EXCEPTIONS(error, "resolver failed at chain_plugin_tests::abi_invalid_type"); }; @@ -61,7 +60,7 @@ BOOST_FIXTURE_TEST_CASE( get_block_with_invalid_abi, TESTER ) try { BOOST_REQUIRE_EQUAL(true, resolver(N(asserter)).valid()); // make an action using the valid contract & abi - variant pretty_trx = mutable_variant_object() + fc::variant pretty_trx = fc::mutable_variant_object() ("actions", variants({ mutable_variant_object() ("account", "asserter") @@ -100,7 +99,7 @@ BOOST_FIXTURE_TEST_CASE( get_block_with_invalid_abi, TESTER ) try { BOOST_TEST(block_str.find("011253686f756c64204e6f742041737365727421") != std::string::npos); //action data // set an invalid abi (int8->xxxx) - std::string abi2 = asserter_abi; + std::string abi2 = contracts::asserter_abi().data(); auto pos = abi2.find("int8"); BOOST_TEST(pos != std::string::npos); abi2.replace(pos, 4, "xxxx"); diff --git a/tests/get_table_tests.cpp b/tests/get_table_tests.cpp index 8084ddd2f93..f806edc76ae 100644 --- a/tests/get_table_tests.cpp +++ b/tests/get_table_tests.cpp @@ -9,14 +9,7 @@ #include #include -#include -#include - -#include -#include - -#include -#include +#include #include @@ -51,8 +44,8 @@ BOOST_FIXTURE_TEST_CASE( get_scope_test, TESTER ) try { create_accounts(accs); produce_block(); - set_code( N(eosio.token), eosio_token_wast ); - set_abi( N(eosio.token), eosio_token_abi ); + set_code( N(eosio.token), contracts::eosio_token_wasm() ); + set_abi( N(eosio.token), contracts::eosio_token_abi().data() ); produce_blocks(1); // create currency @@ -76,14 +69,14 @@ BOOST_FIXTURE_TEST_CASE( get_scope_test, TESTER ) try { eosio::chain_apis::read_only::get_table_by_scope_params param{N(eosio.token), N(accounts), "inita", "", 10}; eosio::chain_apis::read_only::get_table_by_scope_result result = plugin.read_only::get_table_by_scope(param); - BOOST_REQUIRE_EQUAL(4, result.rows.size()); + BOOST_REQUIRE_EQUAL(4u, result.rows.size()); BOOST_REQUIRE_EQUAL("", result.more); if (result.rows.size() >= 4) { BOOST_REQUIRE_EQUAL(name(N(eosio.token)), result.rows[0].code); BOOST_REQUIRE_EQUAL(name(N(inita)), result.rows[0].scope); BOOST_REQUIRE_EQUAL(name(N(accounts)), result.rows[0].table); BOOST_REQUIRE_EQUAL(name(N(eosio)), result.rows[0].payer); - BOOST_REQUIRE_EQUAL(1, result.rows[0].count); + BOOST_REQUIRE_EQUAL(1u, result.rows[0].count); BOOST_REQUIRE_EQUAL(name(N(initb)), result.rows[1].scope); BOOST_REQUIRE_EQUAL(name(N(initc)), result.rows[2].scope); @@ -93,7 +86,7 @@ BOOST_FIXTURE_TEST_CASE( get_scope_test, TESTER ) try { param.lower_bound = "initb"; param.upper_bound = "initc"; result = plugin.read_only::get_table_by_scope(param); - BOOST_REQUIRE_EQUAL(2, result.rows.size()); + BOOST_REQUIRE_EQUAL(2u, result.rows.size()); BOOST_REQUIRE_EQUAL("", result.more); if (result.rows.size() >= 2) { BOOST_REQUIRE_EQUAL(name(N(initb)), result.rows[0].scope); @@ -102,17 +95,17 @@ BOOST_FIXTURE_TEST_CASE( get_scope_test, TESTER ) try { param.limit = 1; result = plugin.read_only::get_table_by_scope(param); - BOOST_REQUIRE_EQUAL(1, result.rows.size()); + BOOST_REQUIRE_EQUAL(1u, result.rows.size()); BOOST_REQUIRE_EQUAL("initc", result.more); param.table = name(0); result = plugin.read_only::get_table_by_scope(param); - BOOST_REQUIRE_EQUAL(1, result.rows.size()); + BOOST_REQUIRE_EQUAL(1u, result.rows.size()); BOOST_REQUIRE_EQUAL("initc", result.more); param.table = N(invalid); result = plugin.read_only::get_table_by_scope(param); - BOOST_REQUIRE_EQUAL(0, result.rows.size()); + BOOST_REQUIRE_EQUAL(0u, result.rows.size()); BOOST_REQUIRE_EQUAL("", result.more); } FC_LOG_AND_RETHROW() /// get_scope_test @@ -127,8 +120,8 @@ BOOST_FIXTURE_TEST_CASE( get_table_test, TESTER ) try { create_accounts(accs); produce_block(); - set_code( N(eosio.token), eosio_token_wast ); - set_abi( N(eosio.token), eosio_token_abi ); + set_code( N(eosio.token), contracts::eosio_token_wasm() ); + set_abi( N(eosio.token), contracts::eosio_token_abi().data() ); produce_blocks(1); // create currency @@ -201,7 +194,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_test, TESTER ) try { p.json = true; p.index_position = "primary"; eosio::chain_apis::read_only::get_table_rows_result result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(4, result.rows.size()); + BOOST_REQUIRE_EQUAL(4u, result.rows.size()); BOOST_REQUIRE_EQUAL(false, result.more); if (result.rows.size() >= 4) { BOOST_REQUIRE_EQUAL("9999.0000 AAA", result.rows[0]["balance"].as_string()); @@ -213,7 +206,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_test, TESTER ) try { // get table: reverse ordered p.reverse = true; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(4, result.rows.size()); + BOOST_REQUIRE_EQUAL(4u, result.rows.size()); BOOST_REQUIRE_EQUAL(false, result.more); if (result.rows.size() >= 4) { BOOST_REQUIRE_EQUAL("9999.0000 AAA", result.rows[3]["balance"].as_string()); @@ -226,7 +219,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_test, TESTER ) try { p.reverse = true; p.show_payer = true; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(4, result.rows.size()); + BOOST_REQUIRE_EQUAL(4u, result.rows.size()); BOOST_REQUIRE_EQUAL(false, result.more); if (result.rows.size() >= 4) { BOOST_REQUIRE_EQUAL("9999.0000 AAA", result.rows[3]["data"]["balance"].as_string()); @@ -245,7 +238,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_test, TESTER ) try { p.upper_bound = "CCC"; p.reverse = false; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(2, result.rows.size()); + BOOST_REQUIRE_EQUAL(2u, result.rows.size()); BOOST_REQUIRE_EQUAL(false, result.more); if (result.rows.size() >= 2) { BOOST_REQUIRE_EQUAL("8888.0000 BBB", result.rows[0]["balance"].as_string()); @@ -257,7 +250,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_test, TESTER ) try { p.upper_bound = "CCC"; p.reverse = true; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(2, result.rows.size()); + BOOST_REQUIRE_EQUAL(2u, result.rows.size()); BOOST_REQUIRE_EQUAL(false, result.more); if (result.rows.size() >= 2) { BOOST_REQUIRE_EQUAL("8888.0000 BBB", result.rows[1]["balance"].as_string()); @@ -269,7 +262,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_test, TESTER ) try { p.limit = 1; p.reverse = false; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(1, result.rows.size()); + BOOST_REQUIRE_EQUAL(1u, result.rows.size()); BOOST_REQUIRE_EQUAL(true, result.more); if (result.rows.size() >= 1) { BOOST_REQUIRE_EQUAL("9999.0000 AAA", result.rows[0]["balance"].as_string()); @@ -280,7 +273,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_test, TESTER ) try { p.limit = 1; p.reverse = true; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(1, result.rows.size()); + BOOST_REQUIRE_EQUAL(1u, result.rows.size()); BOOST_REQUIRE_EQUAL(true, result.more); if (result.rows.size() >= 1) { BOOST_REQUIRE_EQUAL("10000.0000 SYS", result.rows[0]["balance"].as_string()); @@ -292,7 +285,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_test, TESTER ) try { p.limit = 1; p.reverse = false; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(1, result.rows.size()); + BOOST_REQUIRE_EQUAL(1u, result.rows.size()); BOOST_REQUIRE_EQUAL(true, result.more); if (result.rows.size() >= 1) { BOOST_REQUIRE_EQUAL("8888.0000 BBB", result.rows[0]["balance"].as_string()); @@ -304,7 +297,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_test, TESTER ) try { p.limit = 1; p.reverse = true; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(1, result.rows.size()); + BOOST_REQUIRE_EQUAL(1u, result.rows.size()); BOOST_REQUIRE_EQUAL(true, result.more); if (result.rows.size() >= 1) { BOOST_REQUIRE_EQUAL("7777.0000 CCC", result.rows[0]["balance"].as_string()); @@ -322,8 +315,8 @@ BOOST_FIXTURE_TEST_CASE( get_table_by_seckey_test, TESTER ) try { create_accounts(accs); produce_block(); - set_code( N(eosio.token), eosio_token_wast ); - set_abi( N(eosio.token), eosio_token_abi ); + set_code( N(eosio.token), contracts::eosio_token_wasm() ); + set_abi( N(eosio.token), contracts::eosio_token_abi().data() ); produce_blocks(1); // create currency @@ -342,8 +335,13 @@ BOOST_FIXTURE_TEST_CASE( get_table_by_seckey_test, TESTER ) try { } produce_blocks(1); - set_code( config::system_account_name, eosio_system_wast ); - set_abi( config::system_account_name, eosio_system_abi ); + set_code( config::system_account_name, contracts::eosio_system_wasm() ); + set_abi( config::system_account_name, contracts::eosio_system_abi().data() ); + + base_tester::push_action(config::system_account_name, N(init), + config::system_account_name, mutable_variant_object() + ("version", 0) + ("core", CORE_SYM_STR)); // bidname auto bidname = [this]( const account_name& bidder, const account_name& newname, const asset& bid ) { @@ -370,7 +368,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_by_seckey_test, TESTER ) try { p.index_position = "secondary"; // ordered by high_bid p.key_type = "i64"; eosio::chain_apis::read_only::get_table_rows_result result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(4, result.rows.size()); + BOOST_REQUIRE_EQUAL(4u, result.rows.size()); BOOST_REQUIRE_EQUAL(false, result.more); if (result.rows.size() >= 4) { BOOST_REQUIRE_EQUAL("html", result.rows[0]["newname"].as_string()); @@ -394,7 +392,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_by_seckey_test, TESTER ) try { p.reverse = true; p.show_payer = true; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(4, result.rows.size()); + BOOST_REQUIRE_EQUAL(4u, result.rows.size()); BOOST_REQUIRE_EQUAL(false, result.more); if (result.rows.size() >= 4) { BOOST_REQUIRE_EQUAL("html", result.rows[3]["data"]["newname"].as_string()); @@ -423,7 +421,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_by_seckey_test, TESTER ) try { p.show_payer = false; p.limit = 1; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(1, result.rows.size()); + BOOST_REQUIRE_EQUAL(1u, result.rows.size()); BOOST_REQUIRE_EQUAL(true, result.more); if (result.rows.size() >= 1) { BOOST_REQUIRE_EQUAL("html", result.rows[0]["newname"].as_string()); @@ -436,7 +434,7 @@ BOOST_FIXTURE_TEST_CASE( get_table_by_seckey_test, TESTER ) try { p.show_payer = false; p.limit = 1; result = plugin.read_only::get_table_rows(p); - BOOST_REQUIRE_EQUAL(1, result.rows.size()); + BOOST_REQUIRE_EQUAL(1u, result.rows.size()); BOOST_REQUIRE_EQUAL(true, result.more); if (result.rows.size() >= 1) { BOOST_REQUIRE_EQUAL("com", result.rows[0]["newname"].as_string());