Skip to content

Commit

Permalink
HelloWorld Truffle test fix (#648)
Browse files Browse the repository at this point in the history
* tests/truffle/HelloWorld: Fix HelloWorld test to run with ganache-cli

* web3: Remove TAG handling from estimateGas for now

* tests/failing.truffle: Remove HelloWorld from failing list

* tests/truffle/HelloWorld/contracts/Migrations: Make consistent solidity version

* web3: Create default block parameter for estimateGas

* web3: Add default block for eth_call and fix eth_sign

Co-authored-by: rv-jenkins <[email protected]>
  • Loading branch information
gtrepta and rv-jenkins committed Jan 9, 2020
1 parent a12d133 commit 9931dc8
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 5 deletions.
1 change: 0 additions & 1 deletion tests/failing.truffle
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
tests/truffle/HelloWorld/truffle-config.js
tests/truffle/openzeppelin-contracts/truffle-config.js
23 changes: 23 additions & 0 deletions tests/truffle/HelloWorld/contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pragma solidity ^0.5.8;

contract Migrations {
address public owner;
uint public last_completed_migration;

constructor() public {
owner = msg.sender;
}

modifier restricted() {
if (msg.sender == owner) _;
}

function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}

function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
4 changes: 2 additions & 2 deletions tests/truffle/HelloWorld/migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var HelloWorld = artifacts.require("HelloWorld");
const Migrations = artifacts.require("Migrations");

module.exports = function(deployer) {
deployer.deploy(HelloWorld);
deployer.deploy(Migrations);
};
5 changes: 5 additions & 0 deletions tests/truffle/HelloWorld/migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var HelloWorld = artifacts.require("HelloWorld");

module.exports = function(deployer) {
deployer.deploy(HelloWorld);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import "truffle/DeployedAddresses.sol";
import "../contracts/HelloWorld.sol";

contract TestHelloWorld {
string expected = "hello world";

function testgetMessage() public {
HelloWorld hw = HelloWorld(DeployedAddresses.HelloWorld());
Assert.equal("hello world", hw.getMessage(), "String should match");
Assert.equal(hw.getMessage(), expected, "String should match");
}
}
8 changes: 7 additions & 1 deletion web3.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ WEB3 JSON RPC
syntax KItem ::= "#eth_sign"
// ----------------------------
rule <k> #eth_sign => #signMessage(KEY, #hashMessage(#unparseByteStack(#parseByteStack(MESSAGE)))) ... </k>
rule <k> #eth_sign => #signMessage(#unparseByteStack(#asByteStack(KEY)), #hashMessage(Hex2Raw(MESSAGE))) ... </k>
<params> [ ACCTADDR, MESSAGE, .JSONs ] </params>
<accountKeys>... #parseHexWord(ACCTADDR) |-> KEY ...</accountKeys>
Expand Down Expand Up @@ -1264,6 +1264,9 @@ Transaction Execution
```k
syntax KItem ::= "#eth_call"
// ----------------------------
rule <k> #eth_call ... </k>
<params> [ { _ }, (.JSONs => "pending", .JSONs) ] </params>
rule <k> #eth_call
=> #pushNetworkState
~> #setMode NOGAS
Expand Down Expand Up @@ -1332,6 +1335,9 @@ Transaction Execution
```k
syntax KItem ::= "#eth_estimateGas"
// -----------------------------------
rule <k> #eth_estimateGas ... </k>
<params> [ { _ }, (.JSONs => "pending", .JSONs) ] </params>
rule <k> #eth_estimateGas
=> #pushNetworkState
~> #loadTx J
Expand Down

0 comments on commit 9931dc8

Please sign in to comment.