From d711a7c5297f793217427acf9966d7ef9d4e84d8 Mon Sep 17 00:00:00 2001 From: sasha Date: Thu, 31 Mar 2022 11:12:57 -0700 Subject: [PATCH] Fix test_wallet_zkeys failures by increasing diversifier search offset 1 chance in 2^-128 is unobservable, whereas 1 chance in 1024 happens often. --- src/wallet/gtest/test_wallet_zkeys.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wallet/gtest/test_wallet_zkeys.cpp b/src/wallet/gtest/test_wallet_zkeys.cpp index a51ec83f9..5a2ce53da 100644 --- a/src/wallet/gtest/test_wallet_zkeys.cpp +++ b/src/wallet/gtest/test_wallet_zkeys.cpp @@ -67,9 +67,9 @@ TEST(WalletZkeysTest, StoreAndLoadSaplingZkeys) { EXPECT_EQ(1, addrs.count(address)); // Find a diversified address that does not use the same diversifier as the default address. - // By starting our search at `10` we ensure there's no more than a 2^-10 chance that we + // By starting our search at `128` we ensure there's no more than a 2^-128 chance that we // collide with the default diversifier. - libzcash::diversifier_index_t j(10); + libzcash::diversifier_index_t j(128); auto dpa = sk.ToXFVK().FindAddress(j).first; // add the default address @@ -461,11 +461,12 @@ TEST(WalletZkeysTest, WriteCryptedSaplingZkeyDirectToDb) { wallet.GetSaplingPaymentAddresses(addrs); ASSERT_EQ(1, addrs.size()); - // Generate a diversified address different to the default - // If we can't get an early diversified address, we are very unlucky + // Find a diversified address that does not use the same diversifier as the default address. + // By starting our search at `128` we ensure there's no more than a 2^-128 chance that we + // collide with the default diversifier. libzcash::SaplingExtendedSpendingKey extsk; EXPECT_TRUE(wallet.GetSaplingExtendedSpendingKey(address, extsk)); - libzcash::diversifier_index_t j(10); + libzcash::diversifier_index_t j(128); auto dpa = extsk.ToXFVK().FindAddress(j).first; // Add diversified address to the wallet