protocol/packages/protocol-utils/test/eip712_utils_test.ts
Lawrence Forman edda1edc50
@0x/protocol-utils (#76)
* add new packages

* `@0x/protocol-utils`: Update with latest code from `@0x/contracs-zero-ex` + misc stuff

* @0x/contracts-zero-ex`: Switch to using `@0x/protocol-utils` in most places

* @0x/protocol-types`: Delete this package.

* regen yarn lock

* `@0x/contracts-zero-ex`: Unpin `@0x/protocol-utils` dep.

* `@0x/contracts-integrations`: Fix borken test

* update changelogs

* `@0x/protocol-utils`: Update deps

* `@0x/protocol-utils`: add tests

* `@0x/protocol-utils`: More tests

* `@0x/protocol-utils`: Update readme.

* update deps

* run prettier

* `@0x/contract-artifacts`: Regenerate artifacts

* `@0x/contract-wrappers`: Regenerate wrappers

* `@0x/protocol-utils`: Update changelog

* `@0x/contract-wrappers`: Export stuff for doc gen

* `@0x/protocol-utils`: Use `Web3Wrapper.signTypedDataV4Async()` for MM compatibility.

* upgrade org deps

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-12-08 22:08:52 -05:00

43 lines
1.8 KiB
TypeScript

import { chaiSetup } from '@0x/dev-utils';
import { expect } from 'chai';
import { getExchangeProxyEIP712DomainHash, getExchangeProxyEIP712Hash } from '../src/eip712_utils';
chaiSetup.configure();
describe('eip712_utils', () => {
describe('getExchangeProxyEIP712DomainHash()', () => {
it('computes the correct default hash', () => {
const actual = getExchangeProxyEIP712DomainHash();
const expected = '0xc92fa40dbe33b59738624b1b4ec40b30ff52e4da223f68018a7e0667ffc0e798';
expect(actual).to.eq(expected);
});
it('computes the correct hash with parameters', () => {
const chainId = 1337;
const verifyingContract = '0xfe20c9f78898cf8a3e7c5c2ed36568a3d2ad02b9';
const actual = getExchangeProxyEIP712DomainHash(chainId, verifyingContract);
const expected = '0x3f2ee54842d00d7e811297005788367c60110c261f9f94d7f4f46a17e382bdf3';
expect(actual).to.eq(expected);
});
});
describe('getExchangeProxyEIP712Hash()', () => {
const structHash = '0x3ada2b9bef7def77259eca388e1074fd09013e2942cf9b594a9c6a1b2d215d1f';
it('computes the correct hash', () => {
const actual = getExchangeProxyEIP712Hash(structHash);
const expected = '0x619a48532e5e0a633191af930dacfd5538b74078793d09e8408ab9124f7b9bf3';
expect(actual).to.eq(expected);
});
it('computes the correct hash with parameters', () => {
const chainId = 1337;
const verifyingContract = '0xfe20c9f78898cf8a3e7c5c2ed36568a3d2ad02b9';
const actual = getExchangeProxyEIP712Hash(structHash, chainId, verifyingContract);
const expected = '0xc051b4f9f305b095768427eb29d9461c473d2e96aa30a5914a7081feae979d1d';
expect(actual).to.eq(expected);
});
});
});