updated solidity-coverage version to 0.7.1 and truffle 5.0.31
Getting this error now, during compilation after instrumentation
> solidity-coverage cleaning up, shutting down ganache server
Error: TypeError: Cannot convert undefined or null to object
at Object.compile (/home/udkreddy/Dushyanth/NexusMutual/nxm-smart-contracts/node_modules/truffle/build/webpack:/packages/truffle-workflow-compile/legacy/index.js?6101:72:1)
at <anonymous>
Find repo here : https://github.com/udkreddy/nxm-smart-contracts/tree/coverage-fix
@udkreddy I haven't been able to get the tests to run to completion - the setup takes a really long time - I don't know if it's due to the coverage tool because I can't get the regular tests to run. If you add a network flag to...
npx truffle run coverage --network development
in test.sh, coverage will use 8545 but the before block for the first test just seems to hang. If you omit the network flag, eventually you will see some tests running but some of the before blocks error because they are using the wrong port to make Web3 calls.
Having some issues with the parser and Solidity 0.6.3 features.
It doesn't support structs sitting at the tops of files:
ParserError: Could not instrument: mycontract.sol. (Please verify solc can compile this file without errors.) extraneous input 'struct' expecting {<EOF>, 'pragma', 'import', 'abstract', 'contract', 'interface', 'library'}
at Object.parse (.../node_modules/solidity-parser-diligence/dist/index.js:79:11)
at Instrumenter.instrument (.../node_modules/solidity-coverage/lib/instrumenter.js:63:30)
at API.instrument (.../node_modules/solidity-coverage/lib/api.js:91:48)
at plugin (.../node_modules/solidity-coverage/plugins/truffle.plugin.js:76:19)
And it doesn't support enums being used as keys for mappings:
ParserError: Could not instrument: mycontract.sol. (Please verify solc can compile this file without errors.) mismatched input 'MyEnum' expecting {'address', 'var', 'bool', 'string', 'byte', Int, Uint, Byte, Fixed, Ufixed}
at Object.parse (.../node_modules/solidity-parser-diligence/dist/index.js:79:11)
at Instrumenter.instrument (.../node_modules/solidity-coverage/lib/instrumenter.js:63:30)
at Instrumenter.instrument (.../node_modules/solidity-coverage/lib/instrumenter.js:63:30)
at API.instrument (.../node_modules/solidity-coverage/lib/api.js:91:48)
at plugin (.../node_modules/solidity-coverage/plugins/truffle.plugin.js:76:19)
I'm trying to check the coverage of an entire ERC20 set of openzeppelin tests. I'm using openzeppelin/test-environment and solidity-coverage v0.7.4 as a plugins in truffle. the tests went fine but I get odd results for coverage.
Contract | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines
Context.sol | 0 | 100 | 0 | 0 | 20,24,25 |
ERC20.sol | 0 | 0 | 0 | 0 |... 217,227,228 |
ERC20Mock.sol | 0 | 100 | 0 | 0 |... 16,20,24,28 |
IERC20.sol | 100 | 100 | 100 | 100 | |
SafeMath.sol | 0 | 0 | 0 | 0 |... 136,153,154
As you can see, only IERC20 got entirely covered, and ERC20 got nothing despite of this contract being implementation of the interface IERC20. SafeMath should have some coverage as well. Does anyone can explain this? This is my first time using solidity-coverage, any help is much appreciated.
contract.fromArtifact
. It's not using the coverage-enabled instance launched by the truffle plugin. AFAIK they are actively working on their own solidity-coverage integration as part their Q2 improvements: https://github.com/OpenZeppelin/openzeppelin-test-environment/milestone/1
morning, i'm trying to run coverage against my tests and getting a runtimeerror
1) PanDAO Contract Network
"before each" hook:
Uncaught RuntimeError: abort(Error: Method [object Object] not supported.). Build with -s ASSERTIONS=1 for more info.
at process.abort (.coverage_cache/compilers/soljson-v0.6.6+commit.6c089d02.js:1:14382)
at process.emit (node_modules/@nomiclabs/buidler/node_modules/source-map-support/source-map-support.js:495:21)
at process.emit (node_modules/ganache-cli/node_modules/source-map-support/source-map-support.js:465:21)
at process.object.process.function.process.on.process.emit (node_modules/ganache-cli/build/ganache-core.node.cli.js:37:31967)
at process.emit (node_modules/source-map-support/source-map-support.js:465:21)
at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)
at process._tickCallback (internal/process/next_tick.js:69:34)
beforeEach(async () => {
[agent, address1, address2] = await bre.getSigners();
await deployments.fixture();
// setup needed contracts
Manager = await deployments.get("Manager");
manager = new ethers.Contract(Manager.address, Manager.abi, agent);
EternalStorage = await deployments.get("EternalStorage");
eternalStorage = new ethers.Contract(
EternalStorage.address,
EternalStorage.abi,
agent
);
MockToken = await bre.getContractFactory("Token");
mockToken = await MockToken.deploy();
await mockToken.deployed();
});
however tests pass fine when just running tests;
All contracts have already been compiled, skipping compilation.
PanDAO Contract Network
Manager Contract
✓ Manager is stored in EternalStorage
✓ Can get contract address by contract name
✓ Agent owns deployed Manager contract
✓ Can create an Insurance Pool if it doesn't exist (442ms)
✓ Fails to create Insurance Pool if it already exists (269ms)
✓ Fails to create an Insurance Pool if not Agent
6 passing (2s)
module.exports = {
providerOptions: {
allowUnlimetedContractSize: true,
gasLimit: 0xfffffffffff,
logger: console,
port: 9545,
fork: MAINNET_NODE_URL,
network_id: 1,
unlocked_accounts: [
'0xd8f8a53945bcfbbc19da162aa405e662ef71c40d', // MLN whale
'0x3eb01b3391ea15ce752d01cf3d3f09dec596f650', // KNC whale
'0xa57bd00134b2850b2a1c55860c9e9ea100fdd6cf', // ZRX reserve operator
'0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8', // ZRX whale
'0x7D3455421BbC5Ed534a83c88FD80387dc8271392', // ZRX Governor contract
],
default_balance_ether: startingBalance,
accounts: [ // TODO: is this array redundant?
{
secretKey: PRIV_KEY_1,
balance: startingBalance,
}, {
secretKey: PRIV_KEY_2,
balance: startingBalance,
}, {
secretKey: PRIV_KEY_3,
balance: startingBalance,
},
],
}
};
Error: *** Deployment Failed ***
"EngineAdapter" ran out of gas (using a value you set in your network config or deployment parameters.)
* Block limit: 17592186044415 (0xfffffffffff)
* Gas sent: 17592186044415 (0xfffffffffff)
at ./node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.25 (core: 5.1.25)
Node v10.18.1
.solcover.js
config:
allowUnlimetedContractSize: true,
gasLimit: 0xfffffffffff,