@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
39 lines • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
require("../test-helpers/staticTime");
const account_1 = require("../../mock/account");
const portfolio_1 = require("@ledgerhq/live-countervalues/portfolio");
const live_env_1 = require("@ledgerhq/live-env");
const currencies_1 = require("../../currencies");
(0, currencies_1.setSupportedCurrencies)(["ethereum", "ethereum_classic", "ripple"]);
test("generate an account from seed", () => {
const a = (0, account_1.genAccount)("seed");
const b = (0, account_1.genAccount)("seed");
expect(a).toEqual(b);
});
test("generate an account from different seed should generate a different account", () => {
const a = (0, account_1.genAccount)((0, live_env_1.getEnv)("MOCK"));
(0, live_env_1.setEnv)("MOCK", "çacestvraiça");
const b = (0, account_1.genAccount)((0, live_env_1.getEnv)("MOCK"));
expect(a).not.toEqual(b);
});
test("dont generate negative balance", () => {
const a = (0, account_1.genAccount)("n"); // <= with just prando, this seed generates negative balance
expect(a.balance.isNegative()).toBe(false);
});
test("allow specifying number of operations", () => {
const a = (0, account_1.genAccount)("n", {
operationsSize: 10,
});
expect(a.operations.length).toBe(10);
});
// NB we can't guarantee that. bug in implementation because JS Numbers
test("mock generators don't generate negative balances", () => {
for (let i = 0; i < 100; i++) {
const account = (0, account_1.genAccount)("negative?" + i);
const history = (0, portfolio_1.getBalanceHistory)(account, "year", 300);
const invalidDataPoints = history.filter(h => h.value < 0);
expect(invalidDataPoints).toMatchObject([]);
}
});
//# sourceMappingURL=account.js.map