git.delta.rocks / unique-network / refs/commits / d97991513dd8

difftreelog

test scheduled tx should take a fee

Daniel Shiposha2022-08-18parent: #07b1ed5.patch.diff
in: master

2 files changed

modifiedtest-pallets/utils/src/lib.rsdiffbeforeafterboth
70 Err(<Error<T>>::TriggerRollback.into())70 Err(<Error<T>>::TriggerRollback.into())
71 }71 }
72
73 #[pallet::weight(100_000_000)]
74 pub fn just_take_fee(_origin: OriginFor<T>) -> DispatchResult {
75 Ok(())
76 }
72 }77 }
73}78}
7479
modifiedtests/src/.outdated/scheduler.test.tsdiffbeforeafterboth
216 });216 });
217 });217 });
218
219 it('Scheduled tasks should take some fees', async function() {
220 await requirePallets(this, [Pallets.TestUtils]);
221
222 await usingApi(async api => {
223 const scheduledId = makeScheduledId();
224 const waitForBlocks = 10;
225 const period = 2;
226 const repetitions = 1;
227
228 const dummyTxFeeAmount = 100_000_000;
229
230 const dummyTx = api.tx.testUtils.justTakeFee();
231
232 await expect(scheduleAfter(
233 api,
234 dummyTx,
235 alice,
236 waitForBlocks,
237 scheduledId,
238 period,
239 repetitions,
240 )).to.not.be.rejected;
241
242 const aliceInitBalance = await getFreeBalance(alice);
243 let diff;
244
245 await waitNewBlocks(waitForBlocks + 1);
246
247 const aliceBalanceAfterFirst = await getFreeBalance(alice);
248 expect(
249 aliceBalanceAfterFirst < aliceInitBalance,
250 '[after execution #1] Scheduled task should take a fee',
251 ).to.be.true;
252
253 diff = aliceInitBalance - aliceBalanceAfterFirst;
254 expect(diff).to.be.equal(dummyTxFeeAmount, 'Scheduled task should take the right amount of fees');
255
256 await waitNewBlocks(period);
257
258 const aliceBalanceAfterSecond = await getFreeBalance(alice);
259 expect(
260 aliceBalanceAfterSecond < aliceBalanceAfterFirst,
261 '[after execution #2] Scheduled task should take a fee',
262 ).to.be.true;
263
264 diff = aliceBalanceAfterFirst - aliceBalanceAfterSecond;
265 expect(diff).to.be.equal(dummyTxFeeAmount, 'Scheduled task should take the right amount of fees');
266 });
267 });
218268
219 // FIXME What purpose of this test?269 // FIXME What purpose of this test?
220 it.skip('Can schedule a scheduled operation of canceling the scheduled operation', async () => {270 it.skip('Can schedule a scheduled operation of canceling the scheduled operation', async () => {