Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(xcm test): hooks for Astar\Shiden #1005

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pallets/evm-transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ impl<T: Config> OnCheckEvmTransaction<T> for TransactionValidity<T> {
.saturating_mul(v.transaction.gas_limit);
if let Some(sponsor) = sponsor.as_ref() {
if who.balance < v.transaction.value || sponsor.balance < fee {
return Err(TransactionValidationError::BalanceTooLow.into());
return Err(TransactionValidationError::BalanceTooLow);
}
} else {
let total_payment = v.transaction.value.saturating_add(fee);
if who.balance < total_payment {
return Err(TransactionValidationError::BalanceTooLow.into());
return Err(TransactionValidationError::BalanceTooLow);
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/src/util/playgrounds/unique.xcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ export class AssetsGroup<T extends ChainHelperBase> extends HelperGroup<T> {
await this.helper.executeExtrinsic(signer, 'api.tx.assets.create', [assetId, admin, minimalBalance], true);
}

async forceCreate(signer: TSigner, assetId: number | bigint, admin: string, minimalBalance: bigint, isSufficient = true) {
await this.helper.executeExtrinsic(signer, 'api.tx.assets.forceCreate', [assetId, admin, isSufficient, minimalBalance], true);
}

async setMetadata(signer: TSigner, assetId: number | bigint, name: string, symbol: string, decimals: number) {
await this.helper.executeExtrinsic(signer, 'api.tx.assets.setMetadata', [assetId, name, symbol, decimals], true);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/xcm/lowLevelXcmQuartz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ describeXCM('[XCMLL] Integration test: Exchanging tokens with Shiden', () => {
await usingShidenPlaygrounds(shidenUrl, async (helper) => {
if(!(await helper.callRpc('api.query.assets.asset', [QTZ_ASSET_ID_ON_SHIDEN])).toJSON()) {
console.log('1. Create foreign asset and metadata');
await helper.assets.create(
await helper.getSudo().assets.forceCreate(
alice,
QTZ_ASSET_ID_ON_SHIDEN,
alice.address,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/xcm/lowLevelXcmUnique.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ describeXCM('[XCMLL] Integration test: Exchanging tokens with Astar', () => {
await usingAstarPlaygrounds(astarUrl, async (helper) => {
if(!(await helper.callRpc('api.query.assets.asset', [UNQ_ASSET_ID_ON_ASTAR])).toJSON()) {
console.log('1. Create foreign asset and metadata');
await helper.assets.create(
await helper.getSudo().assets.forceCreate(
alice,
UNQ_ASSET_ID_ON_ASTAR,
alice.address,
Expand Down
6 changes: 3 additions & 3 deletions tests/src/xcm/xcmQuartz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1290,11 +1290,11 @@ describeXCM('[XCM] Integration test: Exchanging tokens with Shiden', () => {
const shidenInitialBalance = 1n * (10n ** SHIDEN_DECIMALS); // 1 SHD, existential deposit required to actually create the account on Shiden
const unitsPerSecond = 500_451_000_000_000_000_000n; // The value is taken from the live Shiden
const qtzToShidenTransferred = 10n * (10n ** QTZ_DECIMALS); // 10 QTZ
const qtzToShidenArrived = 9_999_999_999_088_000_000n; // 9.999 ... QTZ, Shiden takes a commision in foreign tokens
const qtzToShidenArrived = 7_998_196_000_000_000_000n; // 7.99 ... QTZ, Shiden takes a commision in foreign tokens

// Shiden -> Quartz
const qtzFromShidenTransfered = 5n * (10n ** QTZ_DECIMALS); // 5 QTZ
const qtzOnShidenLeft = qtzToShidenArrived - qtzFromShidenTransfered; // 4.999_999_999_088_000_000n QTZ
const qtzOnShidenLeft = qtzToShidenArrived - qtzFromShidenTransfered; // 2.99 ... QTZ

let balanceAfterQuartzToShidenXCM: bigint;

Expand All @@ -1311,7 +1311,7 @@ describeXCM('[XCM] Integration test: Exchanging tokens with Shiden', () => {
await usingShidenPlaygrounds(shidenUrl, async (helper) => {
if(!(await helper.callRpc('api.query.assets.asset', [QTZ_ASSET_ID_ON_SHIDEN])).toJSON()) {
console.log('1. Create foreign asset and metadata');
await helper.assets.create(
await helper.getSudo().assets.forceCreate(
alice,
QTZ_ASSET_ID_ON_SHIDEN,
alice.address,
Expand Down
6 changes: 3 additions & 3 deletions tests/src/xcm/xcmUnique.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1518,11 +1518,11 @@ describeXCM('[XCM] Integration test: Exchanging tokens with Astar', () => {
const astarInitialBalance = 1n * (10n ** ASTAR_DECIMALS); // 1 ASTR, existential deposit required to actually create the account on Astar.
const unitsPerSecond = 9_451_000_000_000_000_000n; // The value is taken from the live Astar
const unqToAstarTransferred = 10n * (10n ** UNQ_DECIMALS); // 10 UNQ
const unqToAstarArrived = 9_999_999_999_088_000_000n; // 9.999 ... UNQ, Astar takes a commision in foreign tokens
const unqToAstarArrived = 9_962_196_000_000_000_000n; // 9.962 ... UNQ, Astar takes a commision in foreign tokens

// Astar -> Unique
const unqFromAstarTransfered = 5n * (10n ** UNQ_DECIMALS); // 5 UNQ
const unqOnAstarLeft = unqToAstarArrived - unqFromAstarTransfered; // 4.999_999_999_088_000_000n UNQ
const unqOnAstarLeft = unqToAstarArrived - unqFromAstarTransfered; // 4.962_219_600_000_000_000n UNQ

let balanceAfterUniqueToAstarXCM: bigint;

Expand All @@ -1539,7 +1539,7 @@ describeXCM('[XCM] Integration test: Exchanging tokens with Astar', () => {
await usingAstarPlaygrounds(astarUrl, async (helper) => {
if(!(await helper.callRpc('api.query.assets.asset', [UNQ_ASSET_ID_ON_ASTAR])).toJSON()) {
console.log('1. Create foreign asset and metadata');
await helper.assets.create(
await helper.getSudo().assets.forceCreate(
alice,
UNQ_ASSET_ID_ON_ASTAR,
alice.address,
Expand Down