Skip to content

Commit

Permalink
WalletTest: reduce false positive rate in marriedKeychainBloomFilter()
Browse files Browse the repository at this point in the history
This will hopefully reduce spurious test failures.

This is a backport of 9081d0f.
  • Loading branch information
schildbach committed Jun 24, 2024
1 parent b176f3a commit 300b6aa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/src/test/java/org/bitcoinj/wallet/WalletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1756,15 +1756,16 @@ public void marriedKeychainBloomFilter() throws Exception {
createMarriedWallet(2, 2);
Address address = wallet.currentReceiveAddress();

assertTrue(wallet.getBloomFilter(0.001).contains(address.getHash()));
double falsePositiveRate = 0.00001;
assertTrue(wallet.getBloomFilter(falsePositiveRate).contains(address.getHash()));

Transaction t1 = createFakeTx(UNITTEST, CENT, address);
TransactionOutPoint outPoint = new TransactionOutPoint(UNITTEST, 0, t1);

assertFalse(wallet.getBloomFilter(0.001).contains(outPoint.unsafeBitcoinSerialize()));
assertFalse(wallet.getBloomFilter(falsePositiveRate).contains(outPoint.unsafeBitcoinSerialize()));

sendMoneyToWallet(BlockChain.NewBlockType.BEST_CHAIN, t1);
assertTrue(wallet.getBloomFilter(0.001).contains(outPoint.unsafeBitcoinSerialize()));
assertTrue(wallet.getBloomFilter(falsePositiveRate).contains(outPoint.unsafeBitcoinSerialize()));
}

@Test
Expand Down

0 comments on commit 300b6aa

Please sign in to comment.