Skip to content

Improve scheduler E2E test code #475

@rockbmb

Description

@rockbmb

In #446 , there were spurious failures with the scheduler E2E test suite because of unrobust code patterns in tests.

Example job: https://github.com/open-web3-stack/polkadot-ecosystem-tests/actions/runs/19148571343/job/54732595597

Example of offending code:

const scheduleTx = client.api.tx.scheduler.schedule(targetBlockNumber!, null, 0, adjustIssuanceTx)
await scheduleInlineCallWithOrigin(client, scheduleTx.method.toHex(), { system: 'Root' }, testConfig.blockProvider)
const oldTotalIssuance = await client.api.query.balances.totalIssuance()
await client.dev.newBlock()
let scheduled = await client.api.query.scheduler.agenda(targetBlockNumber!)
expect(scheduled.length).toBe(1)
expect(scheduled[0].isSome).toBeTruthy()
await check(scheduled[0].unwrap()).toMatchObject({
maybeId: null,
priority: 0,
call: { inline: adjustIssuanceTx.method.toHex() },
maybePeriodic: null,
origin: {
system: {
root: null,
},
},
})

Using client.dev.setStorage, the scheduler's agenda for a given block is manually modified to execute a certain task with a desired origin.
This block's prior agenda, from the live network, is erased, so test code executed normally.

The issue occurs when the executed call is itself a scheduling call, and the block in which it is scheduled already contains tasks, which schedule.schedule(Named) will not, as expected, delete.

This makes the above expects to fail, and the test to fail, incorrectly.

This issue is about correcting these unsafe accesses to the scheduler's agenda in tests, replacing them with a proper search.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinge2e testsRelated to end-to-end tests

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions