Closed maiffany closed 7 years ago
It's the modified testrpc
command (which this tool provides itself and runs itself) that generates allFiredEvents
, so my best guess is that you have another instance of testrpc
running.
If that's true, I'll make it clearer in the README
that you should not have testrpc
, geth
or similar running already when running runCoveredTests.js
.
I saw in your README that I should have my port:8545 free. But When i didn't run my localhost ethereum, it showed errors:
cp: no such file or directory: ./../originalContracts/Migrations.sol
rm: no such file or directory: ./allFiredEvents
Compiling Add.sol...
Error: Invalid JSON RPC response: "Error: connect ECONNREFUSED 127.0.0.1:8545\n at Object.exports._errnoException (util.js:870:11)\n at exports._exceptionWithHostPort (util.js:893:20)\n at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14)"
at Object.module.exports.InvalidResponse (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/errors.js:35:16)
at null.request.onreadystatechange (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:111:32)
at null.dispatchEvent (/usr/local/lib/node_modules/truffle/node_modules/web3/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
at setState (/usr/local/lib/node_modules/truffle/node_modules/web3/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
at null.handleError (/usr/local/lib/node_modules/truffle/node_modules/web3/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:532:5)
at ClientRequest.errorHandler (/usr/local/lib/node_modules/truffle/node_modules/web3/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:459:14)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:256:9)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1253:8)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickDomainCallback (node.js:397:17)
fs.js:549
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open './allFiredEvents'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at Object.<anonymous> (/Users/maiffany/graduate/mytest/solcover/runCoveredTests.js:60:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
From the solcover
directory, run
./node_modules/ethereumjs-testrpc/bin/testrpc
and
node -v
(and put the output here)
=_= I found there is no ethereumjs-testrpc in my node_modules directory. Maybe my node version is too old. I'll try to update my node later when my network works fine.
-bash: ./node_modules/ethereumjs-testrpc/bin/testrpc: No such file or directory
MINAHU-MC0:solcover maiffany$ node -v
v4.4.4```
Be sure you've run npm install
from the solcover
directory. You'll need to update your node version soon anyway when #19 gets merged, though.
Thank you for your time and help!
But so weird, I've use the latest version of node
and testrpc works fine. But it still cannot find the file allFiredEvents
.
My node
version is v7.3.0. v6.9.2 doesn't work either.
./node_modules/ethereumjs-testrpc/bin/testrpc: No such file or directory
Available Accounts
==================
(0) 0x0e4ee105d47be78df913df71a5ae1e8974d73232
(1) 0xba4deed46f17c2c441ba1f7158e274cb6b610a09
(2) 0xcf247271a9c1a858a46fe8c3a7e6b853c2b83b6f
(3) 0x433afd579d24b9140297d11fbe1617c1570edfd5
(4) 0xf6cbf07e69bd9f3265c831a5a6727afa9e58fcd2
(5) 0xfb72080de20a94cd7c9d390737ff9eaf939edf2d
(6) 0xbc92f3d3b084c9edc712d806a41717f391324261
(7) 0xfa0caf3ac1de00cb64e8cef4664bcdabe1781d1f
(8) 0x4feca5c06fee845e5c9fa76725eb1c640e85944d
(9) 0x4a5e52d5c7f81c66a15e0efcf860fb33c89ec8d2
Private Keys
==================
node ./runCoveredTests.js
cp: no such file or directory: ./../originalContracts/Migrations.sol
rm: no such file or directory: ./allFiredEvents
Compiling Add.sol...
Contract: Add
✓ should return 5 when add 2 and 3 (56ms)
1 passing (426ms)
fs.js:557
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open './allFiredEvents'
at Object.fs.openSync (fs.js:557:18)
at Object.fs.readFileSync (fs.js:467:33)
at Object.<anonymous> (/Users/maiffany/testcoverage/solcover/runCoveredTests.js:60:13)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:420:7)```
@maiffany That error happens when no coverage events are generated. At the moment there is an issue with solCover capturing events when methods use call
because a code patch broke (see #19 ). Could you try putting a nonsense statement in the body of your contract constructor: e.g
function Add() {
uint z = 1;
}
and seeing if solcover generates a basic report?
Finally!! it succeed!
Thank you so much!
It seems like the contract method sum
invoke failed by the test.js. I'll check how to write the right unit test myself.
Oh good!
I've now merged #19, so a git pull
, rm -r ./node_modules
, npm install
from the solcover
directory should get you running!
~That said, I'm a little suspicious of the claim line 5 is being run there - if that's still the case after the above update, I'll try and investigate.~ It's the constructor for the contract, of course it's being run. That'll teach me to try and be clever before breakfast.
Sorry for the problems, and thanks for the patch, @cgewecke.
I didn't write the test cast in the wrong way. I'm sure the method sum
has been invoked. But the coverage didn't show it.
my test.js. I modified 5 to 6, so the assert is false.
it("should return 5 when add 2 and 3", function() {
var add = Add.deployed();
return add.sum.call().then(function(res){
assert.equal(res.valueOf(), 6, "add result is 5");
});
});
});
The test result is:
This means that the sum
has been invoke. But the the coverage result shows it didn't.
That's the case even updating solcover, and running the commands in my previous reply? Can you upload your whole test project to a repo on github so I can try myself?
Here is my test project: https://github.com/maiffany/mytest
I'll try your commands in your previous reply.
So running
git clone https://github.com/maiffany/mytest
cd mytest
git clone https://github.com/JoinColony/solcover/
cd solcover
npm install
node ./runCoveredTests.js
I get
Yes! After I update the code, it works! Thanks!
Great, sorry again for the problems. Do make sure to raise any other issues you encounter using it though - it's still very new and a bit / a lot hacked together, so bug reports are very valuable for improving the code, which I definitely want to do!
Hi guys,
Sorry to chime in a while after this seems to have been resolved but I am getting very similar errors and have been debugging with no luck for a fair while now.
Any help is greatly appreciated, I really want to use this :)
Finally after no luck I resorted to the steps that worked as you mentioned working above: git clone https://github.com/maiffany/mytest cd mytest git clone https://github.com/JoinColony/solcover/ cd solcover npm install node ./runCoveredTests.js
and get the following output: Unknown network "test". See your Truffle configuration file for available networks.
As the command in runCoveredTests.js is noted as "shell.exec('truffle test --network test');"
I then updated mytest/truffle.js to the following, adding a network: module.exports = { build: { "index.html": "index.html", "app.js": [ "javascripts/app.js" ], "app.css": [ "stylesheets/app.css" ], "images/": "images/" }, rpc: { host: "localhost", port: 8545, gasPrice: 20e9, gas: 0xfffffff, }, networks: { test: {} } };
Rerun resulting in the following error: _Error: You must specify a networkid in your 'test' configuration in order to use this network.
Add a network_id: module.exports = { build: { "index.html": "index.html", "app.js": [ "javascripts/app.js" ], "app.css": [ "stylesheets/app.css" ], "images/": "images/" }, rpc: { host: "localhost", port: 8545, gasPrice: 20e9, gas: 0xfffffff, }, networks: { test: { *network_id: "",** } } };
Resulting in the following error: Error: Invalid JSON RPC response: ""
_./nodemodules/ethereumjs-testrpc/bin/testrpc:
adam@adam:~/Desktop/mytest/solcover$ node -v v7.6.0
Also getting this issue no matter what steps I take.
I want to use solcover to generate test coverage of my contract. I test it with the simple one:
And here is my test code:
But there are some errs when compile it.
Then i add compile version like this:
And now it pass the compile. But this time I got the error:
And in you runCoveredTests.js i found this:
I guess maybe it is this command that generate file "allFiredEvents". So i try this in my command line:
But i still can't find the file "allFiredEvents".
So where did i get wrong?