Skip to content

Commit

Permalink
Add bridge case (#188)
Browse files Browse the repository at this point in the history
* add test case

* update

* update snap
  • Loading branch information
StrawberryFlavor authored Apr 17, 2024
1 parent 5425759 commit c952fe2
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 10 deletions.
88 changes: 88 additions & 0 deletions tests/acala/__snapshots__/homa.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,64 @@ exports[`'acala' homa > with latest block > Homa redeem unbond works > events 2`
]
`;

exports[`'acala' homa > with latest block > Homa redeem unbond works > events 3`] = `
[
{
"data": {
"allowFastMatch": false,
"liquidAmount": 1000000000000,
"redeemer": "23y3WetbNi6rDMgHmyRDjgpb7PnhgPotuPPawxruTMLYTLzG",
},
"method": "RequestedRedeem",
"section": "homa",
},
]
`;

exports[`'acala' homa > with latest block > Homa redeem unbond works > events 4`] = `
[
{
"data": {
"eraIndexWhenUnbond": 100,
"liquidAmount": 1000000000000,
"redeemer": "23y3WetbNi6rDMgHmyRDjgpb7PnhgPotuPPawxruTMLYTLzG",
"unbondingStakingAmount": "(rounded 150000000000)",
},
"method": "RedeemedByUnbond",
"section": "homa",
},
]
`;

exports[`'acala' homa > with latest block > Homa redeem unbond works > events 5`] = `
[
{
"data": {
"allowFastMatch": false,
"liquidAmount": 1000000000000,
"redeemer": "23y3WetbNi6rDMgHmyRDjgpb7PnhgPotuPPawxruTMLYTLzG",
},
"method": "RequestedRedeem",
"section": "homa",
},
]
`;

exports[`'acala' homa > with latest block > Homa redeem unbond works > events 6`] = `
[
{
"data": {
"eraIndexWhenUnbond": 100,
"liquidAmount": 1000000000000,
"redeemer": "23y3WetbNi6rDMgHmyRDjgpb7PnhgPotuPPawxruTMLYTLzG",
"unbondingStakingAmount": "(rounded 150000000000)",
},
"method": "RedeemedByUnbond",
"section": "homa",
},
]
`;

exports[`'acala' homa > with latest block > Homa redeem unbond works > system events 1`] = `
[
{
Expand Down Expand Up @@ -59,6 +117,36 @@ exports[`'acala' homa > with latest block > Homa redeem unbond works > system ev
]
`;

exports[`'acala' homa > with latest block > Homa redeem unbond works > system events 2`] = `
[
{
"data": {
"amount": "(rounded 150000000000)",
"stash": "(address)",
},
"method": "Unbonded",
"section": "staking",
},
{
"data": {
"id": "(hash)",
"origin": {
"Ump": {
"Para": 2000,
},
},
"success": true,
"weightUsed": {
"proofSize": "(rounded 66000)",
"refTime": "(rounded 6300000000)",
},
},
"method": "Processed",
"section": "messageQueue",
},
]
`;

exports[`'acala' homa > with latest block > Homa stake works > events 1`] = `
[
{
Expand Down
49 changes: 49 additions & 0 deletions tests/bridge-sdk/__snapshots__/kusama.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ exports[`'altair' to 'karura' using bridgeSDK cross-chain 'AIR' > parachain brid
}
`;

exports[`'assetHubKusama' to 'karura' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > after 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
"decimals": 6,
"fromChain": 998,
"toChain": "(rounded 2)",
}
`;

exports[`'assetHubKusama' to 'karura' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > fee 1`] = `"(rounded 0.0008)"`;

exports[`'assetHubKusama' to 'karura' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > initial 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
"decimals": 6,
"fromChain": 1000,
"toChain": 0,
}
`;

exports[`'assetHubKusama' to 'kusama' using bridgeSDK cross-chain 'KSM' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > after 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
Expand Down Expand Up @@ -80,6 +100,15 @@ exports[`'basilisk' to 'kusama' using bridgeSDK cross-chain 'KSM' > parachain br
}
`;

exports[`'basilisk' to 'kusama' using bridgeSDK cross-chain 'KSM' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > initial 2`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
"decimals": 12,
"fromChain": 1000,
"toChain": 10,
}
`;

exports[`'bifrost' to 'karura' using bridgeSDK cross-chain 'BNC' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > after 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
Expand Down Expand Up @@ -120,6 +149,26 @@ exports[`'karura' to 'altair' using bridgeSDK cross-chain 'AIR' > parachain brid
}
`;

exports[`'karura' to 'assetHubKusama' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > after 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
"decimals": 6,
"fromChain": 998,
"toChain": "(rounded 1000)",
}
`;

exports[`'karura' to 'assetHubKusama' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > fee 1`] = `"(rounded 0.007)"`;

exports[`'karura' to 'assetHubKusama' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > initial 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
"decimals": 6,
"fromChain": 1000,
"toChain": 1000,
}
`;

exports[`'karura' to 'bifrost' using bridgeSDK cross-chain 'KUSD' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > after 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
Expand Down
40 changes: 40 additions & 0 deletions tests/bridge-sdk/__snapshots__/polkadot.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`'acala' to 'assetHubPolkadot' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > after 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
"decimals": 6,
"fromChain": 998,
"toChain": "(rounded 1000)",
}
`;

exports[`'acala' to 'assetHubPolkadot' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > fee 1`] = `0`;

exports[`'acala' to 'assetHubPolkadot' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > initial 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
"decimals": 6,
"fromChain": 1000,
"toChain": 1000,
}
`;

exports[`'acala' to 'astar' using bridgeSDK cross-chain 'AUSD' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > after 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
Expand Down Expand Up @@ -80,6 +100,26 @@ exports[`'acala' to 'polkadot' using bridgeSDK cross-chain 'DOT' > parachain bri
}
`;

exports[`'assetHubPolkadot' to 'acala' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > after 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
"decimals": 6,
"fromChain": 998,
"toChain": "(rounded 2)",
}
`;

exports[`'assetHubPolkadot' to 'acala' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > fee 1`] = `"(rounded 0.0008)"`;

exports[`'assetHubPolkadot' to 'acala' using bridgeSDK cross-chain 'USDT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > initial 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
"decimals": 6,
"fromChain": 1000,
"toChain": 0,
}
`;

exports[`'assetHubPolkadot' to 'polkadot' using bridgeSDK cross-chain 'DOT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > after 1`] = `
{
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
Expand Down
20 changes: 10 additions & 10 deletions tests/bridge-sdk/kusama.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ const tests = [
to: 'assetHubKusama',
token: 'KSM',
},
{
from: 'assetHubKusama',
to: 'karura',
token: 'USDT',
},
{
from: 'karura',
to: 'assetHubKusama',
token: 'USDT',
},
{
from: 'basilisk',
to: 'karura',
Expand All @@ -57,16 +67,6 @@ const tests = [
to: 'karura',
token: 'BNC',
},
// {
// from: 'altair',
// to: 'karura',
// token: 'KUSD',
// },
// {
// from: 'karura',
// to: 'altair',
// token: 'KUSD',
// },
{
from: 'altair',
to: 'karura',
Expand Down
10 changes: 10 additions & 0 deletions tests/bridge-sdk/polkadot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ const tests = [
to: 'acala',
token: 'DOT',
},
{
from: 'acala',
to: 'assetHubPolkadot',
token: 'USDT',
},
{
from: 'assetHubPolkadot',
to: 'acala',
token: 'USDT',
},
{
from: 'polkadot',
to: 'assetHubPolkadot',
Expand Down
2 changes: 2 additions & 0 deletions tests/bridge-sdk/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const buildTests = (tests: ReadonlyArray<TestTtype>) => {
Accounts: [
[[alice.address, { Token: 'KINT' }], { free: '1000000000000000' }],
[[alice.address, { Token: 'KBTC' }], { free: 3 * 1e8 }],
[[alice.address, { ForeignAsset: 7 }], { free: 1000e6 }],
[[alice.address, { ForeignAsset: 12 }], { free: '100000000000000000000' }],
[[alice.address, { Token: 'KUSD' }], { free: 10 * 1e12 }],
],
Expand All @@ -63,6 +64,7 @@ export const buildTests = (tests: ReadonlyArray<TestTtype>) => {
[[alice.address, { ForeignAsset: 1 }], { free: 10 * 1e12 }],
[[alice.address, { ForeignAsset: 4 }], { free: 10 * 1e10 }],
[[alice.address, { ForeignAsset: 3 }], { free: 3 * 1e8 }],
[[alice.address, { ForeignAsset: 12 }], { free: 1000e6 }],
[[alice.address, { Token: 'AUSD' }], { free: 10 * 1e12 }],
],
},
Expand Down

0 comments on commit c952fe2

Please sign in to comment.