From f3edb6a6effcb513931b1091d1b3a7d7aa0b5d5d Mon Sep 17 00:00:00 2001 From: Brad Chase Date: Tue, 24 Oct 2017 13:58:30 -0400 Subject: [PATCH] [FOLD] Address PR comments --- src/ripple/app/misc/impl/ValidatorSite.cpp | 4 ++++ src/test/app/ValidatorList_test.cpp | 3 ++- src/test/rpc/ValidatorRPC_test.cpp | 8 ++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/ripple/app/misc/impl/ValidatorSite.cpp b/src/ripple/app/misc/impl/ValidatorSite.cpp index f28d5f0662e..8f7d2f69c58 100644 --- a/src/ripple/app/misc/impl/ValidatorSite.cpp +++ b/src/ripple/app/misc/impl/ValidatorSite.cpp @@ -212,6 +212,9 @@ ValidatorSite::onSiteFetch( JLOG (j_.warn()) << "Request for validator list at " << sites_[siteIdx].uri << " returned " << res.result_int(); + + sites_[siteIdx].lastRefreshStatus.emplace( + Site::Status{clock_type::now(), ListDisposition::invalid}); } else if (! ec) { @@ -294,6 +297,7 @@ ValidatorSite::onSiteFetch( } else { + std::lock_guard lock{sites_mutex_}; sites_[siteIdx].lastRefreshStatus.emplace( Site::Status{clock_type::now(), ListDisposition::invalid}); diff --git a/src/test/app/ValidatorList_test.cpp b/src/test/app/ValidatorList_test.cpp index fb4b91936a5..94f12aa066a 100644 --- a/src/test/app/ValidatorList_test.cpp +++ b/src/test/app/ValidatorList_test.cpp @@ -937,7 +937,7 @@ class ValidatorList_test : public beast::unit_test::suite manifests, manifests, env.app().timeKeeper(), journal); std::vector valKeys = {randomNode()}; - + hash_set activeKeys{valKeys.begin(), valKeys.end()}; // Store prepared list data to control when it is applied struct PreparedList { @@ -1007,6 +1007,7 @@ class ValidatorList_test : public beast::unit_test::suite // Advance past the first list's expiration, but it remains the // earliest expiration env.timeKeeper().set(prep1.expiration + 1s); + trustedKeys->onConsensusStart(activeKeys); BEAST_EXPECT( trustedKeys->expires() && trustedKeys->expires().get() == prep1.expiration); diff --git a/src/test/rpc/ValidatorRPC_test.cpp b/src/test/rpc/ValidatorRPC_test.cpp index 84c01274b1b..7bc1c9b3532 100644 --- a/src/test/rpc/ValidatorRPC_test.cpp +++ b/src/test/rpc/ValidatorRPC_test.cpp @@ -210,6 +210,10 @@ class ValidatorRPC_test : public beast::unit_test::suite return cfg; }), }; + + env.app().validatorSites().start(); + env.app().validatorSites().join(); + { auto const jrr = env.rpc("server_info")[jss::result]; BEAST_EXPECT( @@ -247,8 +251,8 @@ class ValidatorRPC_test : public beast::unit_test::suite auto js = jrr[jss::validator_sites][0u]; BEAST_EXPECT(js[jss::refresh_interval_min].asUInt() == 5); BEAST_EXPECT(js[jss::uri] == siteURI); - BEAST_EXPECT(!js.isMember(jss::last_refresh_time)); - BEAST_EXPECT(!js.isMember(jss::last_refresh_status)); + BEAST_EXPECT(js.isMember(jss::last_refresh_time)); + BEAST_EXPECT(js[jss::last_refresh_status] == "invalid"); } } }