diff --git a/src/test/rpc/RPCOverload_test.cpp b/src/test/rpc/RPCOverload_test.cpp index 4c5037f1b..10c287c2a 100644 --- a/src/test/rpc/RPCOverload_test.cpp +++ b/src/test/rpc/RPCOverload_test.cpp @@ -58,9 +58,13 @@ public: // When booted, we just get a null json response if(jv.isNull()) booted = true; - else - BEAST_EXPECT(jv.isMember(jss::status) - && (jv[jss::status] == "success")); + else if (!(jv.isMember(jss::status) && + (jv[jss::status] == "success"))) + { + // Don't use BEAST_EXPECT above b/c it will be called a non-deterministic number of times + // and the number of tests run should be deterministic + fail(); + } if(jv.isMember(jss::warning)) warned = jv[jss::warning] == jss::load; diff --git a/src/test/shamap/SHAMapSync_test.cpp b/src/test/shamap/SHAMapSync_test.cpp index fead36807..417b20c83 100644 --- a/src/test/shamap/SHAMapSync_test.cpp +++ b/src/test/shamap/SHAMapSync_test.cpp @@ -24,6 +24,7 @@ #include #include #include +#include namespace ripple { namespace tests { @@ -31,12 +32,14 @@ namespace tests { class sync_test : public beast::unit_test::suite { public: - static std::shared_ptr makeRandomAS () + beast::xor_shift_engine eng_; + + std::shared_ptr makeRandomAS () { Serializer s; for (int d = 0; d < 3; ++d) - s.add32 (rand_int()); + s.add32 (rand_int(eng_)); return std::make_shared( s.getSHA512Half(), s.peekData ()); @@ -140,8 +143,8 @@ public: SHAMapNodeID (), gotNodeIDs_a, gotNodes_a, - rand_bool(), - rand_int(2))); + rand_bool(eng_), + rand_int(eng_, 2))); unexpected (gotNodes_a.size () < 1, "NodeSize"); @@ -168,24 +171,32 @@ public: for (auto& it : nodesMissing) { - BEAST_EXPECT(source.getNodeFat ( - it.first, - gotNodeIDs_b, - gotNodes_b, - rand_bool(), - rand_int(2))); + // Don't use BEAST_EXPECT here b/c it will be called a non-deterministic number of times + // and the number of tests run should be deterministic + if (!source.getNodeFat( + it.first, + gotNodeIDs_b, + gotNodes_b, + rand_bool(eng_), + rand_int(eng_, 2))) + fail(); } - BEAST_EXPECT(gotNodeIDs_b.size () == gotNodes_b.size ()); - BEAST_EXPECT(!gotNodeIDs_b.empty ()); + // Don't use BEAST_EXPECT here b/c it will be called a non-deterministic number of times + // and the number of tests run should be deterministic + if (gotNodeIDs_b.size() != gotNodes_b.size() || + gotNodeIDs_b.empty()) + fail(); for (std::size_t i = 0; i < gotNodeIDs_b.size(); ++i) { - BEAST_EXPECT( - destination.addKnownNode ( - gotNodeIDs_b[i], - makeSlice(gotNodes_b[i]), - nullptr).isUseful ()); + // Don't use BEAST_EXPECT here b/c it will be called a non-deterministic number of times + // and the number of tests run should be deterministic + if (!destination + .addKnownNode( + gotNodeIDs_b[i], makeSlice(gotNodes_b[i]), nullptr) + .isUseful()) + fail(); } } while (true);