Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ const rinkebyAlchemyApiKey = process.env.RINKEBY_ALCHEMY_API_KEY;
const testnetPrivateKey = process.env.TESTNET_PRIVATE_KEY;
const privateKey = process.env.ETH_PRIVATE_KEY;
const runE2ETests = process.env.RUN_E2E_TESTS;
const enableMainnetForking = process.env.ENABLE_MAINNET_FORKING;
const mainnetAlchemyApiKey = process.env.MAINNET_ALCHEMY_API_KEY;

if (!rinkebyAlchemyApiKey || !testnetPrivateKey || !privateKey || !mainnetAlchemyApiKey) {
throw new Error('Please set your Ethereum keys in a .env')
console.warn("Not all Ethereum keys provided; some functionality will be unavailable.")
}

if (enableMainnetForking) {
if (!mainnetAlchemyApiKey) {
throw new Error("Cannot fork mainnet without mainnet alchemy api key.")
}

console.log("Mainnet forking enabled.")
} else {
console.log("Mainnet forking disabled.")
}

const config: HardhatUserConfig = {
Expand All @@ -28,21 +39,21 @@ const config: HardhatUserConfig = {
hardhat: {
gas: 12e6,
chainId: 5777, // Any network (default: none)
forking: {
forking: enableMainnetForking ? {
url: `https://eth-mainnet.alchemyapi.io/v2/${mainnetAlchemyApiKey}`,
blockNumber: 13135475
}
} : undefined
},
localhost: {
url: 'http://127.0.0.1:8545'
},
rinkeby: {
url: `https://eth-rinkeby.alchemyapi.io/v2/${rinkebyAlchemyApiKey}`,
accounts: [testnetPrivateKey]
accounts: testnetPrivateKey ? [testnetPrivateKey] : []
},
mainnet: {
url: `https://eth-mainnet.alchemyapi.io/v2/${mainnetAlchemyApiKey}`,
accounts: [privateKey]
accounts: privateKey ? [privateKey] : []
},
},
solidity: {
Expand Down
11 changes: 11 additions & 0 deletions test/bondingcurve/EthBondingCurve.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const hre = require('hardhat');
const { env, hrtime } = require('process');
const {
BN,
expectEvent,
Expand All @@ -22,6 +24,15 @@ describe('EthBondingCurve', function () {
let beneficiaryAddress1;
let beneficiaryAddress2;

this.beforeAll(async function() {
// Can only get the current price on a forked network (since we haven't deployed Uniswap stuff in test setup)
if (!hre.network.config.forking) {
return this.skip();
}

return undefined;
});

beforeEach(async function () {
({
userAddress,
Expand Down
11 changes: 11 additions & 0 deletions test/pcv/PCVSwapperUniswap.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const hre = require('hardhat');

const {
BN,
time,
Expand Down Expand Up @@ -27,6 +29,15 @@ describe('PCVSwapperUniswap', function () {
let governorAddress;
let pcvControllerAddress;

this.beforeAll(async function() {
// Can only get the current price on a forked network (since we haven't deployed Uniswap stuff in test setup)
if (!hre.network.config.forking) {
return this.skip();
}

return undefined;
});

beforeEach(async function () {
({
userAddress,
Expand Down
13 changes: 12 additions & 1 deletion test/stablizer/EthReserveStabilizer.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const hre = require('hardhat');

const {
web3,
BN,
Expand All @@ -20,14 +22,23 @@ describe('EthReserveStabilizer', function () {
let minterAddress;
let pcvControllerAddress;

this.beforeAll(async function() {
// Can only get the current price on a forked network (since we haven't deployed Uniswap stuff in test setup)
if (!hre.network.config.forking) {
return this.skip();
}

return undefined;
});

beforeEach(async function () {
({
userAddress,
governorAddress,
minterAddress,
pcvControllerAddress,
} = await getAddresses());

this.core = await getCore(true);

this.fei = await Fei.at(await this.core.fei());
Expand Down