From 8cd2ba3ad637915ab335d87d530f754d104bbdd4 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 12 Feb 2018 18:15:14 +0100 Subject: Add tests for dev-utils package --- .../dev-utils/test/blockchain_lifecycle_test.ts | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/dev-utils/test/blockchain_lifecycle_test.ts (limited to 'packages/dev-utils/test/blockchain_lifecycle_test.ts') diff --git a/packages/dev-utils/test/blockchain_lifecycle_test.ts b/packages/dev-utils/test/blockchain_lifecycle_test.ts new file mode 100644 index 000000000..14712faa0 --- /dev/null +++ b/packages/dev-utils/test/blockchain_lifecycle_test.ts @@ -0,0 +1,25 @@ +import { BlockParamLiteral } from '@0xproject/types'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as chai from 'chai'; +import 'mocha'; + +import { BlockchainLifecycle, RPC, web3Factory } from '../src'; + +const expect = chai.expect; + +describe('BlockchainLifecycle tests', () => { + const web3 = web3Factory.create(); + const web3Wrapper = new Web3Wrapper(web3.currentProvider); + const rpc = new RPC(); + const blockchainLifecycle = new BlockchainLifecycle(); + describe('#startAsync/revertAsync', () => { + it('reverts changes in between', async () => { + const blockNumberBefore = await web3Wrapper.getBlockNumberAsync(); + await blockchainLifecycle.startAsync(); + await rpc.mineBlockAsync(); + await blockchainLifecycle.revertAsync(); + const blockNumberAfter = await web3Wrapper.getBlockNumberAsync(); + expect(blockNumberAfter).to.be.equal(blockNumberBefore); + }); + }); +}); -- cgit From 599adaf1bf2bee561530b932610f80cd1a9111ee Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 14 Feb 2018 11:53:40 -0800 Subject: Add an assertion --- packages/dev-utils/test/blockchain_lifecycle_test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'packages/dev-utils/test/blockchain_lifecycle_test.ts') diff --git a/packages/dev-utils/test/blockchain_lifecycle_test.ts b/packages/dev-utils/test/blockchain_lifecycle_test.ts index 14712faa0..4fdc53c87 100644 --- a/packages/dev-utils/test/blockchain_lifecycle_test.ts +++ b/packages/dev-utils/test/blockchain_lifecycle_test.ts @@ -17,9 +17,11 @@ describe('BlockchainLifecycle tests', () => { const blockNumberBefore = await web3Wrapper.getBlockNumberAsync(); await blockchainLifecycle.startAsync(); await rpc.mineBlockAsync(); - await blockchainLifecycle.revertAsync(); const blockNumberAfter = await web3Wrapper.getBlockNumberAsync(); - expect(blockNumberAfter).to.be.equal(blockNumberBefore); + expect(blockNumberAfter).to.be.equal(blockNumberBefore + 1); + await blockchainLifecycle.revertAsync(); + const blockNumberAfterRevert = await web3Wrapper.getBlockNumberAsync(); + expect(blockNumberAfterRevert).to.be.equal(blockNumberBefore); }); }); }); -- cgit