Fix failing son_cli tests
This commit is contained in:
parent
d428aad312
commit
5cf5b57ace
4 changed files with 54 additions and 43 deletions
|
|
@ -201,9 +201,39 @@ cli_fixture::~cli_fixture()
|
|||
#endif
|
||||
}
|
||||
|
||||
void cli_fixture::generate_blocks(fc::time_point_sec timestamp, bool miss_intermediate_blocks, uint32_t skip)
|
||||
{
|
||||
auto db = app1->chain_database();
|
||||
|
||||
if( miss_intermediate_blocks )
|
||||
{
|
||||
generate_block(skip);
|
||||
auto slots_to_miss = db->get_slot_at_time(timestamp);
|
||||
if( slots_to_miss <= 1 )
|
||||
return;
|
||||
--slots_to_miss;
|
||||
generate_block(skip, fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))), slots_to_miss);
|
||||
return;
|
||||
}
|
||||
while( db->head_block_time() < timestamp )
|
||||
generate_block(skip);
|
||||
}
|
||||
|
||||
signed_block cli_fixture::generate_block(uint32_t skip, const fc::ecc::private_key& key, int miss_blocks)
|
||||
{
|
||||
skip |= database::skip_undo_history_check;
|
||||
// skip == ~0 will skip checks specified in database::validation_steps
|
||||
auto db = app1->chain_database();
|
||||
auto block = db->generate_block(db->get_slot_time(miss_blocks + 1),
|
||||
db->get_scheduled_witness(miss_blocks + 1),
|
||||
key, skip);
|
||||
db->clear_pending();
|
||||
return block;
|
||||
}
|
||||
|
||||
bool cli_fixture::generate_maintenance_block() {
|
||||
try {
|
||||
fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan")));
|
||||
fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
|
||||
uint32_t skip = ~database::skip_fork_db;
|
||||
auto db = app1->chain_database();
|
||||
auto maint_time = db->get_dynamic_global_properties().next_maintenance_time;
|
||||
|
|
@ -219,27 +249,6 @@ bool cli_fixture::generate_maintenance_block() {
|
|||
}
|
||||
}
|
||||
|
||||
bool cli_fixture::generate_block()
|
||||
{
|
||||
graphene::chain::signed_block returned_block;
|
||||
return generate_block(returned_block);
|
||||
}
|
||||
|
||||
bool cli_fixture::generate_block(graphene::chain::signed_block& returned_block)
|
||||
{
|
||||
try {
|
||||
fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan")));
|
||||
auto db = app1->chain_database();
|
||||
returned_block = 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;
|
||||
}
|
||||
}
|
||||
|
||||
void cli_fixture::init_nathan()
|
||||
{
|
||||
try
|
||||
|
|
@ -254,7 +263,7 @@ void cli_fixture::init_nathan()
|
|||
import_txs = con.wallet_api_ptr->import_balance("nathan", nathan_keys, true);
|
||||
nathan_acct_before_upgrade = con.wallet_api_ptr->get_account("nathan");
|
||||
|
||||
BOOST_CHECK(generate_block());
|
||||
generate_block();
|
||||
|
||||
// upgrade nathan
|
||||
BOOST_TEST_MESSAGE("Upgrading Nathan to LTM");
|
||||
|
|
|
|||
|
|
@ -60,13 +60,12 @@ struct cli_fixture
|
|||
cli_fixture();
|
||||
~cli_fixture();
|
||||
|
||||
///////////
|
||||
/// Send a block to the db
|
||||
/// @param returned_block the signed block
|
||||
/// @returns true on success
|
||||
///////////
|
||||
bool generate_block(graphene::chain::signed_block& returned_block);
|
||||
bool generate_block();
|
||||
signed_block generate_block(uint32_t skip = ~0,
|
||||
const fc::ecc::private_key& key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))),
|
||||
int miss_blocks = 0);
|
||||
|
||||
void generate_blocks(fc::time_point_sec timestamp, bool miss_intermediate_blocks = true, uint32_t skip = ~0);
|
||||
|
||||
///////////
|
||||
/// @brief Skip intermediate blocks, and generate a maintenance block
|
||||
/// @returns true on success
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE( create_new_account )
|
|||
BOOST_CHECK(con.wallet_api_ptr->import_key("jmjatlanta", bki.wif_priv_key));
|
||||
con.wallet_api_ptr->save_wallet_file(con.wallet_filename);
|
||||
|
||||
BOOST_CHECK(generate_block());
|
||||
generate_block();
|
||||
fc::usleep( fc::seconds(1) );
|
||||
|
||||
// attempt to give jmjatlanta some peerplays
|
||||
|
|
@ -112,7 +112,7 @@ BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture )
|
|||
signed_transaction vote_witness1_tx = con.wallet_api_ptr->vote_for_witness("jmjatlanta", "init1", true, true);
|
||||
|
||||
// generate a block to get things started
|
||||
BOOST_CHECK(generate_block());
|
||||
generate_block();
|
||||
// wait for a maintenance interval
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE( account_history_pagination )
|
|||
"1.3.0", "Here are some CORE token for your new account", true);
|
||||
}
|
||||
|
||||
BOOST_CHECK(generate_block());
|
||||
generate_block();
|
||||
|
||||
// now get account history and make sure everything is there (and no duplicates)
|
||||
std::vector<graphene::wallet::operation_detail> history = con.wallet_api_ptr->get_account_history("jmjatlanta", 300);
|
||||
|
|
@ -489,7 +489,7 @@ BOOST_FIXTURE_TEST_CASE( saving_keys_wallet_test, cli_fixture )
|
|||
graphene::wallet::plain_keys pk = decrypt_keys( "supersecret", wallet.cipher_keys );
|
||||
BOOST_CHECK( pk.keys.size() == 1 ); // nathan key
|
||||
|
||||
BOOST_CHECK( generate_block() );
|
||||
generate_block();
|
||||
fc::usleep( fc::seconds(1) );
|
||||
|
||||
wallet = fc::json::from_file( path ).as<graphene::wallet::wallet_data>( 2 * GRAPHENE_MAX_NESTED_OBJECTS );
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <graphene/chain/config.hpp>
|
||||
#include <graphene/chain/hardfork.hpp>
|
||||
|
||||
class son_test_helper
|
||||
{
|
||||
|
|
@ -38,6 +39,8 @@ public:
|
|||
fixture_(fixture)
|
||||
{
|
||||
fixture_.init_nathan();
|
||||
fixture_.generate_blocks(HARDFORK_SON_TIME);
|
||||
fixture_.generate_block();
|
||||
}
|
||||
|
||||
void create_son(const std::string& account_name, const std::string& son_url,
|
||||
|
|
@ -67,7 +70,7 @@ public:
|
|||
"nathan", account_name, "65000", "1.3.0", "Here are some CORE token for your new account", true
|
||||
);
|
||||
|
||||
BOOST_CHECK(fixture_.generate_block());
|
||||
fixture_.generate_block();
|
||||
|
||||
// upgrade son account
|
||||
BOOST_TEST_MESSAGE("Upgrading son account to LTM");
|
||||
|
|
@ -77,16 +80,16 @@ public:
|
|||
// verify that the upgrade was successful
|
||||
BOOST_CHECK(son_account.is_lifetime_member());
|
||||
|
||||
BOOST_CHECK(fixture_.generate_block());
|
||||
fixture_.generate_block();
|
||||
|
||||
// create deposit vesting
|
||||
fixture_.con.wallet_api_ptr->create_vesting_balance(account_name,
|
||||
"50", "1.3.0", vesting_balance_type::son, true);
|
||||
BOOST_CHECK(fixture_.generate_block());
|
||||
fixture_.generate_block();
|
||||
|
||||
// create pay_vb vesting
|
||||
fixture_.con.wallet_api_ptr->create_vesting_balance(account_name, "1", "1.3.0", vesting_balance_type::normal, true);
|
||||
BOOST_CHECK(fixture_.generate_block());
|
||||
fixture_.generate_block();
|
||||
|
||||
// check deposits are here
|
||||
auto deposits = fixture_.con.wallet_api_ptr->get_vesting_balances(account_name);
|
||||
|
|
@ -424,7 +427,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
con.wallet_api_ptr->create_vesting_balance("nathan", "1000", "1.3.0", vesting_balance_type::gpos, true);
|
||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||
rejected, 2, true);
|
||||
BOOST_CHECK(generate_block());
|
||||
generate_block();
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
// Verify the votes
|
||||
|
|
@ -464,7 +467,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
rejected.push_back("son1accnt");
|
||||
BOOST_CHECK_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||
rejected, 1, true), fc::exception);
|
||||
BOOST_CHECK(generate_block());
|
||||
generate_block();
|
||||
|
||||
// Verify the votes
|
||||
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||
|
|
@ -678,7 +681,7 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
|||
|
||||
// put SON in maintenance mode
|
||||
con.wallet_api_ptr->request_son_maintenance(name, true);
|
||||
BOOST_CHECK(generate_block());
|
||||
generate_block();
|
||||
|
||||
// check SON is in request_maintenance
|
||||
son_obj = con.wallet_api_ptr->get_son(name);
|
||||
|
|
@ -686,7 +689,7 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
|||
|
||||
// restore SON activity
|
||||
con.wallet_api_ptr->cancel_request_son_maintenance(name, true);
|
||||
BOOST_CHECK(generate_block());
|
||||
generate_block();
|
||||
|
||||
// check SON is active
|
||||
son_obj = con.wallet_api_ptr->get_son(name);
|
||||
|
|
@ -694,7 +697,7 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
|||
|
||||
// put SON in maintenance mode
|
||||
con.wallet_api_ptr->request_son_maintenance(name, true);
|
||||
BOOST_CHECK(generate_block());
|
||||
generate_block();
|
||||
|
||||
// check SON is in request_maintenance
|
||||
son_obj = con.wallet_api_ptr->get_son(name);
|
||||
|
|
|
|||
Loading…
Reference in a new issue