difftreelog
fix code review
in: master
2 files changed
js-packages/tests/inflation.seqtest.tsdiffbeforeafterboth--- a/js-packages/tests/inflation.seqtest.ts
+++ b/js-packages/tests/inflation.seqtest.ts
@@ -24,8 +24,12 @@
let superuser: IKeyringPair;
before(async () => {
- await usingPlaygrounds(async (_, privateKey) => {
+ await usingPlaygrounds(async (helper, privateKey) => {
superuser = await privateKey('//Alice');
+ const api = helper.getApi();
+
+ const relayBlock = (await api.query.parachainSystem.lastRelayChainBlockNumber()).toNumber();
+ await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [helper.constructApiCall('api.tx.inflation.startInflation', [relayBlock])])).to.not.be.rejected;
});
});
@@ -38,10 +42,6 @@
// Make sure superuser can't start inflation without explicit sudo
await expect(helper.executeExtrinsic(superuser, 'api.tx.inflation.startInflation', [1])).to.be.rejectedWith(/BadOrigin/);
- // Start inflation on relay block 1 (Alice is sudo)
- const tx = helper.constructApiCall('api.tx.inflation.startInflation', [1]);
- await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [tx])).to.not.be.rejected;
-
const blockInterval = (helper.getApi().consts.inflation.inflationBlockInterval as any).toBigInt();
const totalIssuanceStart = ((await helper.callRpc('api.query.inflation.startingYearTotalIssuance', [])) as any).toBigInt();
const blockInflation = (await helper.callRpc('api.query.inflation.blockInflation', []) as any).toBigInt();
@@ -63,7 +63,6 @@
const blockInterval = await api.consts.inflation.inflationBlockInterval.toNumber();
const relayBlock = (await api.query.parachainSystem.lastRelayChainBlockNumber()).toNumber();
- await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [helper.constructApiCall('api.tx.inflation.startInflation', [relayBlock])]);
const blockInflation = (await helper.callRpc('api.query.inflation.blockInflation', []) as any).toBigInt();
const startBlock = (relayBlock + blockInterval) - (relayBlock % blockInterval) + 1;
@@ -71,7 +70,7 @@
const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
- await helper.wait.forRelayBlockNumber(startBlock + blockInterval);
+ await helper.wait.forRelayBlockNumber(startBlock + blockInterval + 1);
const treasuryBalanceAfter = await helper.balance.getSubstrate(TREASURY);
expect(Number(treasuryBalanceAfter)).to.be.eqls(Number(treasuryBalanceBefore + blockInflation));
pallets/inflation/src/tests.rsdiffbeforeafterboth106106107parameter_types! {107parameter_types! {108 pub TreasuryAccountId: u64 = 1234;108 pub TreasuryAccountId: u64 = 1234;109 pub const InflationBlockInterval: u32 = 10; // every time per how many blocks inflation is applied109 pub const InflationBlockInterval: u32 = 100; // every time per how many blocks inflation is applied110 pub static MockBlockNumberProvider: u32 = 0;110 pub static MockBlockNumberProvider: u32 = 0;111}111}112112