From 236c4ef3a959fa2dc5a6f923fb89d5d9ba85884a Mon Sep 17 00:00:00 2001 From: Chenna Keshava Date: Fri, 20 Oct 2023 16:01:12 -0700 Subject: [PATCH] fix failing Linux Debug builds: do not call with ValidatorList::load(PublicKey::emptyPubKey) -- hits the assert inside the function --- src/test/app/Manifest_test.cpp | 2 +- src/test/app/ValidatorList_test.cpp | 78 +++++++++++------------------ src/test/app/ValidatorSite_test.cpp | 4 +- 3 files changed, 31 insertions(+), 53 deletions(-) diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index ee0571c33bd..7a9142e938b 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -316,7 +316,7 @@ class Manifest_test : public beast::unit_test::suite for (auto const& man : inManifests) s1.push_back( toBase58(TokenType::NodePublic, man->masterKey)); - unl->load(emptyLocalKey, s1, keys); + unl->load({}, s1, keys); m.save( *dbCon, diff --git a/src/test/app/ValidatorList_test.cpp b/src/test/app/ValidatorList_test.cpp index 48b7fa4e902..638c2060d32 100644 --- a/src/test/app/ValidatorList_test.cpp +++ b/src/test/app/ValidatorList_test.cpp @@ -221,7 +221,6 @@ class ValidatorList_test : public beast::unit_test::suite jtx::Env env( *this, jtx::envconfig(), nullptr, beast::severities::kDisabled); auto& app = env.app(); - PublicKey emptyLocalKey(PublicKey::emptyPubKey); std::vector const emptyCfgKeys; std::vector const emptyCfgPublishers; @@ -278,8 +277,8 @@ class ValidatorList_test : public beast::unit_test::suite env.journal); // Correct (empty) configuration - BEAST_EXPECT(trustedKeys->load( - emptyLocalKey, emptyCfgKeys, emptyCfgPublishers)); + BEAST_EXPECT( + trustedKeys->load({}, emptyCfgKeys, emptyCfgPublishers)); // load local validator key with or without manifest BEAST_EXPECT(trustedKeys->load( @@ -303,8 +302,7 @@ class ValidatorList_test : public beast::unit_test::suite app.config().legacy("database_path"), env.journal); - BEAST_EXPECT( - trustedKeys->load(emptyLocalKey, cfgKeys, emptyCfgPublishers)); + BEAST_EXPECT(trustedKeys->load({}, cfgKeys, emptyCfgPublishers)); for (auto const& n : configList) BEAST_EXPECT(trustedKeys->listed(n)); @@ -315,23 +313,21 @@ class ValidatorList_test : public beast::unit_test::suite std::vector cfgMasterKeys( {format(masterNode1), format(masterNode2, " Comment")}); - BEAST_EXPECT(trustedKeys->load( - emptyLocalKey, cfgMasterKeys, emptyCfgPublishers)); + BEAST_EXPECT( + trustedKeys->load({}, cfgMasterKeys, emptyCfgPublishers)); BEAST_EXPECT(trustedKeys->listed(masterNode1)); BEAST_EXPECT(trustedKeys->listed(masterNode2)); // load should reject invalid config keys + BEAST_EXPECT( + !trustedKeys->load({}, {"NotAPublicKey"}, emptyCfgPublishers)); BEAST_EXPECT(!trustedKeys->load( - emptyLocalKey, {"NotAPublicKey"}, emptyCfgPublishers)); - BEAST_EXPECT(!trustedKeys->load( - emptyLocalKey, - {format(randomNode(), "!")}, - emptyCfgPublishers)); + {}, {format(randomNode(), "!")}, emptyCfgPublishers)); // load terminates when encountering an invalid entry auto const goodKey = randomNode(); BEAST_EXPECT(!trustedKeys->load( - emptyLocalKey, + {}, {format(randomNode(), "!"), format(goodKey)}, emptyCfgPublishers)); BEAST_EXPECT(!trustedKeys->listed(goodKey)); @@ -408,8 +404,7 @@ class ValidatorList_test : public beast::unit_test::suite // load should reject invalid validator list signing keys std::vector badPublishers({"NotASigningKey"}); - BEAST_EXPECT( - !trustedKeys->load(emptyLocalKey, emptyCfgKeys, badPublishers)); + BEAST_EXPECT(!trustedKeys->load({}, emptyCfgKeys, badPublishers)); // load should reject validator list signing keys with invalid // encoding @@ -419,8 +414,7 @@ class ValidatorList_test : public beast::unit_test::suite for (auto const& key : keys) badPublishers.push_back(toBase58(TokenType::NodePublic, key)); - BEAST_EXPECT( - !trustedKeys->load(emptyLocalKey, emptyCfgKeys, badPublishers)); + BEAST_EXPECT(!trustedKeys->load({}, emptyCfgKeys, badPublishers)); for (auto const& key : keys) BEAST_EXPECT(!trustedKeys->trustedPublisher(key)); @@ -429,8 +423,7 @@ class ValidatorList_test : public beast::unit_test::suite for (auto const& key : keys) cfgPublishers.push_back(strHex(key)); - BEAST_EXPECT( - trustedKeys->load(emptyLocalKey, emptyCfgKeys, cfgPublishers)); + BEAST_EXPECT(trustedKeys->load({}, emptyCfgKeys, cfgPublishers)); for (auto const& key : keys) BEAST_EXPECT(trustedKeys->trustedPublisher(key)); } @@ -464,8 +457,7 @@ class ValidatorList_test : public beast::unit_test::suite std::vector cfgPublishers = { strHex(pubRevokedPublic), strHex(legitKey)}; - BEAST_EXPECT( - trustedKeys->load(emptyLocalKey, emptyCfgKeys, cfgPublishers)); + BEAST_EXPECT(trustedKeys->load({}, emptyCfgKeys, cfgPublishers)); BEAST_EXPECT(!trustedKeys->trustedPublisher(pubRevokedPublic)); BEAST_EXPECT(trustedKeys->trustedPublisher(legitKey)); @@ -569,10 +561,9 @@ class ValidatorList_test : public beast::unit_test::suite 1)); std::vector cfgKeys1({strHex(publisherPublic)}); - PublicKey emptyLocalKey(PublicKey::emptyPubKey); std::vector emptyCfgKeys; - BEAST_EXPECT(trustedKeys->load(emptyLocalKey, emptyCfgKeys, cfgKeys1)); + BEAST_EXPECT(trustedKeys->load({}, emptyCfgKeys, cfgKeys1)); std::map> const lists = []() { auto constexpr listSize = 20; @@ -954,10 +945,9 @@ class ValidatorList_test : public beast::unit_test::suite 1)); std::vector cfgKeys1({strHex(publisherPublic)}); - PublicKey emptyLocalKey(PublicKey::emptyPubKey); std::vector emptyCfgKeys; - BEAST_EXPECT(trustedKeys->load(emptyLocalKey, emptyCfgKeys, cfgKeys1)); + BEAST_EXPECT(trustedKeys->load({}, emptyCfgKeys, cfgKeys1)); std::vector const list = []() { auto constexpr listSize = 20; @@ -1066,7 +1056,6 @@ class ValidatorList_test : public beast::unit_test::suite std::string const siteUri = "testUpdateTrusted.test"; - PublicKey emptyLocalKeyOuter(PublicKey::emptyPubKey); ManifestCache manifestsOuter; jtx::Env env(*this); auto& app = env.app(); @@ -1096,8 +1085,8 @@ class ValidatorList_test : public beast::unit_test::suite unseenValidators.emplace(calcNodeID(valKey)); } - BEAST_EXPECT(trustedKeysOuter->load( - emptyLocalKeyOuter, cfgKeys, cfgPublishersOuter)); + BEAST_EXPECT( + trustedKeysOuter->load({}, cfgKeys, cfgPublishersOuter)); // updateTrusted should make all configured validators trusted // even if they are not active/seen @@ -1147,8 +1136,8 @@ class ValidatorList_test : public beast::unit_test::suite std::vector cfgKeys( {toBase58(TokenType::NodePublic, masterPublic)}); - BEAST_EXPECT(trustedKeysOuter->load( - emptyLocalKeyOuter, cfgKeys, cfgPublishersOuter)); + BEAST_EXPECT( + trustedKeysOuter->load({}, cfgKeys, cfgPublishersOuter)); auto const signingKeys1 = randomKeyPair(KeyType::secp256k1); auto const signingPublic1 = signingKeys1.first; @@ -1260,8 +1249,7 @@ class ValidatorList_test : public beast::unit_test::suite std::vector cfgPublishers({strHex(publisherPublic)}); std::vector emptyCfgKeys; - BEAST_EXPECT(trustedKeys->load( - emptyLocalKeyOuter, emptyCfgKeys, cfgPublishers)); + BEAST_EXPECT(trustedKeys->load({}, emptyCfgKeys, cfgPublishers)); TrustChanges changes = trustedKeys->updateTrusted( activeValidatorsOuter, @@ -1305,8 +1293,7 @@ class ValidatorList_test : public beast::unit_test::suite toBeSeen = calcNodeID(valKey); } - BEAST_EXPECT(trustedKeys->load( - emptyLocalKeyOuter, cfgKeys, cfgPublishersOuter)); + BEAST_EXPECT(trustedKeys->load({}, cfgKeys, cfgPublishersOuter)); TrustChanges changes = trustedKeys->updateTrusted( activeValidators, @@ -1339,7 +1326,6 @@ class ValidatorList_test : public beast::unit_test::suite app.config().legacy("database_path"), env.journal); - PublicKey emptyLocalKey(PublicKey::emptyPubKey); std::vector emptyCfgKeys; auto const publisherKeys = randomKeyPair(KeyType::secp256k1); auto const pubSigningKeys = randomKeyPair(KeyType::secp256k1); @@ -1352,8 +1338,7 @@ class ValidatorList_test : public beast::unit_test::suite std::vector cfgKeys({strHex(publisherKeys.first)}); - BEAST_EXPECT( - trustedKeys->load(emptyLocalKey, emptyCfgKeys, cfgKeys)); + BEAST_EXPECT(trustedKeys->load({}, emptyCfgKeys, cfgKeys)); std::vector list({randomValidator(), randomValidator()}); hash_set activeValidators( @@ -1463,8 +1448,7 @@ class ValidatorList_test : public beast::unit_test::suite cfgKeys.push_back(toBase58(TokenType::NodePublic, valKey)); activeValidators.emplace(calcNodeID(valKey)); activeKeys.emplace(valKey); - BEAST_EXPECT(trustedKeys->load( - emptyLocalKeyOuter, cfgKeys, cfgPublishers)); + BEAST_EXPECT(trustedKeys->load({}, cfgKeys, cfgPublishers)); TrustChanges changes = trustedKeys->updateTrusted( activeValidators, env.timeKeeper().now(), @@ -1564,11 +1548,10 @@ class ValidatorList_test : public beast::unit_test::suite std::vector cfgPublishers( {strHex(publisherPublic)}); - PublicKey emptyLocalKey(PublicKey::emptyPubKey); std::vector emptyCfgKeys; - BEAST_EXPECT(trustedKeys->load( - emptyLocalKey, emptyCfgKeys, cfgPublishers)); + BEAST_EXPECT( + trustedKeys->load({}, emptyCfgKeys, cfgPublishers)); auto const version = 1; auto const sequence = 1; @@ -1640,9 +1623,8 @@ class ValidatorList_test : public beast::unit_test::suite BEAST_EXPECT(trustedKeys->expires() == std::nullopt); // Config listed keys have maximum expiry - PublicKey emptyLocalKey(PublicKey::emptyPubKey); PublicKey localCfgListed = randomNode(); - trustedKeys->load(emptyLocalKey, {toStr(localCfgListed)}, {}); + trustedKeys->load({}, {toStr(localCfgListed)}, {}); BEAST_EXPECT( trustedKeys->expires() && trustedKeys->expires().value() == NetClock::time_point::max()); @@ -1688,11 +1670,10 @@ class ValidatorList_test : public beast::unit_test::suite std::vector cfgPublishers( {strHex(publisherPublic)}); - PublicKey emptyLocalKey(PublicKey::emptyPubKey); std::vector emptyCfgKeys; - BEAST_EXPECT(trustedKeys->load( - emptyLocalKey, emptyCfgKeys, cfgPublishers)); + BEAST_EXPECT( + trustedKeys->load({}, emptyCfgKeys, cfgPublishers)); auto const version = 2; auto const sequence1 = 1; @@ -1795,7 +1776,6 @@ class ValidatorList_test : public beast::unit_test::suite { testcase("NegativeUNL"); jtx::Env env(*this); - PublicKey emptyLocalKey(PublicKey::emptyPubKey); ManifestCache manifests; auto createValidatorList = @@ -1820,7 +1800,7 @@ class ValidatorList_test : public beast::unit_test::suite cfgKeys.push_back(toBase58(TokenType::NodePublic, valKey)); activeValidators.emplace(calcNodeID(valKey)); } - if (trustedKeys->load(emptyLocalKey, cfgKeys, cfgPublishers)) + if (trustedKeys->load({}, cfgKeys, cfgPublishers)) { trustedKeys->updateTrusted( activeValidators, diff --git a/src/test/app/ValidatorSite_test.cpp b/src/test/app/ValidatorSite_test.cpp index faf8b0d5008..d1d74fecf46 100644 --- a/src/test/app/ValidatorSite_test.cpp +++ b/src/test/app/ValidatorSite_test.cpp @@ -172,7 +172,6 @@ class ValidatorSite_test : public beast::unit_test::suite test::StreamSink sink; beast::Journal journal{sink}; - PublicKey emptyLocalKey(PublicKey::emptyPubKey); std::vector emptyCfgKeys; struct publisher { @@ -229,8 +228,7 @@ class ValidatorSite_test : public beast::unit_test::suite item.uri = uri.str(); } - BEAST_EXPECT( - trustedKeys.load(emptyLocalKey, emptyCfgKeys, cfgPublishers)); + BEAST_EXPECT(trustedKeys.load({}, emptyCfgKeys, cfgPublishers)); // Normally, tests will only need a fraction of this time, // but sometimes DNS resolution takes an inordinate amount