diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-03 01:38:53 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-02 04:21:08 +0800 |
commit | 45df9de5b5b4ab6cfd4fda1b568f8109ec2c0371 (patch) | |
tree | 6c0a2fa8cf077e0df8bfdd54d0372155aba319ca /packages | |
parent | 2d0940589eb9659cea5179d5b1665ce717ecdf2e (diff) | |
download | dexon-0x-contracts-45df9de5b5b4ab6cfd4fda1b568f8109ec2c0371.tar dexon-0x-contracts-45df9de5b5b4ab6cfd4fda1b568f8109ec2c0371.tar.gz dexon-0x-contracts-45df9de5b5b4ab6cfd4fda1b568f8109ec2c0371.tar.bz2 dexon-0x-contracts-45df9de5b5b4ab6cfd4fda1b568f8109ec2c0371.tar.lz dexon-0x-contracts-45df9de5b5b4ab6cfd4fda1b568f8109ec2c0371.tar.xz dexon-0x-contracts-45df9de5b5b4ab6cfd4fda1b568f8109ec2c0371.tar.zst dexon-0x-contracts-45df9de5b5b4ab6cfd4fda1b568f8109ec2c0371.zip |
Assert that the balances don't change if arbitrage fails
Diffstat (limited to 'packages')
-rw-r--r-- | packages/contracts/test/tutorials/arbitrage.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/packages/contracts/test/tutorials/arbitrage.ts b/packages/contracts/test/tutorials/arbitrage.ts index b2f1c338a..68b8f555e 100644 --- a/packages/contracts/test/tutorials/arbitrage.ts +++ b/packages/contracts/test/tutorials/arbitrage.ts @@ -22,7 +22,7 @@ const web3 = web3Factory.create(); const web3Wrapper = new Web3Wrapper(web3.currentProvider); const blockchainLifecycle = new BlockchainLifecycle(); -describe.only('Arbitrage', () => { +describe('Arbitrage', () => { let coinbase: string; let maker: string; let edMaker: string; @@ -177,13 +177,14 @@ describe.only('Arbitrage', () => { r = [order.params.r as string, edSignature.r]; s = [order.params.s as string, edSignature.s]; }); - it('1', async () => { + it('should successfully execute the arbitrage if not front-runner', async () => { const txHash = await arbitrage.makeAtomicTrade(addresses, values, v, r, s, { from: coinbase }); const res = await zeroEx.awaitTransactionMinedAsync(txHash); const postBalance = await weth.balanceOf(arbitrage.address); expect(postBalance).to.be.bignumber.equal(ZeroEx.toBaseUnitAmount(new BigNumber(2), 18)); }); - it('2', async () => { + it('should fail and revert if front-runned', async () => { + const preBalance = await weth.balanceOf(arbitrage.address); // Front-running transaction await etherDelta.trade( tokenGet, @@ -199,9 +200,11 @@ describe.only('Arbitrage', () => { ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), { from: edFrontRunner }, ); - return expect(arbitrage.makeAtomicTrade(addresses, values, v, r, s, { from: coinbase })).to.be.rejectedWith( + await expect(arbitrage.makeAtomicTrade(addresses, values, v, r, s, { from: coinbase })).to.be.rejectedWith( constants.REVERT, ); + const postBalance = await weth.balanceOf(arbitrage.address); + expect(preBalance).to.be.bignumber.equal(postBalance); }); }); }); |