add test to compare withdrawing KUDOS:25 with demo config

This commit is contained in:
Sebastian 2023-06-16 09:50:19 -03:00
parent b2355a3fcb
commit ed01d407e7
No known key found for this signature in database
GPG Key ID: 173909D1A5F66069

View File

@ -102,6 +102,28 @@ test("get raw 4", (t) => {
t.assert(result.refresh === undefined); 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) => { test("send effective 6", (t) => {
const coinList: Coin[] = [ const coinList: Coin[] = [
[kudos(2), 5], [kudos(2), 5],
@ -246,3 +268,34 @@ test("withdraw raw 21 ", (t) => {
t.deepEqual(result.rawAmount, "KUDOS:20"); t.deepEqual(result.rawAmount, "KUDOS:20");
t.deepEqual(result.effectiveAmount, "KUDOS:19.96"); 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");
});