MyCrypto/spec/config/contracts.spec.ts
James Prado aabcd3f7a3 Use Network Symbol in Confirmation Modal (#1039)
* Set default unit to 'ETH' instead of 'ether'

* Use 'isEtherUnit()' everywhere

* Set default unit to empty string

* Update isEthUnit to isNetworkUnit

* Fix unit conversion for non-ethereum networks

* Set default network unit properly

* Fix tests

* fix typos

* Update isNetworkUnit selector

* Update isNetworkUnit

* Fix validationhelpers tests

* Add mock state to tests & Move isNetworkUnit to selectors

* Fix validation helper spec

* fix unit swap spec
2018-03-01 19:24:14 -06:00

35 lines
1.1 KiB
TypeScript

import { configuredStore } from 'store';
import CONTRACTS from 'config/contracts';
import { isValidETHAddress } from 'libs/validators';
configuredStore.getState();
describe('Contracts JSON', () => {
Object.keys(CONTRACTS).forEach(network => {
it(`${network} contracts array properly formatted`, () => {
const contracts = CONTRACTS[network];
const addressCollisionMap = {};
contracts.forEach(contract => {
if (contract.address && !isValidETHAddress(contract.address)) {
throw Error(`Contract '${contract.name}' has invalid address '${contract.address}'`);
}
if (addressCollisionMap[contract.address]) {
throw Error(
`Contract '${contract.name}' has the same address as ${
addressCollisionMap[contract.address]
}`
);
}
try {
JSON.stringify(contract.abi);
} catch (err) {
throw Error(`Contract '${contract.name}' has invalid JSON ABI`);
}
addressCollisionMap[contract.address] = contract.name;
});
});
});
});