Skip to content

Commit

Permalink
PLMC AH transfer test
Browse files Browse the repository at this point in the history
  • Loading branch information
JuaniRios committed Feb 19, 2025
1 parent 7129d98 commit 04e7c43
Show file tree
Hide file tree
Showing 29 changed files with 9,063 additions and 110 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"macros",
"macros/tests",
"polimec-common/*",
"pallet-xcm-temp",
]
default-members = ["nodes/*", "pallets/*"]
resolver = "2"
Expand Down Expand Up @@ -247,4 +248,7 @@ cumulus-pallet-session-benchmarking = { version = "16.0.0", default-features = f
# Runtimes
polimec-runtime = { path = "runtimes/polimec" }
rococo-runtime-constants = { version = "14.0.0" }
rococo-runtime = { version = "14.0.0" }
rococo-runtime = { version = "14.0.0" }

[patch.crates-io]
pallet-xcm = { path = "pallet-xcm-temp" }
3 changes: 0 additions & 3 deletions integration-tests/chopsticks/.papi/descriptors/.gitignore

This file was deleted.

24 changes: 0 additions & 24 deletions integration-tests/chopsticks/.papi/descriptors/package.json

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 0 additions & 21 deletions integration-tests/chopsticks/.papi/polkadot-api.json

This file was deleted.

17 changes: 12 additions & 5 deletions integration-tests/chopsticks/src/managers/PolimecManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class PolimecManager extends BaseChainManager {
case Asset.WETH:
// Placeholder
return AssetSourceRelation.Self;
case Asset.PLMC:
return AssetSourceRelation.Self;
}
}

Expand All @@ -69,12 +71,17 @@ export class PolimecManager extends BaseChainManager {
return 0n;
}

async getLocalXcmFee() {
async getXcmFee() {
const api = this.getApi(Chains.Polimec);
const events = await api.event.PolkadotXcm.FeesPaid.pull();
if (!events.length) return 0n;
const fees = events[0]?.payload?.fees;
if (!fees?.length) return 0n;
return (fees[0]?.fun?.value as bigint) || 0n;
console.dir(events, { depth: null });

return events[0]?.payload.fees?.[0]?.fun?.value ?? 0n;
}

async getTransactionFee() {
const api = this.getApi(Chains.Polimec);
const events = await api.event.TransactionPayment.TransactionFeePaid.pull();
return (events[0]?.payload.actual_fee as bigint) || 0n;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class PolkadotHubManager extends BaseChainManager {
case Asset.WETH:
// This is not actually used, so we use Self as a placeholder
return AssetSourceRelation.Self;
case Asset.PLMC:
return AssetSourceRelation.Sibling;
}
}

Expand Down
1 change: 1 addition & 0 deletions integration-tests/chopsticks/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export class ChainSetup {
'wasm-override': POLIMEC_WASM,
'import-storage': polimec_storage,
'build-block-mode': BuildBlockMode.Instant,
'runtime-log-level': 5,
});
}

Expand Down
56 changes: 35 additions & 21 deletions integration-tests/chopsticks/src/tests/polimec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,47 @@ describe('Polimec -> Hub Transfer Tests', () => {
});
afterAll(async () => await chainSetup.cleanup());

test(
'Send USDC to Hub',
() =>
transferTest.testTransfer({
account: Accounts.BOB,
assets: [[Asset.USDC, TRANSFER_AMOUNTS.TOKENS, AssetSourceRelation.Sibling]],
}),
{ timeout: 25000 },
);
// test(
// 'Send USDC to Hub',
// () =>
// transferTest.testTransfer({
// account: Accounts.BOB,
// assets: [[Asset.USDC, TRANSFER_AMOUNTS.TOKENS, AssetSourceRelation.Sibling]],
// }),
// { timeout: 25000 },
// );
//
// test(
// 'Send USDT to Hub',
// () =>
// transferTest.testTransfer({
// account: Accounts.BOB,
// assets: [[Asset.USDT, TRANSFER_AMOUNTS.TOKENS, AssetSourceRelation.Sibling]],
// }),
// { timeout: 25000 },
// );

test(
'Send USDT to Hub',
() =>
transferTest.testTransfer({
account: Accounts.BOB,
assets: [[Asset.USDT, TRANSFER_AMOUNTS.TOKENS, AssetSourceRelation.Sibling]],
}),
{ timeout: 25000 },
);
// test(
// 'Send DOT to Hub',
// () =>
// transferTest.testTransfer({
// account: Accounts.BOB,
// assets: [[Asset.DOT, TRANSFER_AMOUNTS.NATIVE, AssetSourceRelation.Parent]],
// }),
// { timeout: 25000 },
// );

test(
'Send DOT to Hub',
'Send PLMC to Hub',
() =>
transferTest.testTransfer({
account: Accounts.BOB,
assets: [[Asset.DOT, TRANSFER_AMOUNTS.NATIVE, AssetSourceRelation.Parent]],
assets: [
[Asset.PLMC, TRANSFER_AMOUNTS.NATIVE, AssetSourceRelation.Self],
[Asset.DOT, TRANSFER_AMOUNTS.NATIVE, AssetSourceRelation.Parent],
],
fee_asset_item: 1,
}),
{ timeout: 25000 },
{ timeout: 25000000 },
);
});
2 changes: 2 additions & 0 deletions integration-tests/chopsticks/src/transfers/BaseTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { sleep } from 'bun';
export interface TransferOptions {
account: Accounts;
assets: [Asset, bigint, AssetSourceRelation][];
fee_asset_item?: number;
}

export abstract class BaseTransferTest {
Expand Down Expand Up @@ -63,6 +64,7 @@ export abstract class BaseTransferTest {
protected async verifyExecution() {
const events = await this.destManager.getMessageQueueEvents();

console.dir(events, { depth: null });
expect(events).not.toBeEmpty();
expect(events).toBeArray();
expect(events).toHaveLength(1);
Expand Down
Loading

0 comments on commit 04e7c43

Please sign in to comment.