summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/util/coinSelection.test.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-06-16 09:40:45 -0300
committerSebastian <sebasjm@gmail.com>2023-06-16 09:40:45 -0300
commit444c5427f41f8030b117a7d3589219abfa60bd1c (patch)
treef33b276528a0369452f25987522328b46f8f8552 /packages/taler-wallet-core/src/util/coinSelection.test.ts
parentd97f440f255966c4231c6c4923a3fff9662a58fd (diff)
downloadwallet-core-444c5427f41f8030b117a7d3589219abfa60bd1c.tar.gz
wallet-core-444c5427f41f8030b117a7d3589219abfa60bd1c.tar.bz2
wallet-core-444c5427f41f8030b117a7d3589219abfa60bd1c.zip
remove some type literal and pretty
Diffstat (limited to 'packages/taler-wallet-core/src/util/coinSelection.test.ts')
-rw-r--r--packages/taler-wallet-core/src/util/coinSelection.test.ts74
1 files changed, 51 insertions, 23 deletions
diff --git a/packages/taler-wallet-core/src/util/coinSelection.test.ts b/packages/taler-wallet-core/src/util/coinSelection.test.ts
index 7f4164aa9..448982c7f 100644
--- a/packages/taler-wallet-core/src/util/coinSelection.test.ts
+++ b/packages/taler-wallet-core/src/util/coinSelection.test.ts
@@ -15,6 +15,8 @@
*/
import test, { ExecutionContext } from "ava";
import {
+ AmountMode,
+ OperationType,
calculatePlanFormAvailableCoins,
selectCoinForOperation,
} from "./coinSelection.js";
@@ -24,6 +26,7 @@ import {
AmountJson,
Amounts,
Duration,
+ TransactionAmountMode,
TransactionType,
} from "@gnu-taler/taler-util";
@@ -67,10 +70,15 @@ test("get effective 2", (t) => {
[kudos(2), 5],
[kudos(5), 5],
];
- const result = selectCoinForOperation("credit", kudos(2), "net", {
- list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
- exchanges: {},
- });
+ const result = selectCoinForOperation(
+ OperationType.Credit,
+ kudos(2),
+ AmountMode.Net,
+ {
+ list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
+ exchanges: {},
+ },
+ );
expect(t, result.coins).deep.equal(["KUDOS:2"]);
t.assert(result.refresh === undefined);
});
@@ -80,10 +88,15 @@ test("get raw 4", (t) => {
[kudos(2), 5],
[kudos(5), 5],
];
- const result = selectCoinForOperation("credit", kudos(4), "gross", {
- list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
- exchanges: {},
- });
+ const result = selectCoinForOperation(
+ OperationType.Credit,
+ kudos(4),
+ AmountMode.Gross,
+ {
+ list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
+ exchanges: {},
+ },
+ );
expect(t, result.coins).deep.equal(["KUDOS:2", "KUDOS:2"]);
t.assert(result.refresh === undefined);
@@ -94,10 +107,15 @@ test("send effective 6", (t) => {
[kudos(2), 5],
[kudos(5), 5],
];
- const result = selectCoinForOperation("debit", kudos(6), "gross", {
- list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
- exchanges: {},
- });
+ const result = selectCoinForOperation(
+ OperationType.Debit,
+ kudos(6),
+ AmountMode.Gross,
+ {
+ list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
+ exchanges: {},
+ },
+ );
expect(t, result.coins).deep.equal(["KUDOS:5"]);
t.assert(result.refresh?.selected === "KUDOS:2");
@@ -108,10 +126,15 @@ test("send raw 6", (t) => {
[kudos(2), 5],
[kudos(5), 5],
];
- const result = selectCoinForOperation("debit", kudos(6), "gross", {
- list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
- exchanges: {},
- });
+ const result = selectCoinForOperation(
+ OperationType.Debit,
+ kudos(6),
+ AmountMode.Gross,
+ {
+ list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
+ exchanges: {},
+ },
+ );
expect(t, result.coins).deep.equal(["KUDOS:5"]);
t.assert(result.refresh?.selected === "KUDOS:2");
@@ -122,10 +145,15 @@ test("send raw 20 (not enough)", (t) => {
[kudos(2), 1],
[kudos(5), 2],
];
- const result = selectCoinForOperation("debit", kudos(20), "gross", {
- list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
- exchanges: {},
- });
+ const result = selectCoinForOperation(
+ OperationType.Debit,
+ kudos(20),
+ AmountMode.Gross,
+ {
+ list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
+ exchanges: {},
+ },
+ );
expect(t, result.coins).deep.equal(["KUDOS:5", "KUDOS:5", "KUDOS:2"]);
t.assert(result.refresh === undefined);
@@ -147,7 +175,7 @@ test("deposit effective 2 ", (t) => {
const result = calculatePlanFormAvailableCoins(
TransactionType.Deposit,
kudos(2),
- "effective",
+ TransactionAmountMode.Effective,
{
list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
exchanges: {
@@ -173,7 +201,7 @@ test("deposit raw 2 ", (t) => {
const result = calculatePlanFormAvailableCoins(
TransactionType.Deposit,
kudos(2),
- "raw",
+ TransactionAmountMode.Raw,
{
list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
exchanges: {
@@ -199,7 +227,7 @@ test("withdraw raw 21 ", (t) => {
const result = calculatePlanFormAvailableCoins(
TransactionType.Withdrawal,
kudos(21),
- "raw",
+ TransactionAmountMode.Raw,
{
list: coinList.map(([v, t]) => defaultFeeConfig(v, t)),
exchanges: {