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 cli_tests websocket port binding issue #1178 #1187

Merged
merged 3 commits into from
Jul 28, 2018
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
32 changes: 16 additions & 16 deletions tests/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ int get_available_port()
socklen_t len = sizeof(sin);
if (getsockname(socket_fd, (struct sockaddr *)&sin, &len) == -1)
return -1;
return sin.sin_port;
close(socket_fd);
return ntohs(sin.sin_port);
}

///////////
Expand All @@ -97,7 +98,7 @@ std::shared_ptr<graphene::app::application> start_application(fc::temp_directory

app1->startup();
fc::usleep(fc::milliseconds(500));
return app1;
return app1;
}

///////////
Expand All @@ -108,13 +109,12 @@ std::shared_ptr<graphene::app::application> start_application(fc::temp_directory
bool generate_block(std::shared_ptr<graphene::app::application> app) {
try {
fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan")));
auto db = app->chain_database();
auto block_1 = db->generate_block(
db->get_slot_time(1),
db->get_scheduled_witness(1),
committee_key,
database::skip_nothing);
return true;
auto db = app->chain_database();
auto block_1 = db->generate_block( db->get_slot_time(1),
db->get_scheduled_witness(1),
committee_key,
database::skip_nothing );
return true;
} catch (exception &e) {
return false;
}
Expand Down Expand Up @@ -208,11 +208,11 @@ BOOST_AUTO_TEST_CASE( cli_connect )
try {
fc::temp_directory app_dir ( graphene::utilities::temp_directory_path() );

int server_port_number = 0;
app1 = start_application(app_dir, server_port_number);
int server_port_number = 0;
app1 = start_application(app_dir, server_port_number);

// connect to the server
client_connection con(app1, app_dir, server_port_number);
client_connection con(app1, app_dir, server_port_number);

} catch( fc::exception& e ) {
edump((e.to_detail_string()));
Expand Down Expand Up @@ -268,7 +268,7 @@ BOOST_AUTO_TEST_CASE( cli_vote_for_2_witnesses )
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));
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
Expand Down Expand Up @@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE( cli_set_voting_proxy )

fc::temp_directory app_dir( graphene::utilities::temp_directory_path() );

int server_port_number;
int server_port_number = 0;
app1 = start_application(app_dir, server_port_number);

// connect to the server
Expand Down Expand Up @@ -364,7 +364,7 @@ BOOST_AUTO_TEST_CASE( cli_set_voting_proxy )
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));
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
Expand Down Expand Up @@ -402,7 +402,7 @@ BOOST_AUTO_TEST_CASE( cli_confidential_tx_test )

// ** Start a Graphene chain and API server:
fc::temp_directory app_dir( graphene::utilities::temp_directory_path() );
int server_port_number;
int server_port_number = 0;
app1 = start_application(app_dir, server_port_number);
unsigned int head_block = 0;

Expand Down