Skip to content

Commit

Permalink
[updated tests for estimated returns][#3]
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed May 14, 2020
1 parent 2e2dde9 commit a39fc77
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions lisk-dex-electron/src/tests/Utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,41 +41,43 @@ describe('Utils tests => ', () => {
});

test.each`
sellerAmountInLshForSell | marketPriceInLsk | estimatedReturnsInLsk | buyerOrders | estimatedStatus
${150} | ${0.78} | ${0} | ${bids} | ${EstimationStatus.NO_MATCH}
${160} | ${0.40} | ${94.5792} | ${bids} | ${EstimationStatus.MATCH}
${142} | ${0.48} | ${85.2} | ${bids} | ${EstimationStatus.MATCH}
${739.130434783} | ${0.23} | ${178.2073} | ${bids} | ${EstimationStatus.PARTIAL_MATCH}
${947.368421053} | ${0.19} | ${188.2073} | ${bids} | ${EstimationStatus.PARTIAL_MATCH}
${818.181818182} | ${0.22} | ${178.2073} | ${bids} | ${EstimationStatus.PARTIAL_MATCH}
${327.868852459} | ${0.61} | ${0} | ${bids} | ${EstimationStatus.NO_MATCH}
${457.142857143} | ${0.35} | ${154.4369} | ${bids} | ${EstimationStatus.PARTIAL_MATCH}
${1495.0166113} | ${0.602} | ${0} | ${bids} | ${EstimationStatus.NO_MATCH}
sellerAmountInLshForSell | marketPriceInLsk | estimatedReturnsInLsk | buyerOrders | estimatedStatus | amountYetToBeSold
${150} | ${0.78} | ${0} | ${bids} | ${EstimationStatus.NO_MATCH} | ${150}
${160} | ${0.40} | ${94.5792} | ${bids} | ${EstimationStatus.MATCH} | ${0}
${142} | ${0.48} | ${85.2} | ${bids} | ${EstimationStatus.MATCH} | ${0}
${739.130434783} | ${0.23} | ${178.2073} | ${bids} | ${EstimationStatus.PARTIAL_MATCH} | ${340.25151811633344}
${947.368421053} | ${0.19} | ${188.2073} | ${bids} | ${EstimationStatus.PARTIAL_MATCH} | ${498.48950438633346}
${818.181818182} | ${0.22} | ${178.2073} | ${bids} | ${EstimationStatus.PARTIAL_MATCH} | ${419.3029015153333}
${327.868852459} | ${0.61} | ${0} | ${bids} | ${EstimationStatus.NO_MATCH} | ${327.868852459}
${457.142857143} | ${0.35} | ${154.4369} | ${bids} | ${EstimationStatus.PARTIAL_MATCH} | ${147.49860714300002}
${1495.0166113} | ${0.602} | ${0} | ${bids} | ${EstimationStatus.NO_MATCH} | ${1495.0166113}
`('Should estimate best returns for {$sellerAmountInLshForSell} LSH based on {$marketPriceInLsk} LSK/LSH', ({
buyerOrders, sellerAmountInLshForSell, marketPriceInLsk, estimatedReturnsInLsk, estimatedStatus,
buyerOrders, sellerAmountInLshForSell, marketPriceInLsk, estimatedReturnsInLsk, estimatedStatus, amountYetToBeSold,
}) => {
const actualEstimatedReturnsInLsk = estimateBestReturnsForSeller(sellerAmountInLshForSell, marketPriceInLsk, buyerOrders);
expect(actualEstimatedReturnsInLsk.estimatedReturns.toFixed(4)).toBe(estimatedReturnsInLsk.toFixed(4));
expect(actualEstimatedReturnsInLsk.status).toBe(estimatedStatus);
expect(actualEstimatedReturnsInLsk.amountYetToBeSold).toBe(amountYetToBeSold);
});

test.each`
buyerAmountInLskForSell | marketPriceInLsk | estimatedLshCanBeBought | sellerOrders | estimatedStatus
${2000} | ${0.77} | ${3.1169} | ${asks} | ${EstimationStatus.PARTIAL_MATCH}
${2793.6} | ${0.96} | ${2997.1761} | ${asks} | ${EstimationStatus.MATCH}
${2821.5} | ${0.95} | ${2999.7445} | ${asks} | ${EstimationStatus.PARTIAL_MATCH}
${2845.25} | ${0.95} | ${2999.7445} | ${asks} | ${EstimationStatus.PARTIAL_MATCH}
${63.36} | ${0.88} | ${74.1392} | ${asks} | ${EstimationStatus.MATCH}
${79.2} | ${0.88} | ${86.3001} | ${asks} | ${EstimationStatus.PARTIAL_MATCH}
${76.244} | ${0.76} | ${0} | ${asks} | ${EstimationStatus.NO_MATCH}
${78} | ${0.56} | ${0} | ${asks} | ${EstimationStatus.NO_MATCH}
${974.86} | ${0.20} | ${0} | ${asks} | ${EstimationStatus.NO_MATCH}
buyerAmountInLskForSell | marketPriceInLsk | estimatedLshCanBeBought | sellerOrders | estimatedStatus | amountYetToBeSold
${2000} | ${0.77} | ${3.1169} | ${asks} | ${EstimationStatus.PARTIAL_MATCH} | ${1997.599987}
${2793.6} | ${0.96} | ${2997.1761} | ${asks} | ${EstimationStatus.MATCH} | ${0}
${2821.5} | ${0.95} | ${2999.7445} | ${asks} | ${EstimationStatus.PARTIAL_MATCH} | ${25.46005500000001}
${2845.25} | ${0.95} | ${2999.7445} | ${asks} | ${EstimationStatus.PARTIAL_MATCH} | ${49.21005500000001}
${63.36} | ${0.88} | ${74.1392} | ${asks} | ${EstimationStatus.MATCH} | ${0}
${79.2} | ${0.88} | ${86.3001} | ${asks} | ${EstimationStatus.PARTIAL_MATCH} | ${5.260015000000003}
${76.244} | ${0.76} | ${0} | ${asks} | ${EstimationStatus.NO_MATCH} | ${76.244}
${78} | ${0.56} | ${0} | ${asks} | ${EstimationStatus.NO_MATCH} | ${78}
${974.86} | ${0.20} | ${0} | ${asks} | ${EstimationStatus.NO_MATCH} | ${974.86}
`('Should estimate best returns for {$buyerAmountInLskForSell} LSK based on {$marketPriceInLsk} LSK/LSH', ({
sellerOrders, buyerAmountInLskForSell, marketPriceInLsk, estimatedLshCanBeBought, estimatedStatus,
sellerOrders, buyerAmountInLskForSell, marketPriceInLsk, estimatedLshCanBeBought, estimatedStatus, amountYetToBeSold,
}) => {
const actualLshCanBeBought = estimatedBestReturnsForBuyer(buyerAmountInLskForSell, marketPriceInLsk, sellerOrders);
expect(actualLshCanBeBought.estimatedReturns.toFixed(4)).toBe(estimatedLshCanBeBought.toFixed(4));
expect(actualLshCanBeBought.status).toBe(estimatedStatus);
expect(actualLshCanBeBought.amountYetToBeSold).toBe(amountYetToBeSold);
});

it('Should Return UI Orderbook from context orderbook', () => {
Expand Down

0 comments on commit a39fc77

Please sign in to comment.