Improved readability of API for cumulative rewards
This commit is contained in:
@@ -34,11 +34,18 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
|
||||
});
|
||||
|
||||
describe('Tracking Cumulative Rewards (CR)', () => {
|
||||
it('should set CR and Most Recent CR when a pool is created', async () => {
|
||||
it('should set CR hen a pool is created is epoch 0', async () => {
|
||||
await simulation.runTestAsync(
|
||||
[],
|
||||
[TestAction.CreatePool],
|
||||
[{ event: 'SetCumulativeReward', epoch: 0 }, { event: 'SetMostRecentCumulativeReward', epoch: 0 }],
|
||||
[{ event: 'SetCumulativeReward', epoch: 0 }],
|
||||
);
|
||||
});
|
||||
it('should set CR and Most Recent CR when a pool is created in epoch >0', async () => {
|
||||
await simulation.runTestAsync(
|
||||
[TestAction.Finalize],
|
||||
[TestAction.CreatePool],
|
||||
[{ event: 'SetCumulativeReward', epoch: 1 }, { event: 'SetMostRecentCumulativeReward', epoch: 1 }],
|
||||
);
|
||||
});
|
||||
it('should not set CR or Most Recent CR when values already exist for the current epoch', async () => {
|
||||
|
@@ -37,20 +37,20 @@ export class CumulativeRewardTrackingSimulation {
|
||||
private static _extractTestLogs(txReceiptLogs: DecodedLogArgs[]): TestLog[] {
|
||||
const logs = [];
|
||||
for (const log of txReceiptLogs) {
|
||||
if ((log as any).event === 'SetMostRecentCumulativeReward') {
|
||||
if ((log as DecodedLogArgs).event === 'SetMostRecentCumulativeReward') {
|
||||
logs.push({
|
||||
event: 'SetMostRecentCumulativeReward',
|
||||
epoch: (log as any).args.epoch,
|
||||
epoch: (log as DecodedLogArgs).args.epoch.toNumber(),
|
||||
});
|
||||
} else if ((log as any).event === 'SetCumulativeReward') {
|
||||
} else if ((log as DecodedLogArgs).event === 'SetCumulativeReward') {
|
||||
logs.push({
|
||||
event: 'SetCumulativeReward',
|
||||
epoch: (log as any).args.epoch,
|
||||
epoch: (log as DecodedLogArgs).args.epoch.toNumber(),
|
||||
});
|
||||
} else if ((log as any).event === 'UnsetCumulativeReward') {
|
||||
} else if ((log as DecodedLogArgs).event === 'UnsetCumulativeReward') {
|
||||
logs.push({
|
||||
event: 'UnsetCumulativeReward',
|
||||
epoch: (log as any).args.epoch,
|
||||
epoch: (log as DecodedLogArgs).args.epoch.toNumber(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ export class CumulativeRewardTrackingSimulation {
|
||||
{ from: this._poolOperator },
|
||||
);
|
||||
const createStakingPoolLog = txReceipt.logs[0];
|
||||
this._poolId = (createStakingPoolLog as any).args.poolId;
|
||||
this._poolId = (createStakingPoolLog as DecodedLogArgs).args.poolId;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Reference in New Issue
Block a user