diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-03 21:19:38 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-04 16:56:32 +0800 |
commit | 249bf0163d8ee71b7329fd58b72e554c0324279c (patch) | |
tree | 5bfb30b082236bd089e35186220bdb02913ba128 /packages/web3-wrapper/test | |
parent | 674e56cea69fe96ddd0071d3c4c5b5ea8ae299bf (diff) | |
download | dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar.gz dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar.bz2 dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar.lz dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar.xz dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.tar.zst dexon-sol-tools-249bf0163d8ee71b7329fd58b72e554c0324279c.zip |
Move our contract templates to accept Provider instead of Web3Wrapper
Diffstat (limited to 'packages/web3-wrapper/test')
-rw-r--r-- | packages/web3-wrapper/test/utils/chai_setup.ts | 13 | ||||
-rw-r--r-- | packages/web3-wrapper/test/web3_wrapper_test.ts | 39 |
2 files changed, 52 insertions, 0 deletions
diff --git a/packages/web3-wrapper/test/utils/chai_setup.ts b/packages/web3-wrapper/test/utils/chai_setup.ts new file mode 100644 index 000000000..078edd309 --- /dev/null +++ b/packages/web3-wrapper/test/utils/chai_setup.ts @@ -0,0 +1,13 @@ +import * as chai from 'chai'; +import chaiAsPromised = require('chai-as-promised'); +import ChaiBigNumber = require('chai-bignumber'); +import * as dirtyChai from 'dirty-chai'; + +export const chaiSetup = { + configure() { + chai.config.includeStack = true; + chai.use(ChaiBigNumber()); + chai.use(dirtyChai); + chai.use(chaiAsPromised); + }, +}; diff --git a/packages/web3-wrapper/test/web3_wrapper_test.ts b/packages/web3-wrapper/test/web3_wrapper_test.ts new file mode 100644 index 000000000..2bf3badaa --- /dev/null +++ b/packages/web3-wrapper/test/web3_wrapper_test.ts @@ -0,0 +1,39 @@ +import * as chai from 'chai'; +import * as Ganache from 'ganache-core'; +import 'mocha'; + +import { Web3Wrapper } from '../src'; + +import { chaiSetup } from './utils/chai_setup'; +chaiSetup.configure(); + +const { expect } = chai; + +describe('Web3Wrapper tests', () => { + const NETWORK_ID = 50; + const provider = Ganache.provider({ network_id: NETWORK_ID }); + const web3Wrapper = new Web3Wrapper(provider); + describe('#isAddress', () => { + it('correctly checks if a string is a valid ethereum address', () => { + expect(Web3Wrapper.isAddress('0x0')).to.be.false(); + expect(Web3Wrapper.isAddress('0xdeadbeef')).to.be.false(); + expect(Web3Wrapper.isAddress('42')).to.be.false(); + expect(Web3Wrapper.isAddress('weth.thetoken.eth')).to.be.false(); + expect(Web3Wrapper.isAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2')).to.be.true(); + expect(Web3Wrapper.isAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')).to.be.true(); + }); + }); + describe('#getNodeVersionAsync', () => { + it('gets the node version', async () => { + const nodeVersion = await web3Wrapper.getNodeVersionAsync(); + const NODE_VERSION = 'EthereumJS TestRPC/v2.1.0/ethereum-js'; + expect(nodeVersion).to.be.equal(NODE_VERSION); + }); + }); + describe('#getNetworkIdAsync', () => { + it('gets the network id', async () => { + const networkId = await web3Wrapper.getNetworkIdAsync(); + expect(networkId).to.be.equal(NETWORK_ID); + }); + }); +}); |