Compare commits
2 commits
master
...
hotfix/uni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f950eb3c25 | ||
|
|
3b83fb9330 |
3 changed files with 50 additions and 2 deletions
|
|
@ -35,6 +35,8 @@
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
#include "../common/genesis_file_util.hpp"
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE Test Application
|
#define BOOST_TEST_MODULE Test Application
|
||||||
#include <boost/test/included/unit_test.hpp>
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
|
||||||
|
|
@ -69,8 +71,11 @@ BOOST_AUTO_TEST_CASE( two_node_network )
|
||||||
cfg2.emplace("seed-node", boost::program_options::variable_value(vector<string>{"127.0.0.1:3939"}, false));
|
cfg2.emplace("seed-node", boost::program_options::variable_value(vector<string>{"127.0.0.1:3939"}, false));
|
||||||
app2.initialize(app2_dir.path(), cfg2);
|
app2.initialize(app2_dir.path(), cfg2);
|
||||||
|
|
||||||
|
cfg.emplace("genesis-json", boost::program_options::variable_value(create_genesis_file(app_dir), false));
|
||||||
|
cfg2.emplace("genesis-json", boost::program_options::variable_value(create_genesis_file(app2_dir), false));
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE( "Starting app1 and waiting 500 ms" );
|
BOOST_TEST_MESSAGE( "Starting app1 and waiting 500 ms" );
|
||||||
app1.startup();
|
app1.startup();
|
||||||
fc::usleep(fc::milliseconds(500));
|
fc::usleep(fc::milliseconds(500));
|
||||||
BOOST_TEST_MESSAGE( "Starting app2 and waiting 500 ms" );
|
BOOST_TEST_MESSAGE( "Starting app2 and waiting 500 ms" );
|
||||||
app2.startup();
|
app2.startup();
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
using namespace graphene::chain::test;
|
using namespace graphene::chain::test;
|
||||||
|
|
||||||
uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP = 1431700002;
|
uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP = 1431700000;
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
|
|
|
||||||
43
tests/common/genesis_file_util.hpp
Normal file
43
tests/common/genesis_file_util.hpp
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/////////
|
||||||
|
/// @brief forward declaration, using as a hack to generate a genesis.json file
|
||||||
|
/// for testing
|
||||||
|
/////////
|
||||||
|
namespace graphene { namespace app { namespace detail {
|
||||||
|
graphene::chain::genesis_state_type create_example_genesis();
|
||||||
|
} } } // graphene::app::detail
|
||||||
|
|
||||||
|
/////////
|
||||||
|
/// @brief create a genesis_json file
|
||||||
|
/// @param directory the directory to place the file "genesis.json"
|
||||||
|
/// @returns the full path to the file
|
||||||
|
////////
|
||||||
|
boost::filesystem::path create_genesis_file(fc::temp_directory& directory) {
|
||||||
|
boost::filesystem::path genesis_path = boost::filesystem::path{directory.path().generic_string()} / "genesis.json";
|
||||||
|
fc::path genesis_out = genesis_path;
|
||||||
|
graphene::chain::genesis_state_type genesis_state = graphene::app::detail::create_example_genesis();
|
||||||
|
|
||||||
|
/* Work In Progress: Place some accounts in the Genesis file so as to pre-make some accounts to play with
|
||||||
|
std::string test_prefix = "test";
|
||||||
|
// helper lambda
|
||||||
|
auto get_test_key = [&]( std::string prefix, uint32_t i ) -> public_key_type
|
||||||
|
{
|
||||||
|
return fc::ecc::private_key::regenerate( fc::sha256::hash( test_prefix + prefix + std::to_string(i) ) ).get_public_key();
|
||||||
|
};
|
||||||
|
// create 2 accounts to use
|
||||||
|
for (int i = 1; i <= 2; ++i )
|
||||||
|
{
|
||||||
|
genesis_state_type::initial_account_type dev_account(
|
||||||
|
test_prefix + std::to_string(i),
|
||||||
|
get_test_key("owner-", i),
|
||||||
|
get_test_key("active-", i),
|
||||||
|
false);
|
||||||
|
genesis_state.initial_accounts.push_back(dev_account);
|
||||||
|
// give her some coin
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
fc::json::save_to_file(genesis_state, genesis_out);
|
||||||
|
return genesis_path;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue