Hard code chainId in tests

This commit is contained in:
Amir Bandeali 2019-08-13 16:52:03 -07:00
parent c5d4559300
commit 2da996f493
3 changed files with 7 additions and 14 deletions

View File

@ -1,17 +1,13 @@
import { addressUtils, blockchainTests, constants, expect } from '@0x/contracts-test-utils'; import { addressUtils, blockchainTests, constants, expect } from '@0x/contracts-test-utils';
import { BigNumber, providerUtils, signTypedDataUtils } from '@0x/utils'; import { BigNumber, signTypedDataUtils } from '@0x/utils';
import * as ethUtil from 'ethereumjs-util'; import * as ethUtil from 'ethereumjs-util';
import { artifacts, TestLibEIP712ExchangeDomainContract } from '../src'; import { artifacts, TestLibEIP712ExchangeDomainContract } from '../src';
blockchainTests('LibEIP712ExchangeDomain', env => { blockchainTests('LibEIP712ExchangeDomain', env => {
let chainId: number;
before(async () => {
chainId = await providerUtils.getChainIdAsync(env.provider);
});
describe('constructor', () => { describe('constructor', () => {
it('should calculate the correct domain hash when verifyingContractAddressIfExists is set to null', async () => { it('should calculate the correct domain hash when verifyingContractAddressIfExists is set to null', async () => {
const chainId = 1;
const libEIP712ExchangeDomainContract = await TestLibEIP712ExchangeDomainContract.deployFrom0xArtifactAsync( const libEIP712ExchangeDomainContract = await TestLibEIP712ExchangeDomainContract.deployFrom0xArtifactAsync(
artifacts.TestLibEIP712ExchangeDomain, artifacts.TestLibEIP712ExchangeDomain,
env.provider, env.provider,
@ -30,6 +26,7 @@ blockchainTests('LibEIP712ExchangeDomain', env => {
expect(actualDomainHash).to.be.equal(expectedDomainHash); expect(actualDomainHash).to.be.equal(expectedDomainHash);
}); });
it('should calculate the correct domain hash when verifyingContractAddressIfExists is set to a non-null address', async () => { it('should calculate the correct domain hash when verifyingContractAddressIfExists is set to a non-null address', async () => {
const chainId = 1;
const verifyingContractAddress = addressUtils.generatePseudoRandomAddress(); const verifyingContractAddress = addressUtils.generatePseudoRandomAddress();
const libEIP712ExchangeDomainContract = await TestLibEIP712ExchangeDomainContract.deployFrom0xArtifactAsync( const libEIP712ExchangeDomainContract = await TestLibEIP712ExchangeDomainContract.deployFrom0xArtifactAsync(
artifacts.TestLibEIP712ExchangeDomain, artifacts.TestLibEIP712ExchangeDomain,

View File

@ -1,7 +1,7 @@
import { addressUtils, blockchainTests, constants, describe, expect } from '@0x/contracts-test-utils'; import { addressUtils, blockchainTests, constants, describe, expect } from '@0x/contracts-test-utils';
import { assetDataUtils, orderHashUtils } from '@0x/order-utils'; import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
import { Order } from '@0x/types'; import { Order } from '@0x/types';
import { BigNumber, providerUtils, signTypedDataUtils } from '@0x/utils'; import { BigNumber, signTypedDataUtils } from '@0x/utils';
import * as ethUtil from 'ethereumjs-util'; import * as ethUtil from 'ethereumjs-util';
import { artifacts, TestLibOrderContract } from '../src'; import { artifacts, TestLibOrderContract } from '../src';
@ -9,17 +9,15 @@ import { artifacts, TestLibOrderContract } from '../src';
blockchainTests('LibOrder', env => { blockchainTests('LibOrder', env => {
let libOrderContract: TestLibOrderContract; let libOrderContract: TestLibOrderContract;
let order: Order; let order: Order;
let chainId: number;
before(async () => { before(async () => {
libOrderContract = await TestLibOrderContract.deployFrom0xArtifactAsync( libOrderContract = await TestLibOrderContract.deployFrom0xArtifactAsync(
artifacts.TestLibOrder, artifacts.TestLibOrder,
env.provider, env.provider,
env.txDefaults, env.txDefaults,
); );
chainId = await providerUtils.getChainIdAsync(env.provider);
const domain = { const domain = {
verifyingContractAddress: libOrderContract.address, verifyingContractAddress: libOrderContract.address,
chainId, chainId: 1,
}; };
order = { order = {
...constants.STATIC_ORDER_PARAMS, ...constants.STATIC_ORDER_PARAMS,

View File

@ -1,7 +1,7 @@
import { addressUtils, blockchainTests, constants, describe, expect } from '@0x/contracts-test-utils'; import { addressUtils, blockchainTests, constants, describe, expect } from '@0x/contracts-test-utils';
import { transactionHashUtils } from '@0x/order-utils'; import { transactionHashUtils } from '@0x/order-utils';
import { ZeroExTransaction } from '@0x/types'; import { ZeroExTransaction } from '@0x/types';
import { BigNumber, providerUtils, signTypedDataUtils } from '@0x/utils'; import { BigNumber, signTypedDataUtils } from '@0x/utils';
import * as ethUtil from 'ethereumjs-util'; import * as ethUtil from 'ethereumjs-util';
import { artifacts, TestLibZeroExTransactionContract } from '../src'; import { artifacts, TestLibZeroExTransactionContract } from '../src';
@ -9,17 +9,15 @@ import { artifacts, TestLibZeroExTransactionContract } from '../src';
blockchainTests('LibZeroExTransaction', env => { blockchainTests('LibZeroExTransaction', env => {
let libZeroExTransactionContract: TestLibZeroExTransactionContract; let libZeroExTransactionContract: TestLibZeroExTransactionContract;
let zeroExTransaction: ZeroExTransaction; let zeroExTransaction: ZeroExTransaction;
let chainId: number;
before(async () => { before(async () => {
libZeroExTransactionContract = await TestLibZeroExTransactionContract.deployFrom0xArtifactAsync( libZeroExTransactionContract = await TestLibZeroExTransactionContract.deployFrom0xArtifactAsync(
artifacts.TestLibZeroExTransaction, artifacts.TestLibZeroExTransaction,
env.provider, env.provider,
env.txDefaults, env.txDefaults,
); );
chainId = await providerUtils.getChainIdAsync(env.provider);
const domain = { const domain = {
verifyingContractAddress: libZeroExTransactionContract.address, verifyingContractAddress: libZeroExTransactionContract.address,
chainId, chainId: 1,
}; };
zeroExTransaction = { zeroExTransaction = {
signerAddress: addressUtils.generatePseudoRandomAddress(), signerAddress: addressUtils.generatePseudoRandomAddress(),