git.delta.rocks / unique-network / refs/commits / 43d9e123e745

difftreelog

fix code review

Grigoriy Simonov2023-11-15parent: #8b49ab6.patch.diff
in: master

2 files changed

modifiedjs-packages/tests/inflation.seqtest.tsdiffbeforeafterboth
24 let superuser: IKeyringPair;24 let superuser: IKeyringPair;
2525
26 before(async () => {26 before(async () => {
27 await usingPlaygrounds(async (_, privateKey) => {27 await usingPlaygrounds(async (helper, privateKey) => {
28 superuser = await privateKey('//Alice');28 superuser = await privateKey('//Alice');
29 const api = helper.getApi();
30
31 const relayBlock = (await api.query.parachainSystem.lastRelayChainBlockNumber()).toNumber();
32 await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [helper.constructApiCall('api.tx.inflation.startInflation', [relayBlock])])).to.not.be.rejected;
29 });33 });
30 });34 });
3135
38 // Make sure superuser can't start inflation without explicit sudo42 // Make sure superuser can't start inflation without explicit sudo
39 await expect(helper.executeExtrinsic(superuser, 'api.tx.inflation.startInflation', [1])).to.be.rejectedWith(/BadOrigin/);43 await expect(helper.executeExtrinsic(superuser, 'api.tx.inflation.startInflation', [1])).to.be.rejectedWith(/BadOrigin/);
40
41 // Start inflation on relay block 1 (Alice is sudo)
42 const tx = helper.constructApiCall('api.tx.inflation.startInflation', [1]);
43 await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [tx])).to.not.be.rejected;
4444
45 const blockInterval = (helper.getApi().consts.inflation.inflationBlockInterval as any).toBigInt();45 const blockInterval = (helper.getApi().consts.inflation.inflationBlockInterval as any).toBigInt();
46 const totalIssuanceStart = ((await helper.callRpc('api.query.inflation.startingYearTotalIssuance', [])) as any).toBigInt();46 const totalIssuanceStart = ((await helper.callRpc('api.query.inflation.startingYearTotalIssuance', [])) as any).toBigInt();
63 const blockInterval = await api.consts.inflation.inflationBlockInterval.toNumber();63 const blockInterval = await api.consts.inflation.inflationBlockInterval.toNumber();
6464
65 const relayBlock = (await api.query.parachainSystem.lastRelayChainBlockNumber()).toNumber();65 const relayBlock = (await api.query.parachainSystem.lastRelayChainBlockNumber()).toNumber();
66 await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [helper.constructApiCall('api.tx.inflation.startInflation', [relayBlock])]);
67 const blockInflation = (await helper.callRpc('api.query.inflation.blockInflation', []) as any).toBigInt();66 const blockInflation = (await helper.callRpc('api.query.inflation.blockInflation', []) as any).toBigInt();
68 const startBlock = (relayBlock + blockInterval) - (relayBlock % blockInterval) + 1;67 const startBlock = (relayBlock + blockInterval) - (relayBlock % blockInterval) + 1;
6968
70 await helper.wait.forRelayBlockNumber(startBlock);69 await helper.wait.forRelayBlockNumber(startBlock);
7170
72 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);71 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
7372
74 await helper.wait.forRelayBlockNumber(startBlock + blockInterval);73 await helper.wait.forRelayBlockNumber(startBlock + blockInterval + 1);
7574
76 const treasuryBalanceAfter = await helper.balance.getSubstrate(TREASURY);75 const treasuryBalanceAfter = await helper.balance.getSubstrate(TREASURY);
77 expect(Number(treasuryBalanceAfter)).to.be.eqls(Number(treasuryBalanceBefore + blockInflation));76 expect(Number(treasuryBalanceAfter)).to.be.eqls(Number(treasuryBalanceBefore + blockInflation));
modifiedpallets/inflation/src/tests.rsdiffbeforeafterboth
--- a/pallets/inflation/src/tests.rs
+++ b/pallets/inflation/src/tests.rs
@@ -106,7 +106,7 @@
 
 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;
 }