Skip to content

Commit

Permalink
Merge pull request #1626 from bitshares/1303-cli-test-issues
Browse files Browse the repository at this point in the history
Add sleep to cli_test
  • Loading branch information
abitmore authored Mar 4, 2019
2 parents fe510a2 + 53cf53e commit 458beae
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions tests/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ std::shared_ptr<graphene::app::application> start_application(fc::temp_directory
#endif
server_port_number = get_available_port();
cfg.emplace(
"rpc-endpoint",
"rpc-endpoint",
boost::program_options::variable_value(string("127.0.0.1:" + std::to_string(server_port_number)), false)
);
cfg.emplace("genesis-json", boost::program_options::variable_value(create_genesis_file(app_dir), false));
Expand Down Expand Up @@ -191,8 +191,8 @@ class client_connection
// constructor
/////////
client_connection(
std::shared_ptr<graphene::app::application> app,
const fc::temp_directory& data_dir,
std::shared_ptr<graphene::app::application> app,
const fc::temp_directory& data_dir,
const int server_port_number
)
{
Expand Down Expand Up @@ -223,6 +223,11 @@ class client_connection
}));
(void)(closed_connection);
}
~client_connection()
{
// wait for everything to finish up
fc::usleep(fc::milliseconds(500));
}
public:
fc::http::websocket_client websocket_client;
graphene::wallet::wallet_data wallet_data;
Expand All @@ -241,16 +246,26 @@ class client_connection

struct cli_fixture
{
class dummy
{
public:
~dummy()
{
// wait for everything to finish up
fc::usleep(fc::milliseconds(500));
}
};
dummy dmy;
int server_port_number;
fc::temp_directory app_dir;
std::shared_ptr<graphene::app::application> app1;
client_connection con;
std::vector<std::string> nathan_keys;

cli_fixture() :
cli_fixture() :
server_port_number(0),
app_dir( graphene::utilities::temp_directory_path() ),
app1( start_application(app_dir, server_port_number) ),
app1( start_application(app_dir, server_port_number) ),
con( app1, app_dir, server_port_number ),
nathan_keys( {"5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"} )
{
Expand All @@ -259,7 +274,7 @@ struct cli_fixture
using namespace graphene::chain;
using namespace graphene::app;

try
try
{
BOOST_TEST_MESSAGE("Setting wallet password");
con.wallet_api_ptr->set_password("supersecret");
Expand All @@ -281,7 +296,7 @@ struct cli_fixture

// wait for everything to finish up
fc::usleep(fc::seconds(1));

app1->shutdown();
#ifdef _WIN32
sockQuit();
Expand Down Expand Up @@ -331,10 +346,10 @@ BOOST_FIXTURE_TEST_CASE( upgrade_nathan_account, cli_fixture )
nathan_acct_after_upgrade = con.wallet_api_ptr->get_account("nathan");

// verify that the upgrade was successful
BOOST_CHECK_PREDICATE(
std::not_equal_to<uint32_t>(),
BOOST_CHECK_PREDICATE(
std::not_equal_to<uint32_t>(),
(nathan_acct_before_upgrade.membership_expiration_date.sec_since_epoch())
(nathan_acct_after_upgrade.membership_expiration_date.sec_since_epoch())
(nathan_acct_after_upgrade.membership_expiration_date.sec_since_epoch())
);
BOOST_CHECK(nathan_acct_after_upgrade.is_lifetime_member());
} catch( fc::exception& e ) {
Expand Down Expand Up @@ -458,7 +473,7 @@ BOOST_FIXTURE_TEST_CASE( cli_confidential_tx_test, cli_fixture )

unsigned int head_block = 0;
auto & W = *con.wallet_api_ptr; // Wallet alias

BOOST_TEST_MESSAGE("Creating blind accounts");
graphene::wallet::brain_key_info bki_nathan = W.suggest_brain_key();
graphene::wallet::brain_key_info bki_alice = W.suggest_brain_key();
Expand Down

0 comments on commit 458beae

Please sign in to comment.