Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail when defaultNetwork is set to localhost #894

Open
bitcoinbrisbane opened this issue Sep 22, 2024 · 4 comments
Open

Tests fail when defaultNetwork is set to localhost #894

bitcoinbrisbane opened this issue Sep 22, 2024 · 4 comments

Comments

@bitcoinbrisbane
Copy link

Im getting the following error when trying to run coverage against a base fork, with the command.

npx hardhat coverage
Error in plugin solidity-coverage: ❌ 24 test(s) failed under coverage.

hardhat config

const PK = process.env.PK;

const config: HardhatUserConfig = {
	solidity: {
		version: "0.8.19",
		settings: {
			optimizer: {
				enabled: true,
				runs: 100,
			},
			viaIR: true,
		},
	},
	defaultNetwork: "localhost",
	etherscan: {
		apiKey: {
			base: process.env.BASESCAN_API_KEY || "",
		},
		customChains: [
			{
				network: "base",
				chainId: 8453,
				urls: {
					apiURL: "https://api.basescan.org/api",
					browserURL: "https://basescan.org",
				},
			},
		],
	},
	networks: {
		base: {
			accounts: PK ? [PK] : [],
			chainId: 8453,
			url: "https://mainnet.base.org",
		},
		hardhat: {
			forking: {
				url: process.env.FORKING_URL as string,
				// blockNumber: 19197423,
				enabled: true,
			},
			chains: {
				8453: {
					hardforkHistory: {
						london: 0,
					},
				},
			},
			blockGasLimit: 60000000 // Network block gasLimit
		},
	},
};

export default config;
@cgewecke
Copy link
Member

@bitcoinbrisbane Could you try commenting out the part of the config where you define the defaultNetwork as localhost and see if that works? (The plugin needs to run on the hardhat network).

Is the problem reproducible when running this repo and branch?

https://github.com/weweswap/contracts/tree/fix/coverage-report

@bitcoinbrisbane
Copy link
Author

@bitcoinbrisbane Could you try commenting out the part of the config where you define the defaultNetwork as localhost and see if that works? (The plugin needs to run on the hardhat network).

Is the problem reproducible when running this repo and branch?

https://github.com/weweswap/contracts/tree/fix/coverage-report

Sure, trying now.

@bitcoinbrisbane
Copy link
Author

Success!

image

@cgewecke cgewecke changed the title Error in plugin solidity-coverage: ❌ 24 test(s) failed under coverage. Tests fail when defaultNetwork is set to localhost Sep 23, 2024
@cgewecke
Copy link
Member

cgewecke commented Sep 23, 2024

I think the plugin should probably detect when there's a user-defined defaultNetwork that won't work and warn about it.

Am going to re-open just to keep track of this problem...thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants