File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed
androidTest/java/com/duckduckgo/app/httpsupgrade
main/java/com/duckduckgo/app/httpsupgrade/api Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ class BloomFilterTest {
5959 }
6060 }
6161
62- val errorRate = falsePositives / testData.size
62+ val errorRate = falsePositives.toDouble() / testData.size.toDouble()
6363 assertEquals(0 , falseNegatives)
6464 assertEquals(bloomData.size, truePositives)
6565 assertTrue(trueNegatives <= testData.size - bloomData.size)
@@ -73,9 +73,9 @@ class BloomFilterTest {
7373 }
7474
7575 companion object {
76- const val FILTER_ELEMENT_COUNT = 1000
77- const val ADDITIONAL_TEST_DATA_ELEMENT_COUNT = 9000
76+ const val FILTER_ELEMENT_COUNT = 5000
77+ const val ADDITIONAL_TEST_DATA_ELEMENT_COUNT = 5000
7878 const val TARGET_ERROR_RATE = 0.001
79- const val ACCEPTABLE_ERROR_RATE = TARGET_ERROR_RATE * 1.1
79+ const val ACCEPTABLE_ERROR_RATE = TARGET_ERROR_RATE * 2
8080 }
8181}
Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ class HttpsBloomFilterFactoryImpl @Inject constructor(private val dao: HttpsBloo
4343 return null
4444 }
4545
46+ if (! binaryDataStore.verifyCheckSum(HTTPS_BINARY_FILE , specification.sha256)) {
47+ Timber .d(" Https update data failed checksum, clearing" )
48+ binaryDataStore.clearData(HTTPS_BINARY_FILE )
49+ return null
50+ }
51+
4652 val initialTimestamp = System .currentTimeMillis()
4753 Timber .d(" Found https data at $dataPath , building filter" )
4854 var bloomFilter = BloomFilter (dataPath, specification.totalEntries)
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ class HttpsUpgradeDataDownloader @Inject constructor(
7979
8080 val bytes = response.body()!! .bytes()
8181 if (! binaryDataStore.verifyCheckSum(bytes, specification.sha256)) {
82- throw IOException (" Https binary has incorrect checksum , throwing away file" )
82+ throw IOException (" Https binary has incorrect sha , throwing away file" )
8383 }
8484
8585 Timber .d(" Updating https bloom data store with new data" )
You can’t perform that action at this time.
0 commit comments