Skip to content

Commit

Permalink
check points sum is consistent (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanocryk authored Nov 27, 2024
1 parent b866a6e commit bb1193d
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 bb1193d

Please sign in to comment.