diff options
author | Sebastian <sebasjm@gmail.com> | 2023-06-16 09:50:19 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-06-16 09:50:19 -0300 |
commit | ed01d407e7e224960337614385676dcf1ae6ca8d (patch) | |
tree | 2ad87a55c788d60be6fe01ae1a928beb00b9f98d | |
parent | b2355a3fcb5d5912ec2b4596e5d383d93564897e (diff) |
add test to compare withdrawing KUDOS:25 with demo config
-rw-r--r-- | packages/taler-wallet-core/src/util/coinSelection.test.ts | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/util/coinSelection.test.ts b/packages/taler-wallet-core/src/util/coinSelection.test.ts index 448982c7f..ab3b2c4f8 100644 --- a/packages/taler-wallet-core/src/util/coinSelection.test.ts +++ b/packages/taler-wallet-core/src/util/coinSelection.test.ts @@ -102,6 +102,28 @@ test("get raw 4", (t) => { t.assert(result.refresh === undefined); }); +test("get raw 25, diff with demo ", (t) => { + const coinList: Coin[] = [ + [kudos(0.1), 0], + [kudos(1), 0], + [kudos(2), 0], + [kudos(5), 0], + [kudos(10), 0], + ]; + const result = selectCoinForOperation( + OperationType.Credit, + kudos(25), + AmountMode.Gross, + { + list: coinList.map(([v, t]) => defaultFeeConfig(v, t)), + exchanges: {}, + }, + ); + + expect(t, result.coins).deep.equal(["KUDOS:10", "KUDOS:10", "KUDOS:5"]); + t.assert(result.refresh === undefined); +}); + test("send effective 6", (t) => { const coinList: Coin[] = [ [kudos(2), 5], @@ -246,3 +268,34 @@ test("withdraw raw 21 ", (t) => { t.deepEqual(result.rawAmount, "KUDOS:20"); t.deepEqual(result.effectiveAmount, "KUDOS:19.96"); }); + +test("withdraw raw 25, diff with demo ", (t) => { + const coinList: Coin[] = [ + [kudos(0.1), 0], + [kudos(1), 0], + [kudos(2), 0], + [kudos(5), 0], + [kudos(10), 0], + ]; + const result = calculatePlanFormAvailableCoins( + TransactionType.Withdrawal, + kudos(25), + TransactionAmountMode.Raw, + { + list: coinList.map(([v, t]) => defaultFeeConfig(v, t)), + exchanges: { + "2": { + creditDeadline: AbsoluteTime.never(), + debitDeadline: AbsoluteTime.never(), + wireFee: kudos(0.01), + purseFee: kudos(0.01), + }, + }, + }, + ); + + t.deepEqual(result.rawAmount, "KUDOS:25"); + // here demo report KUDOS:0.2 fee + // t.deepEqual(result.effectiveAmount, "KUDOS:24.80"); + t.deepEqual(result.effectiveAmount, "KUDOS:24.97"); +}); |