aboutsummaryrefslogtreecommitdiffstats
path: root/packages/dev-utils/test/rpc_test.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-02-16 11:09:53 +0800
committerFabio Berger <me@fabioberger.com>2018-02-16 11:09:53 +0800
commite2b51c5dc46b30b21e0561689de1f9a3d0127554 (patch)
treec8f93b5700961a46b16e49e52d159c989c11102d /packages/dev-utils/test/rpc_test.ts
parentb610b7c1923dcc56883c5167393122ceaed26708 (diff)
parentb75fdd6b66a30196d53331827733b863bed770f0 (diff)
downloaddexon-sol-tools-e2b51c5dc46b30b21e0561689de1f9a3d0127554.tar
dexon-sol-tools-e2b51c5dc46b30b21e0561689de1f9a3d0127554.tar.gz
dexon-sol-tools-e2b51c5dc46b30b21e0561689de1f9a3d0127554.tar.bz2
dexon-sol-tools-e2b51c5dc46b30b21e0561689de1f9a3d0127554.tar.lz
dexon-sol-tools-e2b51c5dc46b30b21e0561689de1f9a3d0127554.tar.xz
dexon-sol-tools-e2b51c5dc46b30b21e0561689de1f9a3d0127554.tar.zst
dexon-sol-tools-e2b51c5dc46b30b21e0561689de1f9a3d0127554.zip
Merge branch 'development' of github.com:0xProject/0x.js into development
* 'development' of github.com:0xProject/0x.js: (24 commits) Rename variables Update CHANGELOG Add npm config for contracts list Run prettier Fix checks, add contract list to compile script in package.json Add contracts to compiler options Add missing public types from connect docs Change imports order Change default page params in connect to page 1 and perPage 100 Add docs staging to 0x.js package Fix a typo Add an assertion Add PR numbers Fix entry points Add tests for dev-utils package Move subproviders from dev-utils to subproviders Add missing CHANGELOG entry Add support for intersection types in docs Add stagedocs script to connect package web3 typings fix - web3.net.peerCount returns number ...
Diffstat (limited to 'packages/dev-utils/test/rpc_test.ts')
-rw-r--r--packages/dev-utils/test/rpc_test.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/packages/dev-utils/test/rpc_test.ts b/packages/dev-utils/test/rpc_test.ts
new file mode 100644
index 000000000..2f0e5ff7f
--- /dev/null
+++ b/packages/dev-utils/test/rpc_test.ts
@@ -0,0 +1,42 @@
+import { BlockParamLiteral } from '@0xproject/types';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import * as chai from 'chai';
+import 'mocha';
+
+import { RPC, web3Factory } from '../src';
+
+const expect = chai.expect;
+
+describe('RPC tests', () => {
+ const web3 = web3Factory.create();
+ const web3Wrapper = new Web3Wrapper(web3.currentProvider);
+ const rpc = new RPC();
+ describe('#mineBlockAsync', () => {
+ it('increases block number when called', async () => {
+ const blockNumberBefore = await web3Wrapper.getBlockNumberAsync();
+ await rpc.mineBlockAsync();
+ const blockNumberAfter = await web3Wrapper.getBlockNumberAsync();
+ expect(blockNumberAfter).to.be.equal(blockNumberBefore + 1);
+ });
+ });
+ describe('#increaseTimeAsync', () => {
+ it('increases time when called', async () => {
+ const TIME_DELTA = 1000;
+ const blockTimestampBefore = await web3Wrapper.getBlockTimestampAsync(BlockParamLiteral.Latest);
+ await rpc.increaseTimeAsync(TIME_DELTA);
+ await rpc.mineBlockAsync();
+ const blockTimestampAfter = await web3Wrapper.getBlockTimestampAsync(BlockParamLiteral.Latest);
+ expect(blockTimestampAfter).to.be.at.least(blockTimestampBefore + TIME_DELTA);
+ });
+ });
+ describe('#takeSnapshotAsync/revertSnapshotAsync', () => {
+ it('reverts changes in between', async () => {
+ const blockNumberBefore = await web3Wrapper.getBlockNumberAsync();
+ const snapshotId = await rpc.takeSnapshotAsync();
+ await rpc.mineBlockAsync();
+ await rpc.revertSnapshotAsync(snapshotId);
+ const blockNumberAfter = await web3Wrapper.getBlockNumberAsync();
+ expect(blockNumberAfter).to.be.equal(blockNumberBefore);
+ });
+ });
+});