Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/neat-kangaroos-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ledgerhq/coin-polkadot": minor
"@ledgerhq/live-common": minor
---

Fix Polkadot integration tests
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,21 @@ const getSendTransactionStatus: AccountBridge<
errors.amount = new AmountRequired();
}

if (!errors.amount && !transaction.useAllAmount && account.spendableBalance.isZero()) {
errors.amount = new NotEnoughBalance();
} else if (totalSpent.gt(account.spendableBalance)) {
errors.amount = new NotEnoughBalance();
}
if (!(errors.amount instanceof AmountRequired)) {
if (
(!transaction.useAllAmount && account.spendableBalance.isZero()) ||
totalSpent.gt(account.spendableBalance)
) {
errors.amount = new NotEnoughBalance();
}

if (
!errors.amount &&
account.polkadotResources?.lockedBalance.gt(0) &&
(transaction.useAllAmount || account.spendableBalance.minus(totalSpent).lt(FEES_SAFETY_BUFFER))
) {
warnings.amount = new PolkadotAllFundsWarning();
if (
account.polkadotResources?.lockedBalance.gt(0) &&
(transaction.useAllAmount ||
account.spendableBalance.minus(totalSpent).lt(FEES_SAFETY_BUFFER))
) {
warnings.amount = new PolkadotAllFundsWarning();
}
}

if (
Expand Down Expand Up @@ -299,7 +302,7 @@ export const getTransactionStatus: AccountBridge<
errors.amount = new NotEnoughBalance();
}

if (totalSpent.gt(account.spendableBalance)) {
if (!(errors.amount instanceof AmountRequired) && totalSpent.gt(account.spendableBalance)) {
errors.amount = new NotEnoughBalance();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,12 @@ const polkadot: CurrenciesData<Transaction> = {
mode: "send",
recipient: ACCOUNT_SAME_STASHCONTROLLER,
}),
expectedStatus: account => ({
expectedStatus: (_account, _transaction, status) => ({
errors: {},
warnings: {
amount: new PolkadotAllFundsWarning(),
},
totalSpent: account.spendableBalance,
totalSpent: status.estimatedFees,
}),
},
{
Expand Down
1 change: 1 addition & 0 deletions libs/ledger-live-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"test": "pnpm ci-test-unit",
"ci-test-unit": "env-cmd -f .ci.unit.env pnpm jest --ci --updateSnapshot && git diff --exit-code src",
"ci-test-integration": "env-cmd -f .ci.integration.env pnpm jest --ci --updateSnapshot --passWithNoTests",
"ci-test-integration:debug": "env-cmd -f .ci.integration.env node --inspect-wait ./node_modules/jest/bin/jest.js --runInBand --ci --updateSnapshot --passWithNoTests",
"test-bridge": "env-cmd -f .ci.bridge.env pnpm jest --ci --updateSnapshot --passWithNoTests --runInBand",
"test-bridge-update": "UPDATE_BACKEND_MOCKS=1 env-cmd -f .ci.integration.env pnpm jest --ci --updateSnapshot --passWithNoTests",
"test-account-migration": "tsx src/__tests__/migration/account-migration.ts",
Expand Down
Loading