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

Refactor cli_test #1192 #1243

Merged
merged 11 commits into from
Aug 29, 2018
59 changes: 22 additions & 37 deletions tests/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,10 @@ BOOST_FIXTURE_TEST_CASE( upgrade_nathan_account, cli_fixture )
}
}

///////////////////////
// Start a server and connect using the same calls as the CLI
// Vote for two witnesses, and make sure they both stay there
// after a maintenance block
///////////////////////
BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture )
BOOST_FIXTURE_TEST_CASE( create_new_account, cli_fixture )
{
try
{
BOOST_TEST_MESSAGE("Cli Vote Test for 2 Witnesses");

INVOKE(upgrade_nathan_account);

// create a new account
Expand All @@ -338,6 +331,24 @@ BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture )
signed_transaction transfer_tx = con.wallet_api_ptr->transfer(
"nathan", "jmjatlanta", "10000", "1.3.0", "Here are some CORE token for your new account", true
);
} catch( fc::exception& e ) {
edump((e.to_detail_string()));
throw;
}
}

///////////////////////
// Start a server and connect using the same calls as the CLI
// Vote for two witnesses, and make sure they both stay there
// after a maintenance block
///////////////////////
BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture )
{
try
{
BOOST_TEST_MESSAGE("Cli Vote Test for 2 Witnesses");

INVOKE(create_new_account);

// get the details for init1
witness_object init1_obj = con.wallet_api_ptr->get_witness("init1");
Expand Down Expand Up @@ -384,23 +395,7 @@ BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture )
BOOST_FIXTURE_TEST_CASE( cli_set_voting_proxy, cli_fixture )
{
try {
INVOKE(upgrade_nathan_account);

// create a new account
graphene::wallet::brain_key_info bki = con.wallet_api_ptr->suggest_brain_key();
BOOST_CHECK(!bki.brain_priv_key.empty());
signed_transaction create_acct_tx = con.wallet_api_ptr->create_account_with_brain_key(
bki.brain_priv_key, "jmjatlanta", "nathan", "nathan", true
);
// save the private key for this new account in the wallet file
BOOST_CHECK(con.wallet_api_ptr->import_key("jmjatlanta", bki.wif_priv_key));
con.wallet_api_ptr->save_wallet_file(con.wallet_filename);

// attempt to give jmjatlanta some bitsahres
BOOST_TEST_MESSAGE("Transferring bitshares from Nathan to jmjatlanta");
signed_transaction transfer_tx = con.wallet_api_ptr->transfer(
"nathan", "jmjatlanta", "10000", "1.3.0", "Here are some CORE token for your new account", true
);
INVOKE(create_new_account);

// grab account for comparison
account_object prior_voting_account = con.wallet_api_ptr->get_account("jmjatlanta");
Expand Down Expand Up @@ -506,21 +501,11 @@ BOOST_FIXTURE_TEST_CASE( account_history_pagination, cli_fixture )
{
try
{
INVOKE(upgrade_nathan_account);

// create a new account
graphene::wallet::brain_key_info bki = con.wallet_api_ptr->suggest_brain_key();
BOOST_CHECK(!bki.brain_priv_key.empty());
signed_transaction create_acct_tx = con.wallet_api_ptr->create_account_with_brain_key(
bki.brain_priv_key, "jmjatlanta", "nathan", "nathan", true
);
// save the private key for this new account in the wallet file
BOOST_CHECK(con.wallet_api_ptr->import_key("jmjatlanta", bki.wif_priv_key));
con.wallet_api_ptr->save_wallet_file(con.wallet_filename);
INVOKE(create_new_account);

// attempt to give jmjatlanta some bitsahres
BOOST_TEST_MESSAGE("Transferring bitshares from Nathan to jmjatlanta");
for(int i = 1; i <= 200; i++)
for(int i = 1; i <= 199; i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? Something was broken?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing was broken, I've changed this because we have +1 transaction inside INVOKE create_new_account, and I've decided to decrease here history by -1 transaction. Should I change another way ? I can change BOOST_CHECK history transfers to 202 as an example here

BOOST_CHECK_EQUAL(201, history.size() );

what are your thoughts ? Thanks !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this because we have +1 transaction inside INVOKE create_new_account, and I've decided to decrease here history by -1 transaction.

Makes sense. Thanks.

{
signed_transaction transfer_tx = con.wallet_api_ptr->transfer("nathan", "jmjatlanta", std::to_string(i),
"1.3.0", "Here are some CORE token for your new account", true);
Expand Down