Skip to content

Commit

Permalink
reduce precision
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Dec 10, 2024
1 parent 60ec2c1 commit 446969b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/bridge-sdk/__snapshots__/kusama.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ exports[`'karura' to 'bifrost' using bridgeSDK cross-chain 'KUSD' > Cross-chain
"address": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu",
"decimals": 12,
"fromChain": 8,
"toChain": "(rounded 1.84)",
"toChain": "(rounded 1.9)",
}
`;

exports[`'karura' to 'bifrost' using bridgeSDK cross-chain 'KUSD' > Cross-chain using BridgeSDK works > fee 1`] = `"(rounded 0.2)"`;
exports[`'karura' to 'bifrost' using bridgeSDK cross-chain 'KUSD' > Cross-chain using BridgeSDK works > fee 1`] = `"(rounded 0.1)"`;

exports[`'karura' to 'bifrost' using bridgeSDK cross-chain 'KUSD' > Cross-chain using BridgeSDK works > initial 1`] = `
{
Expand Down
1 change: 1 addition & 0 deletions tests/bridge-sdk/kusama.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const tests = [
from: 'karura',
to: 'bifrost',
token: 'KUSD',
precision: 2,
},
{
from: 'bifrost',
Expand Down
7 changes: 5 additions & 2 deletions tests/bridge-sdk/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ export type TestTtype = {
to: NetworkNames
token: string
ignoreFee?: boolean
precision?: number
}

export const buildTests = (tests: ReadonlyArray<TestTtype>) => {
for (const { from, to, token, ignoreFee } of tests) {
for (const { from, to, token, ignoreFee, precision } of tests) {
describe(`'${from}' to '${to}' using bridgeSDK cross-chain '${token}'`, async () => {
let fromchain: Network
let tochain: Network
Expand Down Expand Up @@ -173,7 +174,9 @@ export const buildTests = (tests: ReadonlyArray<TestTtype>) => {

await sleep(100)
const chainBalanceNow = await chainBalance(sdk, fromData, address)
await check(chainBalanceNow).redact({ number: 3 }).toMatchSnapshot('after')
await check(chainBalanceNow)
.redact({ number: precision ?? 3 })
.toMatchSnapshot('after')

//Verify if Destination Chain Transfer Fee matches the app
expect(chainBalanceNow.fromChain).not.toEqual(chainBalanceInitial.fromChain)
Expand Down

0 comments on commit 446969b

Please sign in to comment.