Ethereum Asked by LorenzoBerti on August 26, 2021
Hello I’m trying to make my first and simple test for get a variable from my first contract:
Truffle version: Truffle v4.1.14
Node: 8.12.0
pragma solidity ^0.4.4;
contract SimpleContract {
bytes32 hello = "hello";
function getHello() public view returns (bytes32){
return hello;
}
}
And I did a simple test like:
pragma solidity ^0.4.4;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/SimpleContract.sol";
contract TestSimpleContract {
function testGetHello() public {
SimpleContract w = SimpleContract(DeployedAddresses.SimpleContract());
bytes32 expected = "hello";
bytes32 hello = w.getHello();
Assert.equal(hello,expected, "SHould hello!");
}
}
And I have a Migrations:
var Simple = artifacts.require("SimpleContract");
module.exports = function(deployer) {
deployer.deploy(Simple);
};
And I have this truffle config
module.exports = {
networks: {
development: {
host: "localhost",
port: 7545,
network_id: "5777"
}
}
};
But I can’t understand and how figure out why it return this error:
1) TestSimpleContract
testGetHello:
Error: VM Exception while processing transaction: revert
at Object.InvalidResponse (C:UsersLorenzoAppDataRoamingnpmnode_modulestrufflebuildwebpack:~web3libweb3errors.js:38:1)
at C:UsersLorenzoAppDataRoamingnpmnode_modulestrufflebuildwebpack:~web3libweb3requestmanager.js:86:1
at C:UsersLorenzoAppDataRoamingnpmnode_modulestrufflebuildwebpack:packagestruffle-providerwrapper.js:134:1
at XMLHttpRequest.request.onreadystatechange (C:UsersLorenzoAppDataRoamingnpmnode_modulestrufflebuildwebpack:~web3libweb3httpprovider.js:128:1)
at XMLHttpRequestEventTarget.dispatchEvent (C:UsersLorenzoAppDataRoamingnpmnode_modulestrufflebuildwebpack:~xhr2libxhr2.js:64:1)
at XMLHttpRequest._setReadyState (C:UsersLorenzoAppDataRoamingnpmnode_modulestrufflebuildwebpack:~xhr2libxhr2.js:354:1)
at XMLHttpRequest._onHttpResponseEnd (C:UsersLorenzoAppDataRoamingnpmnode_modulestrufflebuildwebpack:~xhr2libxhr2.js:509:1)
at IncomingMessage. (C:UsersLorenzoAppDataRoamingnpmnode_modulestrufflebuildwebpack:~xhr2libxhr2.js:469:1)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickCallback (internal/process/next_tick.js:181:9)
The issue happend with ganache-cli
. In order to fix it you need to run ganache-cli
with networkId
> ganache-cli -i 5777
Answered by Aquila on August 26, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP