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 @@ -396,6 +396,7 @@ uint256 FastRandomContext::rand256()
396396
397397std::vector<unsigned char > FastRandomContext::randbytes (size_t len)
398398{
399+ if (requires_seed) RandomSeed ();
399400 std::vector<unsigned char > ret (len);
400401 if (len > 0 ) {
401402 rng.Output (&ret[0 ], len);
Original file line number Diff line number Diff line change @@ -35,11 +35,18 @@ BOOST_AUTO_TEST_CASE(fastrandom_tests)
3535 BOOST_CHECK (ctx1.randbytes (50 ) == ctx2.randbytes (50 ));
3636
3737 // Check that a nondeterministic ones are not
38- FastRandomContext ctx3;
39- FastRandomContext ctx4;
40- BOOST_CHECK (ctx3.rand64 () != ctx4.rand64 ()); // extremely unlikely to be equal
41- BOOST_CHECK (ctx3.rand256 () != ctx4.rand256 ());
42- BOOST_CHECK (ctx3.randbytes (7 ) != ctx4.randbytes (7 ));
38+ {
39+ FastRandomContext ctx3, ctx4;
40+ BOOST_CHECK (ctx3.rand64 () != ctx4.rand64 ()); // extremely unlikely to be equal
41+ }
42+ {
43+ FastRandomContext ctx3, ctx4;
44+ BOOST_CHECK (ctx3.rand256 () != ctx4.rand256 ());
45+ }
46+ {
47+ FastRandomContext ctx3, ctx4;
48+ BOOST_CHECK (ctx3.randbytes (7 ) != ctx4.randbytes (7 ));
49+ }
4350}
4451
4552BOOST_AUTO_TEST_CASE (fastrandom_randbits)
You can’t perform that action at this time.
0 commit comments