Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Kusama Asset Hub PreImage > Kusama Asset Hub PreImage > preimage tests > preimage single note and unnote test > note preimage events 1`] = `
[
{
"data": {
"hash_": "(hash)",
},
"method": "Noted",
"section": "preimage",
},
]
`;

exports[`Kusama Asset Hub PreImage > Kusama Asset Hub PreImage > preimage tests > preimage single note and unnote test > unnote preimage events 1`] = `
[
{
"data": {
"hash_": "(hash)",
},
"method": "Cleared",
"section": "preimage",
},
]
`;
11 changes: 11 additions & 0 deletions packages/kusama/src/assetHubKusama.preimage.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { assetHubKusama } from '@e2e-test/networks/chains'
import { basePreimageE2ETests, registerTestTree, type TestConfig } from '@e2e-test/shared'

const testConfig: TestConfig = {
testSuiteName: 'Kusama Asset Hub PreImage',
addressEncoding: 2,
blockProvider: 'NonLocal',
asyncBacking: 'Enabled',
}

registerTestTree(basePreimageE2ETests(assetHubKusama, testConfig))
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Polkadot Governance > preimage tests > preimage submission, query and removal works > note preimage events 1`] = `
[
{
"data": {
"hash_": "(hash)",
},
"method": "Noted",
"section": "preimage",
},
]
`;

exports[`Polkadot Governance > preimage tests > preimage submission, query and removal works > unnote preimage events 1`] = `
[
{
"data": {
"hash_": "(hash)",
},
"method": "Cleared",
"section": "preimage",
},
]
`;

exports[`Polkadot Governance > referenda tests > referendum lifecycle test - submission, decision deposit, various voting should all work > cancelling referendum with signed origin 1`] = `
[
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Polkadot PreImage > Polkadot PreImage > preimage tests > preimage single note and unnote test > note preimage events 1`] = `
[
{
"data": {
"hash_": "(hash)",
},
"method": "Noted",
"section": "preimage",
},
]
`;

exports[`Polkadot PreImage > Polkadot PreImage > preimage tests > preimage single note and unnote test > unnote preimage events 1`] = `
[
{
"data": {
"hash_": "(hash)",
},
"method": "Cleared",
"section": "preimage",
},
]
`;
10 changes: 10 additions & 0 deletions packages/polkadot/src/polkadot.preimage.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { polkadot } from '@e2e-test/networks/chains'
import { basePreimageE2ETests, type RelayTestConfig, registerTestTree } from '@e2e-test/shared'

const testConfig: RelayTestConfig = {
testSuiteName: 'Polkadot PreImage',
addressEncoding: 0,
blockProvider: 'Local',
}

registerTestTree(basePreimageE2ETests(polkadot, testConfig))
61 changes: 0 additions & 61 deletions packages/shared/src/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,56 +874,6 @@ export async function referendumLifecycleKillTest<
})
}

/**
* Test the registering, querying and unregistering a preimage; in this test, a `spend_local`
* treasury call.
*/
export async function preimageTest<
TCustom extends Record<string, unknown> | undefined,
TInitStorages extends Record<string, Record<string, any>> | undefined,
>(chain: Chain<TCustom, TInitStorages>) {
const [client] = await setupNetworks(chain)

const encodedProposal = client.api.tx.treasury.spendLocal(1e10, devAccounts.bob.address).method
const preimageTx = client.api.tx.preimage.notePreimage(encodedProposal.toHex())
const preImageEvents = await sendTransaction(preimageTx.signAsync(devAccounts.alice))

await client.dev.newBlock()

await checkEvents(preImageEvents, 'preimage').toMatchSnapshot('note preimage events')

/**
* Query noted preimage
*/

let preimage = await client.api.query.preimage.preimageFor([
encodedProposal.hash.toHex(),
encodedProposal.encodedLength,
])

assert(preimage.isSome)
expect(preimage.unwrap().toHex()).toBe(encodedProposal.toHex())

/**
* Unnote preimage with the same account that had previously noted it
*/

const unnotePreimageTx = client.api.tx.preimage.unnotePreimage(encodedProposal.hash.toHex())
const unnotePreImageEvents = await sendTransaction(unnotePreimageTx.signAsync(devAccounts.alice))

await client.dev.newBlock()

await checkEvents(unnotePreImageEvents, 'preimage').toMatchSnapshot('unnote preimage events')

/**
* Query unnoted preimage, and verify it is absent
*/

preimage = await client.api.query.preimage.preimageFor([encodedProposal.hash.toHex(), encodedProposal.encodedLength])

assert(preimage.isNone)
}

export function baseGovernanceE2ETests<
TCustom extends Record<string, unknown> | undefined,
TInitStorages extends Record<string, Record<string, any>> | undefined,
Expand All @@ -948,17 +898,6 @@ export function baseGovernanceE2ETests<
},
],
},
{
kind: 'describe',
label: 'preimage tests',
children: [
{
kind: 'test',
label: 'preimage submission, query and removal works',
testFn: async () => await preimageTest(chain),
},
],
},
],
}
}
1 change: 1 addition & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from './multisig.proxy.js'
export * from './nomination-pools.js'
export * from './people.js'
export * from './postAhmFiltering.js'
export * from './preimage.js'
export * from './proxy.js'
export * from './scheduler.js'
export * from './setup.js'
Expand Down
Loading
Loading