Skip to content

Commit

Permalink
test(smoke): fix S22C500 smoke test for moonriver and moonsama (#2864)
Browse files Browse the repository at this point in the history
* test(smoke): fix S22C500 smoke test for moonriver and moonsama

* make fix more agnostic
  • Loading branch information
RomarQ authored Jul 9, 2024
1 parent d607b2f commit f0ec9b4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/suites/smoke/test-staking-rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface RoundData {
}

interface PaymentRounds {
asyncBackingEnabled: boolean;
firstRewardBlock: Block;
rewardRound: RoundData; // Stores the last finished round (X)
roundToPay: RoundData; // Stores the round to pay (X-delay)
Expand Down Expand Up @@ -417,7 +418,12 @@ describeSuite({
);
const firstRewardBlock = (await api.rpc.chain.getBlock(firstRewardHash)).block;

const asyncBackingEnabled = !!api.runtimeMetadata.asLatest.pallets.find(
({ name }) => name.toHuman() === "AsyncBacking"
);

const payment: PaymentRounds = {
asyncBackingEnabled,
firstRewardBlock,
rewardRound,
roundToPay,
Expand Down Expand Up @@ -551,12 +557,7 @@ describeSuite({

// calculate reward amounts
let totalRoundIssuance: BN;

// TODO: Update this as moonriver & moonbeam enable async backing
const isAsync =
payment.rewardRound.firstBlockSpecVersion >= 2801 &&
payment.rewardRound.firstBlockApi.consts.system.version.specName.toString() === "moonbase";
if (isAsync) {
if (payment.asyncBackingEnabled) {
// Formula:
// totalRoundIssuance = (roundDuration / idealDuration) * idealIssuance

Expand Down Expand Up @@ -584,7 +585,7 @@ describeSuite({
totalRoundIssuance = roundDuration.mul(idealIssuance).div(idealDuration);
} else {
// Always apply max inflation
// It work because the total staked amound is already 1000 times more than the max on
// It works because the total staked amount is already 1000 times more than the max on
// production, so it's very unlikely to change before RT2801 deployment on moonbeam

const totalIssuance =
Expand Down

0 comments on commit f0ec9b4

Please sign in to comment.