Skip to content

Commit f6aa475

Browse files
Merge pull request #11351 from LedgerHQ/chore/LIVE-20918
chore/LIVE-20918 fix Polkadot integration tests
2 parents 8e273b3 + 5d3353e commit f6aa475

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

.changeset/neat-kangaroos-nail.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@ledgerhq/coin-polkadot": minor
3+
"@ledgerhq/live-common": minor
4+
---
5+
6+
Fix Polkadot integration tests

libs/coin-modules/coin-polkadot/src/bridge/getTransactionStatus.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,21 @@ const getSendTransactionStatus: AccountBridge<
7373
errors.amount = new AmountRequired();
7474
}
7575

76-
if (!errors.amount && !transaction.useAllAmount && account.spendableBalance.isZero()) {
77-
errors.amount = new NotEnoughBalance();
78-
} else if (totalSpent.gt(account.spendableBalance)) {
79-
errors.amount = new NotEnoughBalance();
80-
}
76+
if (!(errors.amount instanceof AmountRequired)) {
77+
if (
78+
(!transaction.useAllAmount && account.spendableBalance.isZero()) ||
79+
totalSpent.gt(account.spendableBalance)
80+
) {
81+
errors.amount = new NotEnoughBalance();
82+
}
8183

82-
if (
83-
!errors.amount &&
84-
account.polkadotResources?.lockedBalance.gt(0) &&
85-
(transaction.useAllAmount || account.spendableBalance.minus(totalSpent).lt(FEES_SAFETY_BUFFER))
86-
) {
87-
warnings.amount = new PolkadotAllFundsWarning();
84+
if (
85+
account.polkadotResources?.lockedBalance.gt(0) &&
86+
(transaction.useAllAmount ||
87+
account.spendableBalance.minus(totalSpent).lt(FEES_SAFETY_BUFFER))
88+
) {
89+
warnings.amount = new PolkadotAllFundsWarning();
90+
}
8891
}
8992

9093
if (
@@ -299,7 +302,7 @@ export const getTransactionStatus: AccountBridge<
299302
errors.amount = new NotEnoughBalance();
300303
}
301304

302-
if (totalSpent.gt(account.spendableBalance)) {
305+
if (!(errors.amount instanceof AmountRequired) && totalSpent.gt(account.spendableBalance)) {
303306
errors.amount = new NotEnoughBalance();
304307
}
305308

libs/coin-modules/coin-polkadot/src/test/bridgeDatasetTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,12 @@ const polkadot: CurrenciesData<Transaction> = {
380380
mode: "send",
381381
recipient: ACCOUNT_SAME_STASHCONTROLLER,
382382
}),
383-
expectedStatus: account => ({
383+
expectedStatus: (_account, _transaction, status) => ({
384384
errors: {},
385385
warnings: {
386386
amount: new PolkadotAllFundsWarning(),
387387
},
388-
totalSpent: account.spendableBalance,
388+
totalSpent: status.estimatedFees,
389389
}),
390390
},
391391
{

libs/ledger-live-common/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"test": "pnpm ci-test-unit",
7777
"ci-test-unit": "env-cmd -f .ci.unit.env pnpm jest --ci --updateSnapshot && git diff --exit-code src",
7878
"ci-test-integration": "env-cmd -f .ci.integration.env pnpm jest --ci --updateSnapshot --passWithNoTests",
79+
"ci-test-integration:debug": "env-cmd -f .ci.integration.env node --inspect-wait ./node_modules/jest/bin/jest.js --runInBand --ci --updateSnapshot --passWithNoTests",
7980
"test-bridge": "env-cmd -f .ci.bridge.env pnpm jest --ci --updateSnapshot --passWithNoTests --runInBand",
8081
"test-bridge-update": "UPDATE_BACKEND_MOCKS=1 env-cmd -f .ci.integration.env pnpm jest --ci --updateSnapshot --passWithNoTests",
8182
"test-account-migration": "tsx src/__tests__/migration/account-migration.ts",

0 commit comments

Comments
 (0)