Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Function calls that returns in a throw in testrpc crashes truffle #65

Closed
MrChico opened this issue Dec 19, 2015 · 6 comments
Closed

Function calls that returns in a throw in testrpc crashes truffle #65

MrChico opened this issue Dec 19, 2015 · 6 comments

Comments

@MrChico
Copy link

MrChico commented Dec 19, 2015

Here is a screenshot of what happens:
screenshot from 2015-12-17 15 15 27

Basically, whenever a function call ends up in a throw, truffle gives an error message. This makes you unable to test that contracts that should return a throw under certain conditions. Happens with testrpc, but not with geth.

@tcoulter
Copy link
Contributor

@MrChico What can I do to convince you to try out ethereumjs-testrpc?

@MrChico
Copy link
Author

MrChico commented Jan 15, 2016

Haha, I have actually moved to the js testrpc now. You underestimate your manipulative powers @tcoulter

@lastperson
Copy link

I think this one is related, please consider the following example:

contract('Tester', function(accounts) {
  it('should fail', function(done) {
    (new Promise(function(_rs, _rj) {
      setTimeout(function() { throw 'error'; }, 1);
    })).then(done).catch(done)
  });
  it('should be pending');
});

It results in a crash on first test, and never gets to the second.

Contract: MultiAccessTester

/usr/lib/node_modules/truffle/node_modules/solc/bin/soljson-latest.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](
error

The same suite

describe('Tester', function(accounts) {
  it('should fail', function(done) {
    (new Promise(function(_rs, _rj) {
      setTimeout(function() { throw 'error'; }, 1);
    })).then(done).catch(done)
  });
  it('should be pending');
});

is handled properly in mocha though:

MultiAccessTester
    1) should emit Called event
    - should be pending emit Called event


  0 passing (11ms)
  1 pending
  1 failing

  1) MultiAccessTester should emit Called event:
     Error: the string "error" was thrown, throw an Error :)

@tcoulter
Copy link
Contributor

tcoulter commented Mar 8, 2016

Hi @lastperson - Can you output more information about the first error message? Unfortunately the solc package likes to gobble all unhandled errors and then rethrow them. What you're seeing in the above error is the point in the code where the error is rethrown; however, you're not including the stack trace that follows it. Can you give me that stack trace? Thanks - that'll help me better understand the issue.

@lastperson
Copy link

Hi @tcoulter , thanks for quick reply. The problem is that this is the only output I get. Terminal prompt line appears right after the error word.

@tcoulter
Copy link
Contributor

Hey there. I'm going to close this issue because it's so old, and Truffle has been significantly revamped since then. If you're still having issues, don't hesitate to ask in the [Truffle Gitter}(https://gitter.im/ConsenSys/truffle) or file a new ticket. Thanks!

nakajo2011 pushed a commit to nakajo2011/truffle that referenced this issue Aug 7, 2018
Merge develop -> master for Truffle 4 release
nakajo2011 pushed a commit to nakajo2011/truffle that referenced this issue Aug 7, 2018
…f-arguments

Use _.assign instead of _.merge
nakajo2011 pushed a commit to nakajo2011/truffle that referenced this issue Aug 7, 2018
Support unresolved link references in contract bytecode
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants