-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate XCM TS tests to Moonwall (#2441)
* progress on PoV tests * started precompile migration * finished author precompile tests * bn and callpermit precompiles done * collective precompile done * beginning conviction voting tests * Updated to moonwall4 * fix * added erc20 precompile tests * progress on local asset precompile * Added Local assets tests * modexp tests done * Added proxy tests * progress on proxy tests * finished proxy tests * updated precompile tests * added more precompile tests * progress * added more precompile tests * refactored wormhole tests * added XCM transactor tests * started xcm utils tests * Precompile tests done * done proxy tests * randomness tests * randomness tests * randomness tests * finished randomness tests * added receipt tests * staking tests * more staking tests * more staking * progress * completed staking tests * added subscription tests * added sudo tests * added treasury tests * update moonwall config * added missing conviction tests * txpool progress * tx pool tests done * CI fix * updated prettier CI * editorconfig * pnpm cache * changed CI * fix CI * changes * fix CI * fixed some tests * more test fixes * fixed tests * lint * editor config * pkg fix * updated lockfile * pkg updates * fix import * fix import * archived old-style dev-tests * lint * PR comments * Port ERC20-XCM tests. Add excess gas tests (#2410) * ERC20XCM tests * Add tsx * Moved expect out of xcm helper * Removed unused imports * removed old tests * editorconfig grr * begin xcm migration * migrate more xcm tests to moonwall using xcmv3 * removed smoke tests * Upgraded randomness smoketest * updated randomness comments * Fix conviction MaxVotes (#2401) * Reduce the ConvictionVoting MaxVotes from 512 to 30 * Set MaxVote to 20 * Run toml-sort and update repo reference (#2426) * [MOON-2434] remove deprecated leave delegator functionality (#2349) * remove leave delegator functionality * remove precompile methods * return error for removed call indices * removed scheduleLeaveDelegators calls * de-bun 🫓 the CI * fix * migrate hrmp-asset-transfer tests * apply some fixes * migrate test-mock-hrmp-transact-ethereum * small fixes * migrate test-mock-hrmp-transact * migrate more tests to moonwall * migrate test-xcmv3-new-instructions and max weight * create separate folders for v2 and v3 * migrate test-mock-hrmp-transact tests to v3 * migrate mock-hrmp-transact-ethereum tests to v3 * fix network "Any" in tests * fix order in xcmv2 tests * fix order in xcmv3 tests * remove replaceNetworkAny * prettier * fmt * fix orders * remove "Any" type from test-xcm-erc20-v3-filter * use proper GLMR constant * remove cast to any in xcmv2 tests * remove cast to any in xcmv3 tests and re-org * small fixes * add expect messages * refactor registerForeignAsset * fixes in test-mock-dmp-queue * remove BN from AssetMetadata * use proper readContract function * use proper deployContract function * remove BN from requireWeightAtMost * use sovereignAccountOfSibling helper function * remove expectOk --------- Co-authored-by: timbrinded <79199034+timbrinded@users.noreply.github.com> Co-authored-by: Francisco Gamundi <52399794+fgamundi@users.noreply.github.com> Co-authored-by: Alan Sapede <alan.sapede@gmail.com>
- Loading branch information
Showing
76 changed files
with
8,736 additions
and
56 deletions.
There are no files selected for viewing
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
80 changes: 80 additions & 0 deletions
80
test/suites/dev/test-xcm-v2/test-mock-dmp-error-and-appendix-1.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,80 @@ | ||
import "@moonbeam-network/api-augment"; | ||
import { beforeAll, describeSuite, expect, customDevRpcRequest } from "@moonwall/cli"; | ||
|
||
import { alith } from "@moonwall/util"; | ||
import { RELAY_SOURCE_LOCATION, relayAssetMetadata } from "../../../helpers/assets.js"; | ||
import { registerForeignAsset, XcmFragment } from "../../../helpers/xcm.js"; | ||
import type { XcmVersionedXcm } from "@polkadot/types/lookup"; | ||
|
||
// Twelve decimal places in the moonbase relay chain's token | ||
const RELAY_TOKEN = 1_000_000_000_000n; | ||
|
||
const palletId = "0x6D6f646c617373746d6E67720000000000000000"; | ||
|
||
describeSuite({ | ||
id: "D3401", | ||
title: "Mock XCM V3 - downward transfer with non-triggered error handler", | ||
foundationMethods: "dev", | ||
testCases: ({ context, it, log }) => { | ||
let assetId: string; | ||
|
||
beforeAll(async () => { | ||
// registerForeignAsset | ||
const { registeredAssetId, registeredAsset } = await registerForeignAsset( | ||
context, | ||
RELAY_SOURCE_LOCATION, | ||
relayAssetMetadata | ||
); | ||
assetId = registeredAssetId; | ||
expect(registeredAsset.owner.toHex()).to.eq(palletId.toLowerCase()); | ||
}); | ||
|
||
it({ | ||
id: "T01", | ||
title: "Should make sure that Alith does not receive 10 dot without error", | ||
test: async function () { | ||
const xcmMessage = new XcmFragment({ | ||
assets: [ | ||
{ | ||
multilocation: { | ||
parents: 1, | ||
interior: { | ||
Here: null, | ||
}, | ||
}, | ||
fungible: 10n * RELAY_TOKEN, | ||
}, | ||
], | ||
beneficiary: alith.address, | ||
}) | ||
.reserve_asset_deposited() | ||
.buy_execution() | ||
// BuyExecution does not charge for fees because we registered it for not doing so | ||
// But since there is no error, and the deposit is on the error handler, the assets | ||
// will be trapped | ||
.with(function () { | ||
return this.set_error_handler_with([this.deposit_asset]); | ||
}) | ||
.clear_origin() | ||
.as_v2(); | ||
|
||
const receivedMessage: XcmVersionedXcm = context | ||
.polkadotJs() | ||
.createType("XcmVersionedXcm", xcmMessage); | ||
|
||
const totalMessage = [...receivedMessage.toU8a()]; | ||
// Send RPC call to inject XCM message | ||
await customDevRpcRequest("xcm_injectDownwardMessage", [totalMessage]); | ||
|
||
// Create a block in which the XCM will be executed | ||
await context.createBlock(); | ||
// Make sure ALITH did not reveive anything | ||
const alith_dot_balance = await context | ||
.polkadotJs() | ||
.query.localAssets.account(assetId, alith.address); | ||
|
||
expect(alith_dot_balance.isNone, "Alith's DOT balance is not empty").to.be.true; | ||
}, | ||
}); | ||
}, | ||
}); |
82 changes: 82 additions & 0 deletions
82
test/suites/dev/test-xcm-v2/test-mock-dmp-error-and-appendix-2.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,82 @@ | ||
import "@moonbeam-network/api-augment"; | ||
import { beforeAll, describeSuite, expect, customDevRpcRequest } from "@moonwall/cli"; | ||
|
||
import { alith } from "@moonwall/util"; | ||
import { RELAY_SOURCE_LOCATION, relayAssetMetadata } from "../../../helpers/assets.js"; | ||
import { registerForeignAsset, XcmFragment } from "../../../helpers/xcm.js"; | ||
import type { XcmVersionedXcm } from "@polkadot/types/lookup"; | ||
|
||
// Twelve decimal places in the moonbase relay chain's token | ||
const RELAY_TOKEN = 1_000_000_000_000n; | ||
|
||
const palletId = "0x6D6f646c617373746d6E67720000000000000000"; | ||
|
||
describeSuite({ | ||
id: "D3402", | ||
title: "Mock XCM V3 - downward transfer with triggered error handler", | ||
foundationMethods: "dev", | ||
testCases: ({ context, it, log }) => { | ||
let assetId: string; | ||
|
||
beforeAll(async () => { | ||
// registerForeignAsset | ||
const { registeredAssetId, registeredAsset } = await registerForeignAsset( | ||
context, | ||
RELAY_SOURCE_LOCATION, | ||
relayAssetMetadata | ||
); | ||
assetId = registeredAssetId; | ||
expect(registeredAsset.owner.toHex()).to.eq(palletId.toLowerCase()); | ||
}); | ||
|
||
it({ | ||
id: "T01", | ||
title: "Should make sure that Alith does receive 10 dot because there is error", | ||
test: async function () { | ||
const xcmMessage = new XcmFragment({ | ||
assets: [ | ||
{ | ||
multilocation: { | ||
parents: 1, | ||
interior: { | ||
Here: null, | ||
}, | ||
}, | ||
fungible: 10n * RELAY_TOKEN, | ||
}, | ||
], | ||
beneficiary: alith.address, | ||
}) | ||
.reserve_asset_deposited() | ||
.buy_execution() | ||
// BuyExecution does not charge for fees because we registered it for not doing so | ||
// As a consequence the trapped assets will be entirely credited | ||
.with(function () { | ||
return this.set_error_handler_with([this.deposit_asset]); | ||
}) | ||
.trap() | ||
.as_v2(); | ||
|
||
const receivedMessage: XcmVersionedXcm = context | ||
.polkadotJs() | ||
.createType("XcmVersionedXcm", xcmMessage); | ||
|
||
const totalMessage = [...receivedMessage.toU8a()]; | ||
|
||
// Send RPC call to inject XCM message | ||
await customDevRpcRequest("xcm_injectDownwardMessage", [totalMessage]); | ||
|
||
// Create a block in which the XCM will be executed | ||
await context.createBlock(); | ||
// Make sure the state has ALITH's to DOT tokens | ||
const alith_dot_balance = ( | ||
await context.polkadotJs().query.assets.account(assetId, alith.address) | ||
) | ||
.unwrap() | ||
.balance.toBigInt(); | ||
|
||
expect(alith_dot_balance, "Alith's DOT balance is empty").to.eq(10n * RELAY_TOKEN); | ||
}, | ||
}); | ||
}, | ||
}); |
79 changes: 79 additions & 0 deletions
79
test/suites/dev/test-xcm-v2/test-mock-dmp-error-and-appendix-3.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,79 @@ | ||
import "@moonbeam-network/api-augment"; | ||
import { beforeAll, describeSuite, expect, customDevRpcRequest } from "@moonwall/cli"; | ||
|
||
import { alith } from "@moonwall/util"; | ||
import { RELAY_SOURCE_LOCATION, relayAssetMetadata } from "../../../helpers/assets.js"; | ||
import { registerForeignAsset, XcmFragment } from "../../../helpers/xcm.js"; | ||
import type { XcmVersionedXcm } from "@polkadot/types/lookup"; | ||
|
||
// Twelve decimal places in the moonbase relay chain's token | ||
const RELAY_TOKEN = 1_000_000_000_000n; | ||
|
||
const palletId = "0x6D6f646c617373746d6E67720000000000000000"; | ||
|
||
describeSuite({ | ||
id: "D3403", | ||
title: "Mock XCM V3 - downward transfer with always triggered appendix", | ||
foundationMethods: "dev", | ||
testCases: ({ context, it, log }) => { | ||
let assetId: string; | ||
|
||
beforeAll(async () => { | ||
// registerForeignAsset | ||
const { registeredAssetId, registeredAsset } = await registerForeignAsset( | ||
context, | ||
RELAY_SOURCE_LOCATION, | ||
relayAssetMetadata | ||
); | ||
assetId = registeredAssetId; | ||
expect(registeredAsset.owner.toHex()).to.eq(palletId.toLowerCase()); | ||
}); | ||
|
||
it({ | ||
id: "T01", | ||
title: "Should make sure Alith receives 10 dot with appendix and without error", | ||
test: async function () { | ||
const xcmMessage = new XcmFragment({ | ||
assets: [ | ||
{ | ||
multilocation: { | ||
parents: 1, | ||
interior: { | ||
Here: null, | ||
}, | ||
}, | ||
fungible: 10n * RELAY_TOKEN, | ||
}, | ||
], | ||
beneficiary: alith.address, | ||
}) | ||
.reserve_asset_deposited() | ||
.buy_execution() | ||
// Set an appendix to be executed after the XCM message is executed. No matter if errors | ||
.with(function () { | ||
return this.set_appendix_with([this.deposit_asset]); | ||
}) | ||
.as_v2(); | ||
|
||
const receivedMessage: XcmVersionedXcm = context | ||
.polkadotJs() | ||
.createType("XcmVersionedXcm", xcmMessage); | ||
|
||
const totalMessage = [...receivedMessage.toU8a()]; | ||
// Send RPC call to inject XCM message | ||
await customDevRpcRequest("xcm_injectDownwardMessage", [totalMessage]); | ||
|
||
// Create a block in which the XCM will be executed | ||
await context.createBlock(); | ||
// Make sure the state has ALITH's to DOT tokens | ||
const alith_dot_balance = ( | ||
await context.polkadotJs().query.assets.account(assetId, alith.address) | ||
) | ||
.unwrap() | ||
.balance.toBigInt(); | ||
|
||
expect(alith_dot_balance, "Alith's DOT balance is empty").to.eq(10n * RELAY_TOKEN); | ||
}, | ||
}); | ||
}, | ||
}); |
Oops, something went wrong.