difftreelog
fix get expected scheduled tx fee
in: master
1 file changed
tests/src/.outdated/scheduler.test.tsdiffbeforeafterboth47 Pallets,47 Pallets,48} from '../deprecated-helpers/helpers';48} from '../deprecated-helpers/helpers';49import {IKeyringPair, SignatureOptions} from '@polkadot/types/types';49import {IKeyringPair, SignatureOptions} from '@polkadot/types/types';50import {RuntimeDispatchInfo} from '@polkadot/types/interfaces';50import {ApiPromise} from '@polkadot/api';51import {ApiPromise} from '@polkadot/api';51import {objectSpread} from '@polkadot/util';52import {objectSpread} from '@polkadot/util';5253215 });216 });216 });217 });217218218 it.only('Scheduled tasks should take some fees', async function() {219 it('Scheduled tasks should take correct fees', async function() {219 await requirePallets(this, [Pallets.TestUtils]);220 await requirePallets(this, [Pallets.TestUtils]);220221221 await usingApi(async api => {222 await usingApi(async api => {226227227 const dummyTx = api.tx.testUtils.justTakeFee();228 const dummyTx = api.tx.testUtils.justTakeFee();229 228 const expectedFee = (await dummyTx.paymentInfo(alice)).partialFee.toBigInt();230 const signingInfo = await api.derive.tx.signingInfo(alice.address);231232 // We need to sign the tx because233 // unsigned transactions does not have an inclusion fee234 dummyTx.sign(alice, {235 blockHash: api.genesisHash,236 genesisHash: api.genesisHash,237 runtimeVersion: api.runtimeVersion,238 nonce: signingInfo.nonce,239 });240241 const scheduledLen = dummyTx.callIndex.length;242229 const expFee = (await api.rpc.payment.queryFeeDetails(dummyTx.toHex())).inclusionFee.unwrap().toHuman();243 const queryInfo = await api.call.transactionPaymentApi.queryInfo(244 dummyTx.toHex(),245 scheduledLen,246 );230247231 console.log('>>>>>> expFee = ' + JSON.stringify(expFee));248 const expectedScheduledFee = (await queryInfo as RuntimeDispatchInfo)232249 .partialFee.toBigInt();233 // const collectionCreate = api.tx.unique.createCollectionEx({234 // name: 0,235 // tokenPrefix: 0xfaf,236 // });237238 // const options = makeSignOptions(api);239 // const signed = collectionCreate.sign(alice, options);240 // const expFee2 = (await api.rpc.payment.queryFeeDetails(signed.toHex())).inclusionFee.unwrap().toHuman();241 // console.log('!!!!!!!!!!!! expFee2 = ' + JSON.stringify(expFee2));242250243 await expect(scheduleAfter(251 await expect(scheduleAfter(244 api,252 api,264 ).to.be.true;272 ).to.be.true;265273266 diff = aliceInitBalance - aliceBalanceAfterFirst;274 diff = aliceInitBalance - aliceBalanceAfterFirst;267 expect(diff).to.be.equal(expectedFee, 'Scheduled task should take the right amount of fees');275 expect(diff).to.be.equal(276 expectedScheduledFee,277 'Scheduled task should take the right amount of fees',278 );268279269 await waitNewBlocks(period);280 await waitNewBlocks(period);275 ).to.be.true;286 ).to.be.true;276287277 diff = aliceBalanceAfterFirst - aliceBalanceAfterSecond;288 diff = aliceBalanceAfterFirst - aliceBalanceAfterSecond;278 expect(diff).to.be.equal(expectedFee, 'Scheduled task should take the right amount of fees');289 expect(diff).to.be.equal(290 expectedScheduledFee,291 'Scheduled task should take the right amount of fees',292 );279 });293 });280 });294 });