Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does any one know why come out of this error, please? #2595

Closed
xiongzhend opened this issue Mar 28, 2019 · 5 comments
Closed

Does any one know why come out of this error, please? #2595

xiongzhend opened this issue Mar 28, 2019 · 5 comments

Comments

@xiongzhend
Copy link

xiongzhend commented Mar 28, 2019


Simple contract, but got this issue

Transaction has been reverted by the EVM

Actual Results

Hi, everyone! I create a very simple contract as follow:

pragma solidity >=0.4.24 <0.6.0; 
contract Test {

// There is minimum and maximum bets.
uint constant MIN_BET = 0.01 ether;
uint constant MAX_AMOUNT = 300000 ether;

// 测试1
function getTest(uint modulo) external payable {

    // Validate input data ranges.
    uint amount = msg.value;
    require (modulo > 1 && modulo <= 100, "Modulo should be within range.");
    require (amount >= MIN_BET && amount <= MAX_AMOUNT, "Amount should be within range.");

}
}

then I use "truffle compile", "truffle migrate", after that, I wrote a test file as follow:

const assert = require('assert');
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));
const json = require('../build/contracts/Test.json');
const utils = require('ethereumjs-util');
let accounts;
let contract;
let manager;
let result;
const interface = json['abi'];
const bytecode = json['bytecode'];
const address = '0x059F708ffFB51719074349A172838285BF1C33BF';
beforeEach(async () => {
accounts = await web3.eth.getAccounts();
manager = accounts[0];
contract = new web3.eth.Contract(interface, address, {from: manager});
});
describe('Test', () => {
it('get test', async () => {
result = await contract.methods.getTest(100).send({
from: manager,
value: web3.utils.toWei('0.01', 'ether'),
gas: 500000
});
console.log('### result:');
console.log(result);
});
});

I run "mocha test", then got this

Error: Transaction has been reverted by the EVM:
{
"transactionHash": "0x6a21a921326725709e1d1cd549b862e9abc5faf691886d5c6d9081b89a2e9ff2",
"transactionIndex": 0,
"blockHash": "0x8ee0d6f54d2ea010d782400fa348e8b253e66a2f4ed54e04f36d992d326c5662",
"blockNumber": 6,
"from": "0x99aa63cceea343c81ccff19e9366a67a5d3635cc",
"to": "0x059f708fffb51719074349a172838285bf1c33bf",
"gasUsed": 21772,
"cumulativeGasUsed": 21772,
"contractAddress": null,
"logs": [],
"status": true,
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"v": "0x1b",
"r": "0xda47199fde41e787bffb63ef1ab2275362914ccb673aac1333911f4f6f30997e",
"s": "0x38faafb77a25155c758d7c3fc998b8c9486c83136ef8dbd445c1be4996041dfc"
}

Environment

  • Operating System: MacOS 10.14.4
  • Ethereum client: 8.1.23
  • Truffle version (truffle version): 4.1.15
  • node version (node --version): 8.14
  • npm version (npm --version): 6.5.0
@SwissArmyBud
Copy link

See #2542 for discussion

@nivida
Copy link
Contributor

nivida commented Mar 28, 2019

Got fixed by @SwissArmyBud and will be released asap.

@nivida nivida closed this as completed Mar 28, 2019
@nivida nivida mentioned this issue Mar 28, 2019
12 tasks
@xiongzhend
Copy link
Author

no, please don't close, I update 1.0.0-beta.51, and now every test with this happen:

  1. "before each" hook for "deploys a contract":
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

@xiongzhend
Copy link
Author

xiongzhend commented Mar 29, 2019

I push a simple project here, you can test it, thank you very much!
https://github.com/xiongzhend/MyContract
steps:

  1. git clone...
  2. npm install
  3. truffle compile --compile-all (just in case)
  4. mocha test (you need install mocha global)

@iheqi
Copy link

iheqi commented Mar 31, 2019

no, please don't close, I update 1.0.0-beta.51, and now every test with this happen:

  1. "before each" hook for "deploys a contract":
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

This is what I want to say too, mocha need a resolved result, but web3's return is not resolve. It work on 1.0.0-beta.48.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants