Skip to content

Commit

Permalink
check points sum is consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
nanocryk committed Nov 25, 2024
1 parent be79416 commit 0447e39
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { beforeAll, describeSuite, expect } from "@moonwall/cli";
import { ApiPromise } from "@polkadot/api";

describeSuite({
id: "S22",
title: "Smoke tests for external validators rewards pallet",
foundationMethods: "read_only",
testCases: ({ it, context }) => {
let api: ApiPromise;

beforeAll(async () => {
api = context.polkadotJs();
});

it({
id: "C01",
title: "Total points matches sum of individual points",
test: async function () {
const entries = await api.query.externalValidatorsRewards.rewardPointsForEra.entries();

for (const [key, entry] of entries) {
let sum = 0;
for (const [, points] of entry.individual.entries()) {
sum += points.toNumber();
}
expect(sum).to.be.eq(entry.total.toNumber(), `inconsistency at key ${key}`);
}
},
});
},
});

0 comments on commit 0447e39

Please sign in to comment.