File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -398,6 +398,7 @@ uint256 FastRandomContext::rand256()
398
398
399
399
std::vector<unsigned char > FastRandomContext::randbytes (size_t len)
400
400
{
401
+ if (requires_seed) RandomSeed ();
401
402
std::vector<unsigned char > ret (len);
402
403
if (len > 0 ) {
403
404
rng.Output (&ret[0 ], len);
Original file line number Diff line number Diff line change @@ -38,11 +38,18 @@ BOOST_AUTO_TEST_CASE(fastrandom_tests)
38
38
BOOST_CHECK (ctx1.randbytes (50 ) == ctx2.randbytes (50 ));
39
39
40
40
// Check that a nondeterministic ones are not
41
- FastRandomContext ctx3;
42
- FastRandomContext ctx4;
43
- BOOST_CHECK (ctx3.rand64 () != ctx4.rand64 ()); // extremely unlikely to be equal
44
- BOOST_CHECK (ctx3.rand256 () != ctx4.rand256 ());
45
- BOOST_CHECK (ctx3.randbytes (7 ) != ctx4.randbytes (7 ));
41
+ {
42
+ FastRandomContext ctx3, ctx4;
43
+ BOOST_CHECK (ctx3.rand64 () != ctx4.rand64 ()); // extremely unlikely to be equal
44
+ }
45
+ {
46
+ FastRandomContext ctx3, ctx4;
47
+ BOOST_CHECK (ctx3.rand256 () != ctx4.rand256 ());
48
+ }
49
+ {
50
+ FastRandomContext ctx3, ctx4;
51
+ BOOST_CHECK (ctx3.randbytes (7 ) != ctx4.randbytes (7 ));
52
+ }
46
53
}
47
54
48
55
BOOST_AUTO_TEST_CASE (fastrandom_randbits)
You can’t perform that action at this time.
0 commit comments