* update abi-gen with new method interfaces * wip: get all packages to build * wip: get all packages to build * Fix two contract wrapper calls * Export necessary types part of the contract wrapper public interfaces * Revive and fix wrapper_unit_tests * Remove duplicate type * Fix lib_exchange_rich_error_decoder tests * Fix remaining test failures in contracts-* packages * Prettier fixes * remove transactionHelper * lint and update changelogs * Fix prettier * Revert changes to reference docs * Add back changelog already published and add revert changelog entry * Add missing CHANGELOG entries * Add missing comma * Update mesh-rpc-client dep * Update Mesh RPC logic in @0x/orderbook to v6.0.1-beta * Align package versions
54 lines
2.5 KiB
TypeScript
54 lines
2.5 KiB
TypeScript
import { blockchainTests, constants, expect, randomAddress } from '@0x/contracts-test-utils';
|
|
import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
|
import * as ethUtil from 'ethereumjs-util';
|
|
|
|
import { TestLibEIP712ExchangeDomainContract } from './wrappers';
|
|
|
|
import { artifacts } from './artifacts';
|
|
|
|
blockchainTests('LibEIP712ExchangeDomain', env => {
|
|
describe('constructor', () => {
|
|
it('should calculate the correct domain hash when verifyingContractAddressIfExists is set to null', async () => {
|
|
const chainId = 1;
|
|
const libEIP712ExchangeDomainContract = await TestLibEIP712ExchangeDomainContract.deployFrom0xArtifactAsync(
|
|
artifacts.TestLibEIP712ExchangeDomain,
|
|
env.provider,
|
|
env.txDefaults,
|
|
{},
|
|
new BigNumber(chainId),
|
|
constants.NULL_ADDRESS,
|
|
);
|
|
const domain = {
|
|
verifyingContract: libEIP712ExchangeDomainContract.address,
|
|
chainId,
|
|
name: constants.EIP712_DOMAIN_NAME,
|
|
version: constants.EIP712_DOMAIN_VERSION,
|
|
};
|
|
const expectedDomainHash = ethUtil.bufferToHex(signTypedDataUtils.generateDomainHash(domain));
|
|
const actualDomainHash = await libEIP712ExchangeDomainContract.EIP712_EXCHANGE_DOMAIN_HASH().callAsync();
|
|
expect(actualDomainHash).to.be.equal(expectedDomainHash);
|
|
});
|
|
it('should calculate the correct domain hash when verifyingContractAddressIfExists is set to a non-null address', async () => {
|
|
const chainId = 1;
|
|
const verifyingContract = randomAddress();
|
|
const libEIP712ExchangeDomainContract = await TestLibEIP712ExchangeDomainContract.deployFrom0xArtifactAsync(
|
|
artifacts.TestLibEIP712ExchangeDomain,
|
|
env.provider,
|
|
env.txDefaults,
|
|
{},
|
|
new BigNumber(chainId),
|
|
verifyingContract,
|
|
);
|
|
const domain = {
|
|
verifyingContract,
|
|
chainId,
|
|
name: constants.EIP712_DOMAIN_NAME,
|
|
version: constants.EIP712_DOMAIN_VERSION,
|
|
};
|
|
const expectedDomainHash = ethUtil.bufferToHex(signTypedDataUtils.generateDomainHash(domain));
|
|
const actualDomainHash = await libEIP712ExchangeDomainContract.EIP712_EXCHANGE_DOMAIN_HASH().callAsync();
|
|
expect(actualDomainHash).to.be.equal(expectedDomainHash);
|
|
});
|
|
});
|
|
});
|