Fix several core_test issues (#959)

* Fix test rpc.version

* Sometimes election can start before block_processor commit

* Attempt to process confirmed block if it's not in ledger yet

* Fix QT block creation tests

* Enable tests upgrade_v1_v2 & send_single_many_peers

* Increase iterations for fork_pre_confirm

* Fix -Wconversion-null warnings

* Disable confirm_if_quorum for already confirmed election

* Fix error with 0 key in wallet store

* Redo "Disable confirm_if_quorum"

* Increase possible synchronizing time for QT wallet
This commit is contained in:
SergiySW 2018-07-12 21:49:30 +03:00 committed by Lee Bousfield
commit 823e2d78e4
6 changed files with 37 additions and 27 deletions

View file

@ -125,7 +125,7 @@ TEST (node, send_single_observing_peer)
}
}
TEST (node, DISABLED_send_single_many_peers)
TEST (node, send_single_many_peers)
{
rai::system system (24000, 10);
rai::keypair key2;
@ -472,7 +472,7 @@ TEST (logging, serialization)
ASSERT_EQ (logging1.max_size, logging2.max_size);
}
TEST (logging, DISABLED_upgrade_v1_v2)
TEST (logging, upgrade_v1_v2)
{
auto path1 (rai::unique_path ());
auto path2 (rai::unique_path ());
@ -486,8 +486,8 @@ TEST (logging, DISABLED_upgrade_v1_v2)
tree.erase ("vote");
bool upgraded (false);
ASSERT_FALSE (logging2.deserialize_json (upgraded, tree));
ASSERT_EQ ("2", tree.get<std::string> ("version"));
ASSERT_EQ (false, tree.get<bool> ("vote"));
ASSERT_LE (2, tree.get<int> ("version"));
ASSERT_FALSE (tree.get<bool> ("vote"));
}
TEST (node, price)
@ -1061,7 +1061,7 @@ TEST (node, fork_pre_confirm)
{
system.poll ();
++iterations;
ASSERT_LT (iterations, 400);
ASSERT_LT (iterations, 600);
}
auto block1 (system.wallet (0)->send_action (rai::test_genesis_key.pub, key2.pub, rai::genesis_amount / 3));
ASSERT_NE (nullptr, block1);
@ -1069,7 +1069,7 @@ TEST (node, fork_pre_confirm)
{
system.poll ();
++iterations;
ASSERT_LT (iterations, 400);
ASSERT_LT (iterations, 600);
}
rai::keypair key3;
rai::keypair key4;
@ -1360,7 +1360,7 @@ TEST (node, DISABLED_unconfirmed_send)
ASSERT_GT (200, iterations0);
}
auto latest (node1.latest (key0.pub));
rai::send_block send2 (latest, rai::genesis_account, rai::Mxrb_ratio, key0.prv, key0.pub, node0.work_generate_blocking (latest));
rai::state_block send2 (key0.pub, latest, rai::genesis_account, rai::Mxrb_ratio, rai::genesis_account, key0.prv, key0.pub, node0.work_generate_blocking (latest));
{
rai::transaction transaction (node1.store.environment, nullptr, true);
ASSERT_EQ (rai::process_result::progress, node1.ledger.process (transaction, send2).code);

View file

@ -1520,7 +1520,7 @@ TEST (rpc, version)
ASSERT_EQ (200, response1.status);
ASSERT_EQ ("1", response1.json.get<std::string> ("rpc_version"));
ASSERT_EQ (200, response1.status);
ASSERT_EQ ("10", response1.json.get<std::string> ("store_version"));
ASSERT_EQ ("11", response1.json.get<std::string> ("store_version"));
ASSERT_EQ (boost::str (boost::format ("RaiBlocks %1%.%2%") % RAIBLOCKS_VERSION_MAJOR % RAIBLOCKS_VERSION_MINOR), response1.json.get<std::string> ("node_vendor"));
auto headers (response1.resp.base ());
auto allowed_origin (headers.at ("Access-Control-Allow-Origin"));

View file

@ -657,9 +657,9 @@ TEST (wallet, insert_locked)
rai::system system (24000, 1);
auto wallet (system.wallet (0));
wallet->store.rekey (rai::transaction (wallet->store.environment, nullptr, true), "1");
ASSERT_EQ (true, wallet->valid_password ());
ASSERT_TRUE (wallet->valid_password ());
wallet->enter_password ("");
ASSERT_EQ (false, wallet->valid_password ());
ASSERT_FALSE (wallet->valid_password ());
ASSERT_TRUE (wallet->insert_adhoc (rai::keypair ().prv).is_zero ());
}
@ -668,11 +668,11 @@ TEST (wallet, version_1_2_upgrade)
rai::system system (24000, 1);
auto wallet (system.wallet (0));
wallet->enter_initial_password ();
ASSERT_EQ (true, wallet->valid_password ());
ASSERT_TRUE (wallet->valid_password ());
rai::keypair key;
wallet->store.rekey (rai::transaction (wallet->store.environment, nullptr, true), "1");
wallet->enter_password ("");
ASSERT_EQ (false, wallet->valid_password ());
ASSERT_FALSE (wallet->valid_password ());
{
rai::transaction transaction (wallet->store.environment, nullptr, true);
rai::raw_key password_l;
@ -687,7 +687,7 @@ TEST (wallet, version_1_2_upgrade)
}
wallet->enter_password ("1");
ASSERT_EQ (true, wallet->valid_password ());
ASSERT_TRUE (wallet->valid_password ());
ASSERT_EQ (2, wallet->store.version (rai::transaction (wallet->store.environment, nullptr, false)));
rai::raw_key prv;
ASSERT_FALSE (wallet->store.fetch (rai::transaction (wallet->store.environment, nullptr, false), key.pub, prv));
@ -706,7 +706,7 @@ TEST (wallet, version_1_2_upgrade)
wallet->store.version_put (transaction, 1);
}
wallet->enter_password ("1");
ASSERT_EQ (true, wallet->valid_password ());
ASSERT_TRUE (wallet->valid_password ());
ASSERT_EQ (2, wallet->store.version (rai::transaction (wallet->store.environment, nullptr, false)));
rai::raw_key prv2;
ASSERT_FALSE (wallet->store.fetch (rai::transaction (wallet->store.environment, nullptr, false), key.pub, prv2));
@ -797,9 +797,9 @@ TEST (wallet, insert_deterministic_locked)
rai::system system (24000, 1);
auto wallet (system.wallet (0));
wallet->store.rekey (rai::transaction (wallet->store.environment, nullptr, true), "1");
ASSERT_EQ (true, wallet->valid_password ());
ASSERT_TRUE (wallet->valid_password ());
wallet->enter_password ("");
ASSERT_EQ (false, wallet->valid_password ());
ASSERT_FALSE (wallet->valid_password ());
ASSERT_TRUE (wallet->deterministic_insert ().is_zero ());
}

View file

@ -2736,10 +2736,18 @@ public:
void rai::node::process_confirmed (std::shared_ptr<rai::block> block_a)
{
rai::transaction transaction (store.environment, nullptr, false);
auto hash (block_a->hash ());
if (store.block_exists (transaction, hash))
bool exists (ledger.block_exists (hash));
// Attempt to process confirmed block if it's not in ledger yet
if (!exists)
{
rai::transaction transaction (store.environment, nullptr, true);
block_processor.process_receive_one (transaction, block_a);
exists = store.block_exists (transaction, hash);
}
if (exists)
{
rai::transaction transaction (store.environment, nullptr, false);
confirmed_visitor visitor (transaction, *this, block_a, hash);
block_a->visit (visitor);
auto account (ledger.account (transaction, hash));
@ -2748,7 +2756,6 @@ void rai::node::process_confirmed (std::shared_ptr<rai::block> block_a)
rai::account pending_account (0);
if (auto state = dynamic_cast<rai::state_block *> (block_a.get ()))
{
rai::transaction transaction (store.environment, nullptr, false);
is_state_send = ledger.is_send (transaction, *state);
pending_account = state->hashables.link;
}
@ -3508,7 +3515,10 @@ bool rai::election::vote (std::shared_ptr<rai::vote> vote_a)
last_votes[vote_a->account] = { std::chrono::steady_clock::now (), vote_a->sequence, vote_a->block->hash () };
node.network.republish_vote (vote_a);
votes.vote (vote_a);
confirm_if_quorum (transaction);
if (!confirmed)
{
confirm_if_quorum (transaction);
}
}
}
return replay;
@ -3525,7 +3535,7 @@ void rai::active_transactions::announce_votes ()
for (auto i (roots.begin ()), n (roots.end ()); i != n; ++i)
{
auto election_l (i->election);
if (!node.store.root_exists (transaction, election_l->votes.id) || (election_l->confirmed && i->announcements >= announcement_min - 1))
if ((!node.store.root_exists (transaction, election_l->votes.id) || election_l->confirmed) && i->announcements >= announcement_min - 1)
{
if (election_l->confirmed)
{

View file

@ -534,7 +534,7 @@ bool rai::wallet_store::fetch (MDB_txn * transaction_a, rai::public_key const &
bool rai::wallet_store::exists (MDB_txn * transaction_a, rai::public_key const & pub)
{
return find (transaction_a, pub) != end ();
return !pub.is_zero () && find (transaction_a, pub) != end ();
}
void rai::wallet_store::serialize_json (MDB_txn * transaction_a, std::string & string_a)

View file

@ -372,7 +372,7 @@ TEST (wallet, create_send)
std::stringstream istream (json);
boost::property_tree::read_json (istream, tree1);
bool error;
rai::send_block send (error, tree1);
rai::state_block send (error, tree1);
ASSERT_FALSE (error);
ASSERT_EQ (rai::process_result::progress, system.nodes[0]->process (send).code);
ASSERT_EQ (rai::process_result::old, system.nodes[0]->process (send).code);
@ -406,7 +406,7 @@ TEST (wallet, create_open_receive)
std::stringstream istream1 (json1);
boost::property_tree::read_json (istream1, tree1);
bool error;
rai::open_block open (error, tree1);
rai::state_block open (error, tree1);
ASSERT_FALSE (error);
ASSERT_EQ (rai::process_result::progress, system.nodes[0]->process (open).code);
ASSERT_EQ (rai::process_result::old, system.nodes[0]->process (open).code);
@ -421,7 +421,7 @@ TEST (wallet, create_open_receive)
std::stringstream istream2 (json2);
boost::property_tree::read_json (istream2, tree2);
bool error2;
rai::receive_block receive (error2, tree2);
rai::state_block receive (error2, tree2);
ASSERT_FALSE (error2);
ASSERT_EQ (rai::process_result::progress, system.nodes[0]->process (receive).code);
ASSERT_EQ (rai::process_result::old, system.nodes[0]->process (receive).code);
@ -449,7 +449,7 @@ TEST (wallet, create_change)
std::stringstream istream (json);
boost::property_tree::read_json (istream, tree1);
bool error (false);
rai::change_block change (error, tree1);
rai::state_block change (error, tree1);
ASSERT_FALSE (error);
ASSERT_EQ (rai::process_result::progress, system.nodes[0]->process (change).code);
ASSERT_EQ (rai::process_result::old, system.nodes[0]->process (change).code);
@ -795,6 +795,6 @@ TEST (wallet, synchronizing)
system1.poll ();
test_application->processEvents ();
++iterations1;
ASSERT_GT (200, iterations1);
ASSERT_GT (500, iterations1);
}
}