-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move xcm maintenance tests to common
- Loading branch information
Showing
6 changed files
with
139 additions
and
164 deletions.
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
test/suites/common/test-maintenance/test-maintenance-mode-xcm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import "@polkadot/api-augment"; | ||
import { beforeAll, describeSuite, expect } from "@moonwall/cli"; | ||
import { KeyringPair } from "@moonwall/util"; | ||
import { ApiPromise } from "@polkadot/api"; | ||
import { initializeCustomCreateBlock } from "../../../util/block"; | ||
import { MultiLocation } from "../../../util/xcm"; | ||
|
||
describeSuite({ | ||
id: "C0101", | ||
title: "XCM in maintenance mode", | ||
foundationMethods: "dev", | ||
testCases: ({ it, context }) => { | ||
let polkadotJs: ApiPromise; | ||
let alice: KeyringPair; | ||
let chain: string; | ||
|
||
beforeAll(() => { | ||
initializeCustomCreateBlock(context); | ||
|
||
polkadotJs = context.pjsApi; | ||
chain = polkadotJs.consts.system.version.specName.toString(); | ||
alice = context.keyring.alice; | ||
}); | ||
|
||
it({ | ||
id: "E01", | ||
title: "polkadotXcm calls disabled in maintenance mode", | ||
test: async function () { | ||
const tx = polkadotJs.tx.maintenanceMode.enterMaintenanceMode(); | ||
await context.createBlock([await polkadotJs.tx.sudo.sudo(tx).signAsync(alice)]); | ||
|
||
const enabled = (await polkadotJs.query.maintenanceMode.maintenanceMode()).toJSON(); | ||
expect(enabled).to.be.true; | ||
|
||
const destMultilocation: MultiLocation = { | ||
parents: 1, | ||
interior: { Here: null }, | ||
}; | ||
|
||
const dest = { | ||
V3: destMultilocation, | ||
}; | ||
|
||
const message = { | ||
V3: [{ ClearOrigin: null }], | ||
}; | ||
|
||
const polkadotXcmSend = context.polkadotJs().tx.polkadotXcm.send(dest, message); | ||
|
||
if (chain == "frontier-template") { | ||
expect(async () => await context.createBlock(polkadotXcmSend.signAsync(alice))).rejects.toThrowError( | ||
"1010: Invalid Transaction: Transaction call is not expected" | ||
); | ||
} else { | ||
const {result} = await context.createBlock([await polkadotXcmSend.signAsync(alice)]); | ||
expect(result[0].successful).to.be.false; | ||
expect(result[0].error.name).to.eq("CallFiltered"); | ||
} | ||
}, | ||
}); | ||
|
||
it({ | ||
id: "E02", | ||
title: "polkadotXcm calls enabled with sudo in maintenance mode", | ||
test: async function () { | ||
const tx = polkadotJs.tx.maintenanceMode.enterMaintenanceMode(); | ||
await context.createBlock([await polkadotJs.tx.sudo.sudo(tx).signAsync(alice)]); | ||
|
||
const enabled = (await polkadotJs.query.maintenanceMode.maintenanceMode()).toJSON(); | ||
expect(enabled).to.be.true; | ||
|
||
const destMultilocation: MultiLocation = { | ||
parents: 1, | ||
interior: { Here: null }, | ||
}; | ||
|
||
const dest = { | ||
V3: destMultilocation, | ||
}; | ||
|
||
const message = { | ||
V3: [{ ClearOrigin: null }], | ||
}; | ||
|
||
const polkadotXcmSend = context.polkadotJs().tx.polkadotXcm.send(dest, message); | ||
|
||
const {result} = await context.createBlock([await polkadotJs.tx.sudo.sudo(polkadotXcmSend).signAsync(alice)]); | ||
|
||
// Search for ExtrinsicSuccess event | ||
const events = (await context.polkadotJs().query.system.events()).filter(({ event }) => | ||
context.polkadotJs().events.system.ExtrinsicSuccess.is(event) | ||
); | ||
expect(events.length).toBeGreaterThanOrEqual(1); | ||
expect(result[0].successful).to.be.true; | ||
expect(result[0].error).to.be.undefined; | ||
}, | ||
}); | ||
|
||
it({ | ||
id: "E03", | ||
title: "polkadotXcm calls allowed again after disabling maintenance mode", | ||
test: async function () { | ||
const tx = polkadotJs.tx.maintenanceMode.resumeNormalOperation(); | ||
await context.createBlock([await polkadotJs.tx.sudo.sudo(tx).signAsync(alice)]); | ||
|
||
const enabled = (await polkadotJs.query.maintenanceMode.maintenanceMode()).toJSON(); | ||
expect(enabled).to.be.false; | ||
|
||
const destMultilocation: MultiLocation = { | ||
parents: 1, | ||
interior: { Here: null }, | ||
}; | ||
|
||
const dest = { | ||
V3: destMultilocation, | ||
}; | ||
|
||
const message = { | ||
V3: [{ ClearOrigin: null }], | ||
}; | ||
|
||
const polkadotXcmSend = context.polkadotJs().tx.polkadotXcm.send(dest, message); | ||
const { result } = await context.createBlock([await polkadotXcmSend.signAsync(alice)]); | ||
|
||
// Search for ExtrinsicSuccess event | ||
const events = (await context.polkadotJs().query.system.events()).filter(({ event }) => | ||
context.polkadotJs().events.system.ExtrinsicSuccess.is(event) | ||
); | ||
expect(events.length).toBeGreaterThanOrEqual(1); | ||
expect(result[0].successful).to.be.true; | ||
expect(result[0].error).to.be.undefined; | ||
}, | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 0 additions & 76 deletions
76
test/suites/dev-frontier-template/test-maintenance/test-maintenance-xcm-normal-filter.ts
This file was deleted.
Oops, something went wrong.
84 changes: 0 additions & 84 deletions
84
test/suites/dev-frontier-template/test-maintenance/test-maintenance-xcm.ts
This file was deleted.
Oops, something went wrong.