diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2017-12-25 08:02:01 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2017-12-25 08:02:01 +0800 |
commit | 9f3acf8e2888b6105062e47664ecd5adaaf3c889 (patch) | |
tree | 2dba9c402dedee2be62bde7f5eaa21432efce0c1 /packages/connect/test | |
parent | cbf06b2165715aaadf1afb6fb84040837a7a8827 (diff) | |
download | dexon-sol-tools-9f3acf8e2888b6105062e47664ecd5adaaf3c889.tar dexon-sol-tools-9f3acf8e2888b6105062e47664ecd5adaaf3c889.tar.gz dexon-sol-tools-9f3acf8e2888b6105062e47664ecd5adaaf3c889.tar.bz2 dexon-sol-tools-9f3acf8e2888b6105062e47664ecd5adaaf3c889.tar.lz dexon-sol-tools-9f3acf8e2888b6105062e47664ecd5adaaf3c889.tar.xz dexon-sol-tools-9f3acf8e2888b6105062e47664ecd5adaaf3c889.tar.zst dexon-sol-tools-9f3acf8e2888b6105062e47664ecd5adaaf3c889.zip |
Prevent getFeesAsync method on HttpClient from mutating input
Diffstat (limited to 'packages/connect/test')
-rw-r--r-- | packages/connect/test/http_client_test.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts index 21e7abb69..db7077531 100644 --- a/packages/connect/test/http_client_test.ts +++ b/packages/connect/test/http_client_test.ts @@ -124,6 +124,18 @@ describe('HttpClient', () => { const fees = await relayerClient.getFeesAsync(request); expect(fees).to.be.deep.equal(feesResponse); }); + it('does not mutate input', async () => { + fetchMock.post(url, feesResponseJSON); + const makerTokenAmountBefore = new BigNumber(request.makerTokenAmount); + const takerTokenAmountBefore = new BigNumber(request.takerTokenAmount); + const saltBefore = new BigNumber(request.salt); + const expirationUnixTimestampSecBefore = new BigNumber(request.expirationUnixTimestampSec); + await relayerClient.getFeesAsync(request); + expect(makerTokenAmountBefore).to.be.deep.equal(request.makerTokenAmount); + expect(takerTokenAmountBefore).to.be.deep.equal(request.takerTokenAmount); + expect(saltBefore).to.be.deep.equal(request.salt); + expect(expirationUnixTimestampSecBefore).to.be.deep.equal(request.expirationUnixTimestampSec); + }); it('throws an error for invalid JSON response', async () => { fetchMock.post(url, {test: 'dummy'}); expect(relayerClient.getFeesAsync(request)).to.be.rejected(); |