blob: 4fdc53c87b03e95b5f672d31e068df7a037729ca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
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();
const blockNumberAfter = await web3Wrapper.getBlockNumberAsync();
expect(blockNumberAfter).to.be.equal(blockNumberBefore + 1);
await blockchainLifecycle.revertAsync();
const blockNumberAfterRevert = await web3Wrapper.getBlockNumberAsync();
expect(blockNumberAfterRevert).to.be.equal(blockNumberBefore);
});
});
});
|