From 17986df677bac95384af667b763fc9888318f44b Mon Sep 17 00:00:00 2001 From: iceseer Date: Mon, 11 Nov 2024 08:36:45 +0300 Subject: [PATCH] issues fixes Signed-off-by: iceseer --- core/parachain/types.hpp | 15 +--------- test/core/parachain/grid_tracker.cpp | 44 ++++++++++++---------------- 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/core/parachain/types.hpp b/core/parachain/types.hpp index 68cd53c704..2e36a58a4f 100644 --- a/core/parachain/types.hpp +++ b/core/parachain/types.hpp @@ -198,20 +198,7 @@ namespace kagome::network { return hash_.value(); } - inline bool operator==(const CandidateReceipt &other) const { - return descriptor == other.descriptor - and commitments_hash == other.commitments_hash; - } - - friend inline scale::ScaleDecoderStream &operator>>( - scale::ScaleDecoderStream &s, CandidateReceipt &cr) { - return s >> cr.descriptor >> cr.commitments_hash; - } - - friend inline scale::ScaleEncoderStream &operator<<( - scale::ScaleEncoderStream &s, const CandidateReceipt &cr) { - return s << cr.descriptor << cr.commitments_hash; - } + SCALE_TIE_ONLY(descriptor, commitments_hash); private: mutable std::optional hash_{}; diff --git a/test/core/parachain/grid_tracker.cpp b/test/core/parachain/grid_tracker.cpp index 20b8b22afc..fbad8e3809 100644 --- a/test/core/parachain/grid_tracker.cpp +++ b/test/core/parachain/grid_tracker.cpp @@ -42,12 +42,6 @@ class GridTrackerTest : public ProspectiveParachainsTestHarness { }; return statement_filter; } - - template - inline auto check_error(const outcome::result &result, const E &e) const { - ASSERT_TRUE(result.has_error()); - ASSERT_EQ(result.error(), e); - } }; TEST_F(GridTrackerTest, reject_disallowed_manifest) { @@ -923,32 +917,32 @@ TEST_F(GridTrackerTest, knowledge_rejects_conflicting_manifest) { { auto s = expected_manifest_summary; s.claimed_group_index = GroupIndex(1); - check_error(knowledge.import_received(3, 2, fromNumber(1), s), - GridTracker::Error::CONFLICTING); + EXPECT_EC(knowledge.import_received(3, 2, fromNumber(1), s), + GridTracker::Error::CONFLICTING); } // conflicting parent hash { auto s = expected_manifest_summary; s.claimed_parent_hash = fromNumber(3); - check_error(knowledge.import_received(3, 2, fromNumber(1), s), - GridTracker::Error::CONFLICTING); + EXPECT_EC(knowledge.import_received(3, 2, fromNumber(1), s), + GridTracker::Error::CONFLICTING); } // conflicting seconded statements bitfield { auto s = expected_manifest_summary; s.statement_knowledge.seconded_in_group.bits = {false, true, false}; - check_error(knowledge.import_received(3, 2, fromNumber(1), s), - GridTracker::Error::CONFLICTING); + EXPECT_EC(knowledge.import_received(3, 2, fromNumber(1), s), + GridTracker::Error::CONFLICTING); } // conflicting valid statements bitfield { auto s = expected_manifest_summary; s.statement_knowledge.validated_in_group.bits = {false, true, false}; - check_error(knowledge.import_received(3, 2, fromNumber(1), s), - GridTracker::Error::CONFLICTING); + EXPECT_EC(knowledge.import_received(3, 2, fromNumber(1), s), + GridTracker::Error::CONFLICTING); } } @@ -983,17 +977,17 @@ TEST_F(GridTrackerTest, reject_overflowing_manifests) { // Reject a seconding validator that is already at the seconding limit. // Seconding counts for the validators should not be applied. - check_error(knowledge.import_received( - 3, - 2, - fromNumber(3), - ManifestSummary{ - .claimed_parent_hash = fromNumber(0xC), - .claimed_group_index = GroupIndex(0), - .statement_knowledge = create_filter( - {{true, true, true}, {false, true, true}}), - }), - GridTracker::Error::SECONDING_OVERFLOW); + EXPECT_EC(knowledge.import_received( + 3, + 2, + fromNumber(3), + ManifestSummary{ + .claimed_parent_hash = fromNumber(0xC), + .claimed_group_index = GroupIndex(0), + .statement_knowledge = create_filter( + {{true, true, true}, {false, true, true}}), + }), + GridTracker::Error::SECONDING_OVERFLOW); // Don't reject validators that have seconded less than the limit so far. ASSERT_TRUE(