aboutsummaryrefslogtreecommitdiffstats
path: root/test/artifacts_test.ts
blob: 74705a5259eabdaddf04a2dd30ff244962fe0a35 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import * as fs from 'fs';
import * as _ from 'lodash';
import * as chai from 'chai';
import * as BigNumber from 'bignumber.js';
import HDWalletProvider = require('truffle-hdwallet-provider');
import {chaiSetup} from './utils/chai_setup';
import {ZeroEx, Order} from '../src';
import {web3Factory} from './utils/web3_factory';
import {FillScenarios} from './utils/fill_scenarios';
import {constants} from './utils/constants';

chaiSetup.configure();
const expect = chai.expect;

// Those tests are slower cause they're talking to a remote node
const TIMEOUT = 10000;

describe('Artifacts', () => {
    describe('contracts are deployed on kovan', () => {
        const kovanRpcUrl = constants.KOVAN_URL;
        const packageJSONContent = fs.readFileSync('package.json', 'utf-8');
        const packageJSON = JSON.parse(packageJSONContent);
        const mnemonic = packageJSON.config.mnemonic;
        const web3Provider = new HDWalletProvider(mnemonic, kovanRpcUrl);
        const zeroEx = new ZeroEx(web3Provider);
        it('token registry contract is deployed', async () => {
            const tokens = await zeroEx.tokenRegistry.getTokensAsync();
        }).timeout(TIMEOUT);
        it('proxy contract is deployed', async () => {
            const [token] = await zeroEx.tokenRegistry.getTokensAsync();
            const allowance = await zeroEx.token.getProxyAllowanceAsync(token.address, ZeroEx.NULL_ADDRESS);
            expect(allowance).to.be.bignumber.equal(0);
        }).timeout(TIMEOUT);
        it('exchange contract is deployed', async () => {
            const userAddreses = await zeroEx.getAvailableAddressesAsync();
            const tokens = await zeroEx.tokenRegistry.getTokensAsync();
            const makerTokenAddress = tokens[0].address;
            const takerTokenAddress = tokens[1].address;
            // Unused anyway
            const zrxTokenAddress = ZeroEx.NULL_ADDRESS;
            const fillScenarios = new FillScenarios(zeroEx, userAddreses, tokens, zrxTokenAddress);
            const order: Order = {
                maker: userAddreses[0],
                taker: userAddreses[0],
                makerFee: new BigNumber(0),
                takerFee: new BigNumber(0),
                makerTokenAmount: new BigNumber(0),
                takerTokenAmount: new BigNumber(0),
                makerTokenAddress,
                takerTokenAddress,
                salt: ZeroEx.generatePseudoRandomSalt(),
                feeRecipient: ZeroEx.NULL_ADDRESS,
                expirationUnixTimestampSec: new BigNumber(2524604400),
            };
            const orderHash = await zeroEx.getOrderHashHexAsync(order);
        }).timeout(TIMEOUT);
    });
});