1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, usingPlaygrounds} from './util';192021describe('integration test: Inflation', () => {22 let superuser: IKeyringPair;2324 before(async () => {25 await usingPlaygrounds(async (_, privateKey) => {26 superuser = await privateKey('//Alice');27 });28 });2930 itSub('First year inflation is 10%', async ({helper}) => {31 32 const [bob] = await helper.arrange.createAccounts([10n], superuser);3334 await expect(helper.executeExtrinsic(bob, 'api.tx.inflation.startInflation', [1])).to.be.rejectedWith(/BadOrigin/);3536 37 await expect(helper.executeExtrinsic(superuser, 'api.tx.inflation.startInflation', [1])).to.be.rejectedWith(/BadOrigin/);3839 40 const tx = helper.constructApiCall('api.tx.inflation.startInflation', [1]);41 await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [tx])).to.not.be.rejected;4243 const blockInterval = (helper.getApi().consts.inflation.inflationBlockInterval as any).toBigInt();44 const totalIssuanceStart = ((await helper.callRpc('api.query.inflation.startingYearTotalIssuance', [])) as any).toBigInt();45 const blockInflation = (await helper.callRpc('api.query.inflation.blockInflation', []) as any).toBigInt();4647 const YEAR = 5259600n; 48 4950 const totalExpectedInflation = totalIssuanceStart / 10n;51 const totalActualInflation = blockInflation * YEAR / blockInterval;5253 const tolerance = 0.00001; 54 const expectedInflation = totalExpectedInflation / totalActualInflation - 1n;5556 expect(Math.abs(Number(expectedInflation))).to.be.lessThanOrEqual(tolerance);57 });58});