This makes it possible for long and short components to exist in the same path.
This also makes shorter path components more likely. For
randint(1, randint(1, n)), the likelihood that one sees a number k
(1 <= k <= n) is 1/n * (\sum_{k=i}^n 1/i). This decreases with k, much like in
the real world where shorter paths are more common than longer ones.
The previous fix and this one together cause issue3958 to be detected by this
test with reasonable frequency. When this test was run 100 times in a loop, the
issue was detected 30 of those times.
test-pathencode.py outputs the seed value in hex if it finds a deviation.
This change allows to specify the seed value as a command line
parameter for test-pathencode.py in hex as well.
We already have two implementations of the pathencoding (C and
Python) and this test can perfectly well be used to probabilistically
test them instead of just wasting CPU cycles and test time.
This is a probabilistic test - it generates different test cases on every
run, unless invoked from the command line with a specific seed.
The default number of tests run should make the tests take about a
second to complete on a semi-modern laptop.