I'm new to hardhat and tried to run some tests. Everything works fine until I try to execute payable functions. Addresses generated with ethers.getSigners();
have no eth on them. Which made me realise that when running npx hardhat test
it's actually set on mainnet for some reason. Logging network gives me:
network is: { name: 'homestead', chainId: 1, ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', _defaultProvider: [Function: func] { renetwork: [Function (anonymous)] } }
How do I go on about switching back to testing locally with hardhat network? I've added this to my hardhat.config.js
networks: { hardhat: { chainId: 31337 } }
But it stills run tests on chainId 1. Even when trying npx hardhat test --network localhost
Any ideas how I could fix that pls ?