diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-05-19 09:56:01 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-05-19 09:56:05 +0200 |
commit | 7771aa57bdd606a3b9b9020b59da9ff8832860b6 (patch) | |
tree | 6663b91cafd27306d270064989e8d6ab24e9951f /src/test | |
parent | 18436d889653cbae62e86cd789479d4a69ada278 (diff) | |
parent | 2a8b3589b5a6c0863012329ddb40e7d901decf0e (diff) | |
download | bitcoin-7771aa57bdd606a3b9b9020b59da9ff8832860b6.tar.xz |
Merge #8070: Remove non-determinism which is breaking net_tests #8069
2a8b358 Fix typo adddrman to addrman as requested in #8070 (Ethan Heilman)
f4119c6 Remove non-determinism which is breaking net_tests #8069 (EthanHeilman)
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/net_tests.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index 6debf6ac5e..b38d61f330 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -17,6 +17,13 @@ class CAddrManSerializationMock : public CAddrMan { public: virtual void Serialize(CDataStream& s, int nType, int nVersionDummy) const = 0; + + //! Ensure that bucket placement is always the same for testing purposes. + void MakeDeterministic() + { + nKey.SetNull(); + seed_insecure_rand(true); + } }; class CAddrManUncorrupted : public CAddrManSerializationMock @@ -65,6 +72,7 @@ BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(caddrdb_read) { CAddrManUncorrupted addrmanUncorrupted; + addrmanUncorrupted.MakeDeterministic(); CService addr1 = CService("250.7.1.1", 8333); CService addr2 = CService("250.7.2.2", 9999); @@ -106,6 +114,7 @@ BOOST_AUTO_TEST_CASE(caddrdb_read) BOOST_AUTO_TEST_CASE(caddrdb_read_corrupted) { CAddrManCorrupted addrmanCorrupted; + addrmanCorrupted.MakeDeterministic(); // Test that the de-serialization of corrupted addrman throws an exception. CDataStream ssPeers1 = AddrmanToStream(addrmanCorrupted); @@ -119,7 +128,7 @@ BOOST_AUTO_TEST_CASE(caddrdb_read_corrupted) } catch (const std::exception& e) { exceptionThrown = true; } - // Even through de-serialization failed adddrman is not left in a clean state. + // Even through de-serialization failed addrman is not left in a clean state. BOOST_CHECK(addrman1.size() == 1); BOOST_CHECK(exceptionThrown); |