From 85de0a9350406627b2678be3ae803f28ab209e67 Mon Sep 17 00:00:00 2001 From: Diego Date: Mon, 23 Dec 2024 18:46:51 -0300 Subject: [PATCH 1/3] Fix tests --- .../tanssi-relay-service/src/dev_service.rs | 5 +-- .../xcm/test-xcm-send-upward.ts | 38 ++++++++++--------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/solo-chains/node/tanssi-relay-service/src/dev_service.rs b/solo-chains/node/tanssi-relay-service/src/dev_service.rs index 3707a712c..4409125f5 100644 --- a/solo-chains/node/tanssi-relay-service/src/dev_service.rs +++ b/solo-chains/node/tanssi-relay-service/src/dev_service.rs @@ -401,10 +401,7 @@ where client .get_aux(XMC_UPM_SELECTOR_AUX_KEY) .expect("Should be able to query aux storage; qed") - .map(|upm_message| { - log::info!("upm message read from kvs {:?}", upm_message); - upm_messages.force_push(upm_message) - }); + .map(|upm_message| upm_messages.force_push(upm_message)); // generate a candidate with most of the values mocked let candidate = CommittedCandidateReceipt:: { diff --git a/test/suites/dev-tanssi-relay/xcm/test-xcm-send-upward.ts b/test/suites/dev-tanssi-relay/xcm/test-xcm-send-upward.ts index d68f35096..fa0a6bd58 100644 --- a/test/suites/dev-tanssi-relay/xcm/test-xcm-send-upward.ts +++ b/test/suites/dev-tanssi-relay/xcm/test-xcm-send-upward.ts @@ -3,7 +3,8 @@ import { KeyringPair } from "@moonwall/util"; import { ApiPromise, Keyring } from "@polkadot/api"; import { u8aToHex } from "@polkadot/util"; import { jumpToSession } from "util/block"; -import { RawXcmMessage, XcmFragment, injectUmpMessageAndSeal } from "../../../util/xcm"; +import { injectUmpMessageAndSeal, RawXcmMessage, XcmFragment } from "../../../util/xcm"; + describeSuite({ id: "DTR1003", @@ -27,7 +28,7 @@ describeSuite({ id: "T01", title: "Should succeed receiving tokens", test: async function () { - // XCM message sending reserved assets to alice + // Basic xcm message const xcmMessage = new XcmFragment({ assets: [ { @@ -40,32 +41,35 @@ describeSuite({ ], beneficiary: u8aToHex(alice.addressRaw), }) - .reserve_asset_deposited() - .clear_origin() - .buy_execution() - .deposit_asset() - .as_v3(); + .withdraw_asset() + .clear_origin() + .as_v3(); + // Enable para inherent to process xcm message await customDevRpcRequest("mock_enableParaInherentCandidate", []); - // Send an XCM and create block to execute it + // Send ump message await injectUmpMessageAndSeal(context, { type: "XcmVersionedXcm", payload: xcmMessage, } as RawXcmMessage); + // Wait until message is processed await jumpToSession(context, 3); - - // Create a block in which the XCM will be executed await context.createBlock(); - // Make sure the state has alice's to DOT tokens - const alice_dot_balance = (await context.polkadotJs().query.foreignAssets.account(1, alice.address)) - .unwrap() - .balance.toBigInt(); - expect(alice_dot_balance > 0n).to.be.true; - // we should expect to have received less than the amount transferred - expect(alice_dot_balance < transferredBalance).to.be.true; + // Check message was processed ok + const events = await polkadotJs.query.system.events(); + + const xcmEvent = events.find((event) => { + console.log("Event", event) + + + return event.event.section === 'xcmpQueue' && + event.event.method === 'Success' + }); + + expect(xcmEvent).to.not.be.undefined; }, }); }, From fb92948bfac1bc18a9fa08451d68d1c54b6e6414 Mon Sep 17 00:00:00 2001 From: Diego Date: Mon, 23 Dec 2024 19:27:47 -0300 Subject: [PATCH 2/3] Improve xcm ump dancelight test --- .../xcm/test-xcm-send-upward.ts | 42 +++++-------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/test/suites/dev-tanssi-relay/xcm/test-xcm-send-upward.ts b/test/suites/dev-tanssi-relay/xcm/test-xcm-send-upward.ts index fa0a6bd58..ae8b154d8 100644 --- a/test/suites/dev-tanssi-relay/xcm/test-xcm-send-upward.ts +++ b/test/suites/dev-tanssi-relay/xcm/test-xcm-send-upward.ts @@ -1,7 +1,5 @@ -import { beforeAll, customDevRpcRequest, describeSuite, expect } from "@moonwall/cli"; -import { KeyringPair } from "@moonwall/util"; -import { ApiPromise, Keyring } from "@polkadot/api"; -import { u8aToHex } from "@polkadot/util"; +import { beforeAll, customDevRpcRequest, describeSuite } from "@moonwall/cli"; +import { ApiPromise } from "@polkadot/api"; import { jumpToSession } from "util/block"; import { injectUmpMessageAndSeal, RawXcmMessage, XcmFragment } from "../../../util/xcm"; @@ -12,16 +10,9 @@ describeSuite({ foundationMethods: "dev", testCases: ({ context, it }) => { let polkadotJs: ApiPromise; - let alice: KeyringPair; - let transferredBalance; beforeAll(async function () { polkadotJs = context.polkadotJs(); - alice = new Keyring({ type: "sr25519" }).addFromUri("//Alice", { - name: "Alice default", - }); - - transferredBalance = 10_000_000_000_000n; }); it({ @@ -30,20 +21,10 @@ describeSuite({ test: async function () { // Basic xcm message const xcmMessage = new XcmFragment({ - assets: [ - { - multilocation: { - parents: 0, - interior: { Here: null }, - }, - fungible: transferredBalance, - }, - ], - beneficiary: u8aToHex(alice.addressRaw), + assets: [], }) - .withdraw_asset() - .clear_origin() - .as_v3(); + .clear_origin() + .as_v3(); // Enable para inherent to process xcm message await customDevRpcRequest("mock_enableParaInherentCandidate", []); @@ -59,17 +40,14 @@ describeSuite({ await context.createBlock(); // Check message was processed ok - const events = await polkadotJs.query.system.events(); - - const xcmEvent = events.find((event) => { - console.log("Event", event) - + const events = await polkadotJs.query.system.events() - return event.event.section === 'xcmpQueue' && - event.event.method === 'Success' + const processedEvent = events.find((event) => { + return event.event.section === 'messageQueue' && + event.event.method === 'Processed' }); - expect(xcmEvent).to.not.be.undefined; + expect(processedEvent).to.not.be.undefined; }, }); }, From 3a97c2e903a12058ba2e40447351009b3bcadd9b Mon Sep 17 00:00:00 2001 From: Diego Date: Mon, 23 Dec 2024 19:33:10 -0300 Subject: [PATCH 3/3] Clippy is not complaining anymore :D --- solo-chains/node/tanssi-relay-service/src/dev_service.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/solo-chains/node/tanssi-relay-service/src/dev_service.rs b/solo-chains/node/tanssi-relay-service/src/dev_service.rs index 4409125f5..589f049f6 100644 --- a/solo-chains/node/tanssi-relay-service/src/dev_service.rs +++ b/solo-chains/node/tanssi-relay-service/src/dev_service.rs @@ -398,10 +398,12 @@ where let mut upm_messages = UpwardMessages::new(); - client + if let Some(upm_message) = client .get_aux(XMC_UPM_SELECTOR_AUX_KEY) .expect("Should be able to query aux storage; qed") - .map(|upm_message| upm_messages.force_push(upm_message)); + { + upm_messages.force_push(upm_message); + } // generate a candidate with most of the values mocked let candidate = CommittedCandidateReceipt:: {