Skip to content

Commit

Permalink
fix: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Grigoriy Simonov committed Oct 18, 2023
1 parent 47816d9 commit be1922f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pallets/inflation/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl frame_system::Config for Test {

parameter_types! {
pub TreasuryAccountId: u64 = 1234;
pub const InflationBlockInterval: u32 = 10; // every time per how many blocks inflation is applied
pub const InflationBlockInterval: u32 = 100; // every time per how many blocks inflation is applied
pub static MockBlockNumberProvider: u32 = 0;
}

Expand Down
13 changes: 6 additions & 7 deletions tests/src/inflation.seqtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ describe('integration test: Inflation', () => {
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;
});
});

Expand All @@ -38,10 +42,6 @@ describe('integration test: Inflation', () => {
// 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();
Expand All @@ -63,15 +63,14 @@ describe('integration test: Inflation', () => {
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;

await helper.wait.forRelayBlockNumber(startBlock);

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));
Expand Down

0 comments on commit be1922f

Please sign in to comment.