Skip to content
Snippets Groups Projects
Commit 0979db10 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

Make the Share generator generate smaller shares more often

Instead of distributing the range of the size of most fields of the share
linearly over some range, use an exponential distribution so that values in
the result are exponentially more likely to be small.  Large values are still
possible, just less likely.

Since most encoding/decoding bugs are possible with even the smallest allowed
amount of data this seems like a reasonable tradeoff for better test suite
performance.

Before the change "Share round-trips through put / get" takes 165 seconds on
my laptop.  After the change it takes 26 seconds.
parent 1de296b5
Branches
No related tags found
1 merge request!35Make the Share generator generate smaller shares more often
Pipeline #4390 passed
......@@ -64,8 +64,8 @@ shares = do
-- memory (and even if they didn't, they would be constrained by disk
-- space and speed) and maxBound :: Int64 is a lot of bytes...
let maxSize = 65536
shareBlockSize <- Gen.integral (Range.linear 1 maxSize)
numBlocks <- Gen.integral (Range.linear 1 32)
shareBlockSize <- Gen.integral (Range.exponential 1 maxSize)
numBlocks <- Gen.integral (Range.exponential 1 32)
-- We don't make shareDataSize agree with the rest of the share data
-- because the field is supposedly unused so everyone should just ignore
......@@ -79,10 +79,10 @@ shares = do
-- XXX These merkle trees and the "needed hashes" list all have a size
-- that really needs to be dictated by the encoding parameters (k and n).
sharePlaintextHashTree <- merkleTrees (Range.linear 1 256)
shareCrypttextHashTree <- merkleTrees (Range.linear 1 256)
shareBlockHashTree <- merkleTrees (Range.linear 1 256)
shareNeededHashes <- Gen.list (Range.linear 1 100) ((,) <$> Gen.integral (Range.linear 1 255) <*> Gen.bytes (Range.singleton 32))
sharePlaintextHashTree <- merkleTrees (Range.exponential 1 256)
shareCrypttextHashTree <- merkleTrees (Range.exponential 1 256)
shareBlockHashTree <- merkleTrees (Range.exponential 1 256)
shareNeededHashes <- Gen.list (Range.exponential 1 100) ((,) <$> Gen.integral (Range.exponential 1 255) <*> Gen.bytes (Range.singleton 32))
-- XXX A valid share will have a URI extension that agrees with some of
-- the other fields we've just generated, which we're not even trying to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment