Skip to content

Commit

Permalink
fix cosmos delegation flaky e2e test due to rounding error
Browse files Browse the repository at this point in the history
  • Loading branch information
Wozacosta committed Sep 9, 2024
1 parent e80de5f commit 67c0154
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/ledger-live-mobile/e2e/specs/delegate/cosmos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "../../models/currencies";
import { Application } from "../../page";
import DeviceAction from "../../models/DeviceAction";
import BigNumber from "bignumber.js";

let app: Application;
let deviceAction: DeviceAction;
Expand Down Expand Up @@ -37,7 +38,12 @@ describe("Cosmos delegate flow", () => {
const unit = getAccountUnit(testAccount);

const usableAmount = testAccount.spendableBalance.minus(COSMOS_MIN_SAFE).minus(COSMOS_MIN_FEES);
const delegatedAmount = usableAmount.div(100 / delegatedPercent).integerValue();
// rounding to avoid floating point errors
// NOTE: we could allow for some precision error here to avoid rounding issues
const delegatedAmount = usableAmount
.multipliedBy(delegatedPercent)
.div(100)
.integerValue(BigNumber.ROUND_CEIL);
const remainingAmount = usableAmount.minus(delegatedAmount);

await app.stake.selectCurrency(testedCurrency);
Expand Down

0 comments on commit 67c0154

Please sign in to comment.