Skip to content

Commit

Permalink
test: ✅ remove unused XCM v2 compatibility function deposit_asset in …
Browse files Browse the repository at this point in the history
…TS tests
  • Loading branch information
manuelmauro committed Jan 15, 2025
1 parent f293e8d commit 36fc806
Show file tree
Hide file tree
Showing 37 changed files with 41 additions and 59 deletions.
20 changes: 1 addition & 19 deletions test/helpers/xcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,25 +348,7 @@ export class XcmFragment {
}

// Add a `DepositAsset` instruction
deposit_asset(max_assets = 1n, network: "Any" | XcmV3JunctionNetworkId["type"] = "Any"): this {
if (this.config.beneficiary == null) {
console.warn("!Building a DepositAsset instruction without a configured beneficiary");
}
this.instructions.push({
DepositAsset: {
assets: { Wild: "All" },
maxAssets: max_assets,
beneficiary: {
parents: 0,
interior: { X1: { AccountKey20: { network, key: this.config.beneficiary } } },
},
},
});
return this;
}

// Add a `DepositAsset` instruction for xcm v3
deposit_asset_v3(max_assets = 1n, network: XcmV3JunctionNetworkId["type"] | null = null): this {
deposit_asset(max_assets = 1n, network: XcmV3JunctionNetworkId["type"] | null = null): this {
if (this.config.beneficiary == null) {
console.warn("!Building a DepositAsset instruction without a configured beneficiary");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// 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_v3]);
return this.set_error_handler_with([this.deposit_asset]);
})
.clear_origin()
.as_v3();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describeSuite({
// 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_v3]);
return this.set_error_handler_with([this.deposit_asset]);
})
.trap()
.as_v3();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describeSuite({
.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_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.as_v3();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// As a consequence the trapped assets will be entirely credited
// The goal is to show appendix runs even if there is an error
.with(function () {
return this.set_appendix_with([this.deposit_asset_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.trap()
.as_v3();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// As a consequence the trapped assets will be entirely credited
// The goal is to show appendix runs even if there is an error
.with(function () {
return this.set_appendix_with([this.deposit_asset_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.trap()
.as_v3();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describeSuite({
.claim_asset()
.buy_execution()
// Deposit assets, this time correctly, on Alith
.deposit_asset_v3()
.deposit_asset()
.as_v3();

const receivedMessage: XcmVersionedXcm = context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

const chargedWeight = await weightMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution(1) // buy execution with asset at index 1
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3()
) as any
);
Expand All @@ -114,7 +114,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Mock the reception of the xcm message
Expand Down Expand Up @@ -258,7 +258,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Mock the reception of the xcm message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Mock the reception of the xcm message
Expand Down Expand Up @@ -254,7 +254,7 @@ describeSuite({
const xcmMessageToClaimAssets = new XcmFragment(claimConfig)
.claim_asset()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

const balanceBefore = (
Expand Down Expand Up @@ -325,7 +325,7 @@ describeSuite({
const xcmMessageFailedClaim = new XcmFragment(failedClaimConfig)
.claim_asset()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

await injectHrmpMessageAndSeal(context, paraId, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(limit)
.deposit_asset(limit)
.as_v3(),
});

Expand Down
2 changes: 1 addition & 1 deletion test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Mock the reception of the xcm message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

// Inject an XCM message that should be included in the next block but not executed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// 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_v3]);
return this.set_error_handler_with([this.deposit_asset]);
})
.clear_origin()
.as_v4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describeSuite({
// 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_v3]);
return this.set_error_handler_with([this.deposit_asset]);
})
.trap()
.as_v4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describeSuite({
.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_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.as_v4();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// As a consequence the trapped assets will be entirely credited
// The goal is to show appendix runs even if there is an error
.with(function () {
return this.set_appendix_with([this.deposit_asset_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.trap()
.as_v4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// As a consequence the trapped assets will be entirely credited
// The goal is to show appendix runs even if there is an error
.with(function () {
return this.set_appendix_with([this.deposit_asset_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.trap()
.as_v4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describeSuite({
.claim_asset()
.buy_execution()
// Deposit assets, this time correctly, on Alith
.deposit_asset_v3()
.deposit_asset()
.as_v4();

const receivedMessage: XcmVersionedXcm = context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

const chargedWeight = await weightMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution(1) // buy execution with asset at index 1
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v4();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v4();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

const dryRunXcm = await polkadotJs.call.dryRunApi.dryRunXcm(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(3n)
.deposit_asset(3n)
.as_v4();

// Mock the reception of the xcm message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v4();

// Mock the reception of the xcm message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

const chargedWeight = await weightMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

const chargedWeight = await weightMessage(
Expand Down
2 changes: 1 addition & 1 deletion test/suites/tracing-tests/test-trace-erc20-xcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Mock the reception of the xcm message
Expand Down

0 comments on commit 36fc806

Please sign in to comment.