2018-03-02 01:24:14 +00:00
|
|
|
import { configuredStore } from 'store';
|
2018-01-11 06:47:48 +00:00
|
|
|
import CONTRACTS from 'config/contracts';
|
|
|
|
import { isValidETHAddress } from 'libs/validators';
|
2018-03-02 01:24:14 +00:00
|
|
|
configuredStore.getState();
|
2018-01-11 06:47:48 +00:00
|
|
|
|
|
|
|
describe('Contracts JSON', () => {
|
|
|
|
Object.keys(CONTRACTS).forEach(network => {
|
|
|
|
it(`${network} contracts array properly formatted`, () => {
|
2018-03-07 23:36:05 +00:00
|
|
|
const contracts: any = (CONTRACTS as any)[network];
|
|
|
|
const addressCollisionMap: any = {};
|
2018-01-11 06:47:48 +00:00
|
|
|
|
2018-03-07 23:36:05 +00:00
|
|
|
contracts.forEach((contract: any) => {
|
2018-01-11 06:47:48 +00:00
|
|
|
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;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|