Skip to content

Commit

Permalink
issues fixes
Browse files Browse the repository at this point in the history
Signed-off-by: iceseer <[email protected]>
  • Loading branch information
iceseer committed Nov 11, 2024
1 parent e62f185 commit 17986df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 39 deletions.
15 changes: 1 addition & 14 deletions core/parachain/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<parachain::Hash> hash_{};
Expand Down
44 changes: 19 additions & 25 deletions test/core/parachain/grid_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ class GridTrackerTest : public ProspectiveParachainsTestHarness {
};
return statement_filter;
}

template <typename T, typename E>
inline auto check_error(const outcome::result<T> &result, const E &e) const {
ASSERT_TRUE(result.has_error());
ASSERT_EQ(result.error(), e);
}
};

TEST_F(GridTrackerTest, reject_disallowed_manifest) {
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 17986df

Please sign in to comment.