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()
398398
399399std::vector<unsigned char > FastRandomContext::randbytes (size_t len)
400400{
401+ if (requires_seed) RandomSeed ();
401402 std::vector<unsigned char > ret (len);
402403 if (len > 0 ) {
403404 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)
3838 BOOST_CHECK (ctx1.randbytes (50 ) == ctx2.randbytes (50 ));
3939
4040 // 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+ }
4653}
4754
4855BOOST_AUTO_TEST_CASE (fastrandom_randbits)
You can’t perform that action at this time.
0 commit comments