Auto merge of #4431 - oxarbitrage:issue4389, r=daira

Lock with cs_main inside gtests that request chain state

Fix https://github.com/zcash/zcash/issues/4389

- Used the lock from boost tests where `chainActive.Height()` is being called: https://github.com/zcash/zcash/blob/master/src/wallet/test/rpc_wallet_tests.cpp#L1323

- I found no other place in the gtests where `chainActive` is used apart from just the same tests `chainActive.Height()` is called. It seems chain state is only used when we fake mine transactions and these are all inside `test_wallet.cpp`.

I might be missing some other patterns to look at, please let me know if so.
This commit is contained in:
Homu 2020-04-15 11:03:48 +00:00
commit 344a2325ef
1 changed files with 8 additions and 8 deletions

View File

@ -185,7 +185,7 @@ TEST(WalletTests, FindUnspentSproutNotes) {
auto consensusParams = RegtestActivateSapling();
CWallet wallet;
LOCK(wallet.cs_wallet);
LOCK2(cs_main, wallet.cs_wallet);
auto sk = libzcash::SproutSpendingKey::random();
wallet.AddSproutSpendingKey(sk);
@ -643,7 +643,7 @@ TEST(WalletTests, GetConflictedSaplingNotes) {
auto consensusParams = RegtestActivateSapling();
TestWallet wallet;
LOCK(wallet.cs_wallet);
LOCK2(cs_main, wallet.cs_wallet);
// Generate Sapling address
auto sk = GetTestMasterSaplingSpendingKey();
@ -759,7 +759,7 @@ TEST(WalletTests, GetConflictedSaplingNotes) {
TEST(WalletTests, SproutNullifierIsSpent) {
CWallet wallet;
LOCK(wallet.cs_wallet);
LOCK2(cs_main, wallet.cs_wallet);
auto sk = libzcash::SproutSpendingKey::random();
wallet.AddSproutSpendingKey(sk);
@ -802,7 +802,7 @@ TEST(WalletTests, SaplingNullifierIsSpent) {
auto consensusParams = RegtestActivateSapling();
TestWallet wallet;
LOCK(wallet.cs_wallet);
LOCK2(cs_main, wallet.cs_wallet);
// Generate dummy Sapling address
auto sk = GetTestMasterSaplingSpendingKey();
@ -887,7 +887,7 @@ TEST(WalletTests, NavigateFromSaplingNullifierToNote) {
auto consensusParams = RegtestActivateSapling();
TestWallet wallet;
LOCK(wallet.cs_wallet);
LOCK2(cs_main, wallet.cs_wallet);
// Generate dummy Sapling address
auto sk = GetTestMasterSaplingSpendingKey();
@ -1010,7 +1010,7 @@ TEST(WalletTests, SpentSaplingNoteIsFromMe) {
auto consensusParams = RegtestActivateSapling();
TestWallet wallet;
LOCK(wallet.cs_wallet);
LOCK2(cs_main, wallet.cs_wallet);
// Generate Sapling address
auto sk = GetTestMasterSaplingSpendingKey();
@ -1801,7 +1801,7 @@ TEST(WalletTests, UpdatedSaplingNoteData) {
auto consensusParams = RegtestActivateSapling();
TestWallet wallet;
LOCK(wallet.cs_wallet);
LOCK2(cs_main, wallet.cs_wallet);
auto m = GetTestMasterSaplingSpendingKey();
@ -1944,7 +1944,7 @@ TEST(WalletTests, MarkAffectedSaplingTransactionsDirty) {
auto consensusParams = RegtestActivateSapling();
TestWallet wallet;
LOCK(wallet.cs_wallet);
LOCK2(cs_main, wallet.cs_wallet);
// Generate Sapling address
auto sk = GetTestMasterSaplingSpendingKey();