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

Update cli_test for better code coverage #2389

Merged
merged 3 commits into from
Mar 22, 2021
Merged
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
35 changes: 27 additions & 8 deletions tests/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,14 @@ BOOST_FIXTURE_TEST_CASE( uia_tests, cli_fixture )
fc::variant(result, FC_PACK_MAX_DEPTH), fc::variants());
BOOST_CHECK( output.find("BOBCOIN") != string::npos );
}

BOOST_CHECK_THROW( con.wallet_api_ptr->get_asset_name("BOBCOI"), fc::exception );
BOOST_CHECK_EQUAL( con.wallet_api_ptr->get_asset_name("BOBCOIN"), "BOBCOIN" );
BOOST_CHECK_EQUAL( con.wallet_api_ptr->get_asset_symbol("BOBCOIN"), "BOBCOIN" );

BOOST_CHECK_THROW( con.wallet_api_ptr->get_account_name("nath"), fc::exception );
BOOST_CHECK_EQUAL( con.wallet_api_ptr->get_account_name("nathan"), "nathan" );
BOOST_CHECK( con.wallet_api_ptr->get_account_id("nathan") == con.wallet_api_ptr->get_account("nathan").id );
}
BOOST_CHECK(generate_block(app1));

Expand All @@ -478,6 +486,8 @@ BOOST_FIXTURE_TEST_CASE( uia_tests, cli_fixture )

auto bobcoin = con.wallet_api_ptr->get_asset("BOBCOIN");

BOOST_CHECK( con.wallet_api_ptr->get_asset_id("BOBCOIN") == bobcoin.id );

bool balance_formatter_tested = false;
auto check_bobcoin_balance = [&](string account, int64_t amount) {
auto balances = con.wallet_api_ptr->list_account_balances( account );
Expand Down Expand Up @@ -534,7 +544,7 @@ BOOST_FIXTURE_TEST_CASE( uia_tests, cli_fixture )
auto test_pubkey = fc::json::to_string( test_bki.pub_key );
test_pubkey = test_pubkey.substr( 1, test_pubkey.size() - 2 );
idump( (test_pubkey) );
op.memo = con.wallet_api_ptr->sign_memo( test_pubkey, "nathan", "get back some coin" );
op.memo = con.wallet_api_ptr->sign_memo( "nathan", test_pubkey, "get back some coin" );
idump( (op.memo) );
con.wallet_api_ptr->add_operation_to_builder_transaction( handle, op );
con.wallet_api_ptr->set_fees_on_builder_transaction( handle, "1.3.0" );
Expand All @@ -543,7 +553,7 @@ BOOST_FIXTURE_TEST_CASE( uia_tests, cli_fixture )
auto memo = con.wallet_api_ptr->read_memo( *op.memo );
BOOST_CHECK_EQUAL( memo, "get back some coin" );

op.memo = con.wallet_api_ptr->sign_memo( "nathan", test_pubkey, "another test" );
op.memo = con.wallet_api_ptr->sign_memo( test_pubkey, "nathan", "another test" );
idump( (op.memo) );
memo = con.wallet_api_ptr->read_memo( *op.memo );
BOOST_CHECK_EQUAL( memo, "another test" );
Expand Down Expand Up @@ -896,13 +906,22 @@ BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture )
if( !is_hf2262_passed(app1) )
BOOST_CHECK(init1_last_votes > init1_start_votes);

auto check_account_last_history = [&]( string account, string keyword ) {
auto history = con.wallet_api_ptr->get_relative_account_history(account, 0, 1, 0);
BOOST_REQUIRE_GT( history.size(), 0 );
BOOST_CHECK( history[0].description.find( keyword ) != string::npos );
};
{
auto history = con.wallet_api_ptr->get_account_history_by_operations(
"jmjatlanta", {6}, 0, 1); // 6 - account_update_operation
BOOST_REQUIRE_GT( history.details.size(), 0 );
BOOST_CHECK( history.details[0].description.find( "Update Account 'jmjatlanta'" ) != string::npos );

check_account_last_history( "jmjatlanta", "Update Account 'jmjatlanta'" );
// Testing result formatter
auto formatters = con.wallet_api_ptr->get_result_formatters();
if( formatters.find("get_account_history_by_operations") != formatters.end() )
{
BOOST_TEST_MESSAGE("Testing formatter of get_account_history_by_operations");
string output = formatters["get_account_history_by_operations"](
fc::variant(history, FC_PACK_MAX_DEPTH), fc::variants());
BOOST_CHECK( output.find("Update Account 'jmjatlanta'") != string::npos );
}
}

} catch( fc::exception& e ) {
edump((e.to_detail_string()));
Expand Down