diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-02-08 02:27:22 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-02-08 02:27:22 +0800 |
commit | f3c6cce4559d096a2f3babfc7af670d078a6f0dd (patch) | |
tree | 580c59d474d52affc57593d25eb1d0acd480d4b0 /packages/contracts/test/token_registry.ts | |
parent | d9b1d31e7310f7f554f1740f93e4ccd5b5db90f5 (diff) | |
parent | a26e77074fdf5ea7a754a7a676ebd752668d3c82 (diff) | |
download | dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.gz dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.bz2 dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.lz dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.xz dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.zst dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.zip |
Merge branch 'development' into feature/testnet-faucets/queue-by-network
* development: (24 commits)
Fix Remco's github name in CODEOWNERS
Fix ABI error message
Stop using definite assignment assertion cause prettier doesn't handle that
Special-case ZRXToken snake case conversion
Fix linter errors
Generate contract wrappers on pre-build
Add missing async
Remove noImplicitThis
Tslint disable no-consecutive-blank-lines in generated files
Change compiled sources in contracts
Change utils
Change tests
Add base_contract.ts
Remove generated files
.gitignore gemerated files
Change the list of generated wrappers
Change contract templates
Add indices for index parameters so that their names don't collide
Use abi-gen for events in 0x.js
Fix artifacts path
...
Diffstat (limited to 'packages/contracts/test/token_registry.ts')
-rw-r--r-- | packages/contracts/test/token_registry.ts | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts index 2a270dc2f..867282d2c 100644 --- a/packages/contracts/test/token_registry.ts +++ b/packages/contracts/test/token_registry.ts @@ -1,11 +1,13 @@ import { ZeroEx } from '0x.js'; import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; +import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; import * as Web3 from 'web3'; +import { TokenRegistryContract } from '../src/contract_wrappers/generated/token_registry'; import { constants } from '../util/constants'; import { TokenRegWrapper } from '../util/token_registry_wrapper'; import { ContractName } from '../util/types'; @@ -22,13 +24,14 @@ const blockchainLifecycle = new BlockchainLifecycle(); describe('TokenRegistry', () => { let owner: string; let notOwner: string; - let tokenReg: Web3.ContractInstance; + let tokenReg: TokenRegistryContract; let tokenRegWrapper: TokenRegWrapper; before(async () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); owner = accounts[0]; notOwner = accounts[1]; - tokenReg = await deployer.deployAsync(ContractName.TokenRegistry); + const tokenRegInstance = await deployer.deployAsync(ContractName.TokenRegistry); + tokenReg = new TokenRegistryContract(tokenRegInstance); tokenRegWrapper = new TokenRegWrapper(tokenReg); }); beforeEach(async () => { @@ -132,12 +135,12 @@ describe('TokenRegistry', () => { describe('setTokenName', () => { it('should throw when not called by owner', async () => { return expect( - tokenReg.setTokenName(token1.address, token2.name, { from: notOwner }), + tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: notOwner }), ).to.be.rejectedWith(constants.REVERT); }); it('should change the token name when called by owner', async () => { - await tokenReg.setTokenName(token1.address, token2.name, { + await tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: owner, }); const [newData, oldData] = await Promise.all([ @@ -154,14 +157,14 @@ describe('TokenRegistry', () => { it('should throw if the name already exists', async () => { await tokenRegWrapper.addTokenAsync(token2, owner); - return expect(tokenReg.setTokenName(token1.address, token2.name, { from: owner })).to.be.rejectedWith( - constants.REVERT, - ); + return expect( + tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: owner }), + ).to.be.rejectedWith(constants.REVERT); }); it('should throw if token does not exist', async () => { return expect( - tokenReg.setTokenName(nullToken.address, token2.name, { from: owner }), + tokenReg.setTokenName.sendTransactionAsync(nullToken.address, token2.name, { from: owner }), ).to.be.rejectedWith(constants.REVERT); }); }); @@ -169,14 +172,14 @@ describe('TokenRegistry', () => { describe('setTokenSymbol', () => { it('should throw when not called by owner', async () => { return expect( - tokenReg.setTokenSymbol(token1.address, token2.symbol, { + tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, { from: notOwner, }), ).to.be.rejectedWith(constants.REVERT); }); it('should change the token symbol when called by owner', async () => { - await tokenReg.setTokenSymbol(token1.address, token2.symbol, { from: owner }); + await tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, { from: owner }); const [newData, oldData] = await Promise.all([ tokenRegWrapper.getTokenBySymbolAsync(token2.symbol), tokenRegWrapper.getTokenBySymbolAsync(token1.symbol), @@ -192,7 +195,7 @@ describe('TokenRegistry', () => { await tokenRegWrapper.addTokenAsync(token2, owner); return expect( - tokenReg.setTokenSymbol(token1.address, token2.symbol, { + tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, { from: owner, }), ).to.be.rejectedWith(constants.REVERT); @@ -200,7 +203,7 @@ describe('TokenRegistry', () => { it('should throw if token does not exist', async () => { return expect( - tokenReg.setTokenSymbol(nullToken.address, token2.symbol, { + tokenReg.setTokenSymbol.sendTransactionAsync(nullToken.address, token2.symbol, { from: owner, }), ).to.be.rejectedWith(constants.REVERT); @@ -209,15 +212,15 @@ describe('TokenRegistry', () => { describe('removeToken', () => { it('should throw if not called by owner', async () => { - const index = 0; - return expect(tokenReg.removeToken(token1.address, index, { from: notOwner })).to.be.rejectedWith( - constants.REVERT, - ); + const index = new BigNumber(0); + return expect( + tokenReg.removeToken.sendTransactionAsync(token1.address, index, { from: notOwner }), + ).to.be.rejectedWith(constants.REVERT); }); it('should remove token metadata when called by owner', async () => { - const index = 0; - await tokenReg.removeToken(token1.address, index, { + const index = new BigNumber(0); + await tokenReg.removeToken.sendTransactionAsync(token1.address, index, { from: owner, }); const tokenData = await tokenRegWrapper.getTokenMetaDataAsync(token1.address); @@ -225,18 +228,18 @@ describe('TokenRegistry', () => { }); it('should throw if token does not exist', async () => { - const index = 0; - return expect(tokenReg.removeToken(nullToken.address, index, { from: owner })).to.be.rejectedWith( - constants.REVERT, - ); + const index = new BigNumber(0); + return expect( + tokenReg.removeToken.sendTransactionAsync(nullToken.address, index, { from: owner }), + ).to.be.rejectedWith(constants.REVERT); }); it('should throw if token at given index does not match address', async () => { await tokenRegWrapper.addTokenAsync(token2, owner); - const incorrectIndex = 0; - return expect(tokenReg.removeToken(token2.address, incorrectIndex, { from: owner })).to.be.rejectedWith( - constants.REVERT, - ); + const incorrectIndex = new BigNumber(0); + return expect( + tokenReg.removeToken.sendTransactionAsync(token2.address, incorrectIndex, { from: owner }), + ).to.be.rejectedWith(constants.REVERT); }); }); }); |