Skip to content

Add minor missing points to Preimage test #481

@rockbmb

Description

@rockbmb

#453 (and its PR #471) have left the preimages pallet with good end-to-end test coverage.

Two outstanding points remain:

  1. the test to ensureUpdated needs a fix regarding the check of transaction fee waiving
    /**
    * Test the "ensure_updated" preimage functionality.
    *
    * 1. Simulate a number of pre-deprecation preimages with bogus hashes.
    * 2. Alice registers a number of post-deprecation (valid) preimages.
    * 3. Ensure that all valid preimages have been registered.
    * 4. Alice calls "ensure_updated" for all hashes (valid and bogus).
    * 5. Verify that Alice's reserved funds remain the same after the update.
    * 6. If the ratio of new to total preimages is less than 90%, check that fees have been paid.
    */
    async function preimageEnsureUpdatedTest<
    TCustom extends Record<string, unknown> | undefined,
    TInitStorages extends Record<string, Record<string, any>> | undefined,
    >(chain: Chain<TCustom, TInitStorages>, oldPreimagesCount: number, newPreimagesCount: number) {
    const [client] = await setupNetworks(chain)
  2. the test to excessively large preimages is currently not submitting the preimage it generates
    /**
    * Test the registering (noting) and unregistering (unnoting) of an oversized preimage.
    *
    * 1. Alice registers an oversized preimage.
    * 2. The registration fails and no preimage is stored.
    */
    async function preimageOversizedTest<
    TCustom extends Record<string, unknown> | undefined,
    TInitStorages extends Record<string, Record<string, any>> | undefined,
    >(chain: Chain<TCustom, TInitStorages>) {
    const [client] = await setupNetworks(chain)
    const alice = testAccounts.alice
    setupBalances(client, [{ address: alice.address, amount: 1000e10 }])
    // 1. Alice registers an oversized preimage (more than 4 MB).
    const maxPreimageSize = 4 * 1024 * 1024
    const oversizedBytes = new Uint8Array(maxPreimageSize + 1).fill(1)

This PR is to address these minor issues.

Metadata

Metadata

Assignees

Labels

e2e testsRelated to end-to-end testsenhancementNew feature or request

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions