Fix infra core deployment in test environment (#454)

pull/461/head
Nam Chu Hoai 3 years ago committed by GitHub
parent 854c5e8529
commit c47d42aecd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      typescript/deploy/src/config.ts
  2. 7
      typescript/infra/config/environments/test/index.ts
  3. 39
      typescript/infra/hardhat.config.ts
  4. 2
      typescript/infra/package.json
  5. 5
      typescript/infra/scripts/core.ts
  6. 17
      typescript/infra/test/controller.test.ts
  7. 16
      typescript/infra/test/core.test.ts

@ -16,6 +16,7 @@ export type TransactionConfig = {
// The number of confirmations considered reorg safe
confirmations?: number;
signer?: ethers.Signer;
provider?: ethers.providers.Provider;
};
export type EnvironmentConfig<Chain extends ChainName> = ChainMap<

@ -1,3 +1,5 @@
import { JsonRpcProvider } from '@ethersproject/providers';
import { utils } from '@abacus-network/deploy';
import { CoreEnvironmentConfig } from '../../../src/config';
@ -16,9 +18,8 @@ export const environment: CoreEnvironmentConfig<TestChains> = {
infra,
// NOTE: Does not work from hardhat.config.ts
getMultiProvider: async () => {
const hre = await import('hardhat');
await import('@nomiclabs/hardhat-ethers');
const [signer] = await hre.ethers.getSigners();
const provider = testConfigs.test1.provider! as JsonRpcProvider;
const signer = provider.getSigner(0);
return utils.getMultiProviderFromConfigAndSigner(testConfigs, signer);
},
};

@ -12,13 +12,7 @@ import {
} from '@abacus-network/sdk';
import { utils } from '@abacus-network/utils';
import {
getCoreContractsSdkFilepath,
getCoreEnvironmentConfig,
getCoreRustDirectory,
getCoreVerificationDirectory,
} from './scripts/utils';
import { AbacusCoreInfraDeployer } from './src/core/deploy';
import { getCoreEnvironmentConfig } from './scripts/utils';
import { sleep } from './src/utils/utils';
import { AbacusContractVerifier } from './src/verify';
@ -62,37 +56,6 @@ const chainSummary = async <Chain extends ChainName>(
return summary;
};
task('abacus', 'Deploys abacus on top of an already running Hardhat Network')
// If we import ethers from hardhat, we get error HH9 with included note.
// You probably tried to import the "hardhat" module from your config or a file imported from it.
// This is not possible, as Hardhat can't be initialized while its config is being defined.
.setAction(async (_: any, hre: HardhatRuntimeEnvironment) => {
const environment = 'test';
const config = getCoreEnvironmentConfig(environment);
// TODO: replace with config.getMultiProvider()
const [signer] = await hre.ethers.getSigners();
const multiProvider = deployUtils.getMultiProviderFromConfigAndSigner(
config.transactionConfigs,
signer,
);
const deployer = new AbacusCoreInfraDeployer(multiProvider, config.core);
const addresses = await deployer.deploy();
// Write configs
deployer.writeVerification(getCoreVerificationDirectory(environment));
deployer.writeRustConfigs(
environment,
getCoreRustDirectory(environment),
addresses,
);
deployer.writeContracts(
addresses,
getCoreContractsSdkFilepath(environment),
);
});
task('kathy', 'Dispatches random abacus messages').setAction(
async (_, hre: HardhatRuntimeEnvironment) => {
const environment = 'test';

@ -20,7 +20,7 @@
"test": "hardhat test",
"check": "tsc --noEmit",
"node": "hardhat node",
"abacus": "hardhat abacus --network localhost",
"abacus": "ts-node scripts/core.ts -e test",
"kathy": "hardhat kathy --network localhost",
"prettier": "prettier --write *.ts ./src ./config ./scripts ./test"
},

@ -12,10 +12,7 @@ async function main() {
const environment = await getEnvironment();
const config = getCoreEnvironmentConfig(environment) as any;
const multiProvider = await config.getMultiProvider();
const deployer = new AbacusCoreInfraDeployer(
multiProvider,
config.core.validatorManagers,
);
const deployer = new AbacusCoreInfraDeployer(multiProvider, config.core);
const addresses = await deployer.deploy();

@ -1,6 +1,8 @@
import '@nomiclabs/hardhat-waffle';
import { ethers } from 'hardhat';
import path from 'path';
import { getMultiProviderFromConfigAndSigner } from '@abacus-network/deploy/dist/src/utils';
import {
AbacusCore,
ChainMap,
@ -9,8 +11,8 @@ import {
MultiProvider,
} from '@abacus-network/sdk';
import { environment as config } from '../config/environments/test';
import { TestChains } from '../config/environments/test/chains';
import { getCoreEnvironmentConfig } from '../scripts/utils';
import {
ControllerChecker,
ControllerConfig,
@ -18,19 +20,20 @@ import {
} from '../src/controller';
describe('controller', async () => {
const environment = 'test';
let multiProvider: MultiProvider<TestChains>;
let deployer: ControllerDeployer<TestChains>;
let addresses: ChainMap<TestChains, ControllerAddresses>;
let controllerConfig: ChainMap<TestChains, ControllerConfig>;
before(async () => {
const config = getCoreEnvironmentConfig(environment);
controllerConfig = config.controller;
multiProvider = await config.getMultiProvider();
const core = AbacusCore.fromEnvironment(environment, multiProvider);
const [signer] = await ethers.getSigners();
// This is kind of awkward and really these tests shouldn't live here
multiProvider = getMultiProviderFromConfigAndSigner(
config.transactionConfigs,
signer,
);
const core = AbacusCore.fromEnvironment('test', multiProvider);
console.log(core);
deployer = new ControllerDeployer(multiProvider, controllerConfig, core);
});

@ -3,6 +3,7 @@ import { ethers } from 'hardhat';
import path from 'path';
import { AbacusCoreDeployer, CoreConfig } from '@abacus-network/deploy';
import { getMultiProviderFromConfigAndSigner } from '@abacus-network/deploy/dist/src/utils';
import {
AbacusCore,
ChainMap,
@ -11,8 +12,8 @@ import {
objMap,
} from '@abacus-network/sdk';
import { environment as testConfig } from '../config/environments/test';
import { TestChains } from '../config/environments/test/chains';
import { getCoreEnvironmentConfig } from '../scripts/utils';
import { AbacusCoreChecker } from '../src/core';
import { AbacusCoreInfraDeployer } from '../src/core/deploy';
@ -27,12 +28,15 @@ describe('core', async () => {
let owners: ChainMap<TestChains, string>;
before(async () => {
const config = getCoreEnvironmentConfig(environment);
multiProvider = await config.getMultiProvider();
coreConfig = config.core;
const [signer, owner] = await ethers.getSigners();
// This is kind of awkward and really these tests shouldn't live here
multiProvider = getMultiProviderFromConfigAndSigner(
testConfig.transactionConfigs,
signer,
);
coreConfig = testConfig.core;
deployer = new AbacusCoreInfraDeployer(multiProvider, coreConfig);
const [, owner] = await ethers.getSigners();
owners = objMap(config.transactionConfigs, () => owner.address);
owners = objMap(testConfig.transactionConfigs, () => owner.address);
});
it('deploys', async () => {

Loading…
Cancel
Save