I am using truffle tests for my smart contract.I guess there is no problem with contracts because I can compile and deploy them in Remix.

I can also run truffle migrate --reset successfully, and it runs successfully sometimes, other times it gives the error:

node[26189]: ../src/timer_wrap.cc:107:static void node::{anonymous}::TimerWrap::Stop(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `HandleWrap::IsAlive(wrap)' failed.
 1: node::Abort() [node]
 2: 0x11e83db [node]
 3: 0x127169a [node]
 4: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
 5: 0xb7a9ac [node]
 6: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]
 7: 0x18df548042fd
Aborted (core dumped)

Truffle migrate --reset is behaving randomly.

But even if truffle migrate runs successfuly and I try to run test cases, I get error:

The contract code couldn't be stored, please check your gas amount

Compiling ./contracts/TradeWeapon.sol...
(node:26546) UnhandledPromiseRejectionWarning: Error: The contract code couldn't be stored, please check your gas amount.
    at Object.callback (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/contract.js:147:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/method.js:142:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:89:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-migrate/index.js:225:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:134:1
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
(node:26546) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:26546) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.



var Token = artifacts.require("./Token.sol")

contract('Trading', function(accounts){
  const  gasLimit = 6000000

  beforeEach(async function () {
    let token = await Token.deployed( {gas: gasLimit});


var Token = artifacts.require("./Token.sol")
var Tokenize = artifacts.require("./Tokenize.sol")
var Trade = artifacts.require("./Trade.sol")

module.exports =  function(deployer) {
  deployer.link(ConvertLib, MetaCoin);

  deployer.deploy(Token, {gas: 6000000}).then(()=>{
    deployer.deploy(Tokenize, {gas: 6000000}).then(() => {
      deployer.deploy(Trade, Tokenize.address, Token.address, {gas: 6000000});
  • Which chain do you connect to for testing? – Ha ĐANG Sep 12 '18 at 10:13
  • Do you insist on using truffle migrate, or would you also be willing to use truffle test directly? – goodvibration Sep 12 '18 at 10:27
  • Does this still happen if you remove the {gas: 6000000} option? – cleanunicorn Sep 12 '18 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.