Add test for wallet password race
When the wallet password is modified it currently is a non-atomic operation. While we consider how to change the design to mitigate the condition, here's a test case that reproduces the problem.
This commit is contained in:
parent
48fb5fa5c8
commit
411f994355
1 changed files with 24 additions and 0 deletions
|
@ -882,3 +882,27 @@ TEST (wallet, send_race)
|
|||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
}
|
||||
|
||||
TEST (wallet, password_race)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::thread_runner runner (system.service, system.nodes[0]->config.io_threads);
|
||||
auto wallet = system.wallet (0);
|
||||
system.nodes[0]->background ([&wallet]() {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
rai::transaction transaction (wallet->store.environment, nullptr, true);
|
||||
wallet->store.rekey (transaction, std::to_string(i));
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < 100; i++) {
|
||||
rai::transaction transaction (wallet->store.environment, nullptr, false);
|
||||
// Password should always be valid, the rekey operation should be atomic.
|
||||
bool ok = wallet->store.valid_password (transaction);
|
||||
EXPECT_TRUE (ok);
|
||||
if (!ok) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
system.stop ();
|
||||
runner.join ();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue