Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: test build bug and docker build failed #149

Merged
merged 1 commit into from
Mar 12, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions tests/chain_plugin_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#include <eosio/chain/wast_to_wasm.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>

#include <asserter/asserter.wast.hpp>
#include <asserter/asserter.abi.hpp>
#include <contracts.hpp>

#include <fc/io/fstream.hpp>

Expand Down Expand Up @@ -42,26 +41,26 @@ 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<abi_serializer> {
auto resolver = [&,this]( const account_name& name ) -> fc::optional<abi_serializer> {
try {
const auto& accnt = this->control->db().get<account_object,by_name>( name );
abi_def abi;
if (abi_serializer::to_abi(accnt.abi, abi)) {
return abi_serializer(abi, abi_serializer_max_time);
}
return optional<abi_serializer>();
return fc::optional<abi_serializer>();
} FC_RETHROW_EXCEPTIONS(error, "resolver failed at chain_plugin_tests::abi_invalid_type");
};

// abi should be resolved
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")
Expand Down Expand Up @@ -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");
Expand Down
68 changes: 33 additions & 35 deletions tests/get_table_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@
#include <eosio/chain/wast_to_wasm.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>

#include <asserter/asserter.wast.hpp>
#include <asserter/asserter.abi.hpp>

#include <eosio.token/eosio.token.wast.hpp>
#include <eosio.token/eosio.token.abi.hpp>

#include <eosio.system/eosio.system.wast.hpp>
#include <eosio.system/eosio.system.abi.hpp>
#include <contracts.hpp>

#include <fc/io/fstream.hpp>

Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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
Expand All @@ -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 ) {
Expand All @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down