Skip to content

Commit

Permalink
Migrate test suite to ethers and optimise
Browse files Browse the repository at this point in the history
  • Loading branch information
kanewallmann committed Oct 8, 2024
1 parent 8d4d5c0 commit 6812cf7
Show file tree
Hide file tree
Showing 96 changed files with 14,173 additions and 22,464 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ node_modules/
.idea/
cache/
artifacts/
.env
.env
coverage/
coverage.json
52 changes: 52 additions & 0 deletions hardhat-common.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
require('dotenv').config();
require('@nomicfoundation/hardhat-ethers');

// Importing babel to be able to use ES6 imports
require('@babel/register')({
presets: [
['@babel/preset-env', {
'targets': {
'node': '16',
},
}],
],
only: [/test|scripts/],
retainLines: true,
});
require('@babel/polyfill');

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: {
compilers: [
{
version: '0.7.6',
settings: {
optimizer: {
enabled: true,
runs: 15000,
},
},
},
{
version: '0.8.18',
settings: {
optimizer: {
enabled: true,
runs: 15000,
},
},
},
],
},
networks: {},
paths: {
sources: './contracts',
tests: './test',
cache: './cache',
artifacts: './artifacts',
},
mocha: {
timeout: 0,
},
};
17 changes: 17 additions & 0 deletions hardhat-fork.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let common = require('./hardhat-common.config.js');

// Config from environment
const mainnetProviderUrl = process.env.MAINNET_PROVIDER_URL || 'http://localhost:8545';

module.exports = Object.assign(common, {
networks: {
hardhat: {
forking: {
url: mainnetProviderUrl,
},
},
},
paths: {
tests: './test-fork',
}
});
59 changes: 9 additions & 50 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,20 @@
// Support truffle-style test setup
require('@nomiclabs/hardhat-truffle5');
require('dotenv').config();
require('hardhat-gas-reporter');
require('solidity-coverage');

// Importing babel to be able to use ES6 imports
require('@babel/register')({
presets: [
['@babel/preset-env', {
'targets': {
'node': '16',
},
}],
],
only: [ /test|scripts/ ],
retainLines: true,
});
require('@babel/polyfill');
let common = require('./hardhat-common.config.js');

// Config from environment
const mnemonicPhrase = process.env.MNEMONIC || 'test test test test test test test test test test test junk';
const mnemonicPassword = process.env.MNEMONIC_PASSWORD;
const providerUrl = process.env.PROVIDER_URL || 'http://localhost:8545';

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: {
compilers: [
{
version: '0.7.6',
settings: {
optimizer: {
enabled: true,
runs: 15000,
},
},
},
{
version: '0.8.18',
settings: {
optimizer: {
enabled: true,
runs: 15000,
},
},
}
]
},
module.exports = Object.assign(common, {
networks: {
hardhat: {
accounts: {
count: 50,
}
accountsBalance: '10000000000000000000000000',
},
},
localhost: {
host: '127.0.0.1',
Expand All @@ -68,13 +33,7 @@ module.exports = {
network_id: '*',
},
},
paths: {
sources: './contracts',
tests: './test',
cache: './cache',
artifacts: './artifacts',
},
mocha: {
timeout: 0,
gasReporter: {
enabled: !!process.env.REPORT_GAS,
},
};
});
Loading

0 comments on commit 6812cf7

Please sign in to comment.