fix browser test

pull/3094/head
yann300 6 years ago
parent 084b171821
commit 7ea166da6c
  1. 2
      contracts/src/gmbh/company.sol
  2. 2
      contracts/src/gmbh/contract.sol
  3. 2
      contracts/src/gmbh/test.sol
  4. 2
      src/app/debugger/debugger/VmDebugger.js
  5. 16
      src/app/editor/example-contracts.js
  6. 2
      test-browser/tests/ballot.js
  7. 46
      test-browser/tests/compiling.js
  8. 9
      test-browser/tests/sharedFolderExplorer.js
  9. 55
      test-browser/tests/simpleContract.js
  10. 2
      test-browser/tests/staticanalysis.js
  11. 6
      test-browser/tests/units/testRecorder.js

@ -1,7 +1,7 @@
import "./contract.sol"; import "./contract.sol";
contract Assets { contract Assets {
uint[] proposals; uint[] proposals;
function add(uint8 _numProposals) { function add(uint8 _numProposals) public {
proposals.length = _numProposals; proposals.length = _numProposals;
} }
} }

@ -1,6 +1,6 @@
contract gmbh { contract gmbh {
uint[] proposals; uint[] proposals;
function register(uint8 _numProposals) { function register(uint8 _numProposals) public {
proposals.length = _numProposals; proposals.length = _numProposals;
} }
} }

@ -1,6 +1,6 @@
contract test { contract test {
function Test(uint8 _numProposals) { function Test(uint8 _numProposals) public {
proposals.length = _numProposals; proposals.length = _numProposals;
} }
} }

@ -195,7 +195,7 @@ class VmDebuggerLogic {
self.event.trigger('newTrace', []) self.event.trigger('newTrace', [])
}) })
self.debugger.event.register('callTreeReady', function () { self.debugger.event.register('callTreeReady', this, function () {
if (self.debugger.callTree.reducedTrace.length) { if (self.debugger.callTree.reducedTrace.length) {
return self.event.trigger('newCallTree', []) return self.event.trigger('newCallTree', [])
} }

@ -1,7 +1,6 @@
'use strict' 'use strict'
var ballot = `pragma solidity ^0.4.0; var ballot = `contract Ballot {
contract Ballot {
struct Voter { struct Voter {
uint weight; uint weight;
@ -18,7 +17,7 @@ contract Ballot {
Proposal[] proposals; Proposal[] proposals;
/// Create a new ballot with $(_numProposals) different proposals. /// Create a new ballot with $(_numProposals) different proposals.
function Ballot(uint8 _numProposals) public { constructor(uint8 _numProposals) public {
chairperson = msg.sender; chairperson = msg.sender;
voters[chairperson].weight = 1; voters[chairperson].weight = 1;
proposals.length = _numProposals; proposals.length = _numProposals;
@ -56,7 +55,7 @@ contract Ballot {
proposals[toProposal].voteCount += sender.weight; proposals[toProposal].voteCount += sender.weight;
} }
function winningProposal() public constant returns (uint8 _winningProposal) { function winningProposal() public view returns (uint8 _winningProposal) {
uint256 winningVoteCount = 0; uint256 winningVoteCount = 0;
for (uint8 prop = 0; prop < proposals.length; prop++) for (uint8 prop = 0; prop < proposals.length; prop++)
if (proposals[prop].voteCount > winningVoteCount) { if (proposals[prop].voteCount > winningVoteCount) {
@ -64,16 +63,17 @@ contract Ballot {
_winningProposal = prop; _winningProposal = prop;
} }
} }
}` }
`
var ballotTest = `pragma solidity ^0.4.7; var ballotTest = `
import "remix_tests.sol"; // this import is automatically injected by Remix. import "remix_tests.sol"; // this import is automatically injected by Remix.
import "./ballot.sol"; import "./ballot.sol";
contract test3 { contract test3 {
Ballot ballotToTest; Ballot ballotToTest;
function beforeAll () { function beforeAll () public {
ballotToTest = new Ballot(2); ballotToTest = new Ballot(2);
} }
@ -82,7 +82,7 @@ contract test3 {
Assert.equal(ballotToTest.winningProposal(), uint(1), "1 should be the winning proposal"); Assert.equal(ballotToTest.winningProposal(), uint(1), "1 should be the winning proposal");
} }
function checkWinninProposalWithReturnValue () public constant returns (bool) { function checkWinninProposalWithReturnValue () public view returns (bool) {
return ballotToTest.winningProposal() == 1; return ballotToTest.winningProposal() == 1;
} }
} }

@ -48,7 +48,7 @@ function runTests (browser, testData) {
.pause(2000) .pause(2000)
.perform(function (client, done) { .perform(function (client, done) {
console.log('goToVMtraceStep') console.log('goToVMtraceStep')
contractHelper.goToVMtraceStep(browser, 47, () => { contractHelper.goToVMtraceStep(browser, 55, () => {
done() done()
}) })
}) })

@ -89,12 +89,12 @@ function testReturnValues (browser, callback) {
"1": "bytes2: _b2 0x1223", "1": "bytes2: _b2 0x1223",
"2": "bytes3: _b3 0x000000", "2": "bytes3: _b3 0x000000",
"3": "bytes: _blit 0x123498", "3": "bytes: _blit 0x123498",
"4": "bytes5: _b5 0x0000043245", "4": "bytes5: _b5 0x0432450000",
"5": "bytes6: _b6 0x002345532532", "5": "bytes6: _b6 0x234553253200",
"6": "string: _str this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string", "6": "string: _str this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string",
"7": "bytes7: _b7 0x03252353253253", "7": "bytes7: _b7 0x03252353253253",
"8": "bytes22: _b22 0x00000000000000000000325235235325325325235325", "8": "bytes22: _b22 0x32523523532532532523532500000000000000000000",
"9": "bytes32: _b32 0x0000000000000000000000000000000000032523532532523532523532523532" "9": "bytes32: _b32 0x0325235325325235325235325235320000000000000000000000000000000000"
}`).pause(500).testFunction('retunValues3 - transact (not payable)', }`).pause(500).testFunction('retunValues3 - transact (not payable)',
'0x94c4b4324bad773dec29af3ffe26a698c32b5caf8a1eedf8889563158639d28a', '0x94c4b4324bad773dec29af3ffe26a698c32b5caf8a1eedf8889563158639d28a',
'[vm]\nfrom:0xca3...a733c\nto:testReturnValues.retunValues3() 0x5e7...26e9f\nvalue:0 wei\ndata:0x033...e0a7d\nlogs:0\nhash:0x94c...9d28a', null, `{ '[vm]\nfrom:0xca3...a733c\nto:testReturnValues.retunValues3() 0x5e7...26e9f\nvalue:0 wei\ndata:0x033...e0a7d\nlogs:0\nhash:0x94c...9d28a', null, `{
@ -137,7 +137,7 @@ function testInputValues (browser, callback) {
"indexed": true, "indexed": true,
"hash": "0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658" "hash": "0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658"
}, },
"3": "0x00001234", "3": "0x12340000",
"4": "test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test ", "4": "test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test ",
"_i": "-123", "_i": "-123",
"_u": "123", "_u": "123",
@ -145,7 +145,7 @@ function testInputValues (browser, callback) {
"indexed": true, "indexed": true,
"hash": "0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658" "hash": "0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658"
}, },
"_b": "0x00001234", "_b": "0x12340000",
"_notIndexed": "test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test ", "_notIndexed": "test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test ",
"length": 5 "length": 5
} }
@ -158,37 +158,37 @@ function testInputValues (browser, callback) {
// @TODO test: bytes8[3][] type as input // @TODO test: bytes8[3][] type as input
var sources = [ var sources = [
{'browser/Untitled.sol': {content: `pragma solidity ^0.4.0; {'browser/Untitled.sol': {content: `
contract TestContract { function f() returns (uint) { return 8; } contract TestContract { function f() public returns (uint) { return 8; }
function g() returns (uint, string, bool, uint) { function g() public returns (uint, string memory, bool, uint) {
uint payment = 345; uint payment = 345;
bool payed = true; bool payed = true;
string memory comment = "comment_comment_"; string memory comment = "comment_comment_";
uint month = 4; uint month = 4;
return (payment, comment, payed, month); } }`}}, return (payment, comment, payed, month); } }`}},
{'browser/returnValues.sol': {content: `pragma solidity ^0.4.0; {'browser/returnValues.sol': {content: `
contract testReturnValues { contract testReturnValues {
enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill } enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill }
function retunValues1 () returns (bool _b, uint _u, int _i, address _a) { function retunValues1 () public returns (bool _b, uint _u, int _i, address _a) {
_b = true; _b = true;
_u = 345; _u = 345;
_i = -345; _i = -345;
_a = msg.sender; _a = msg.sender;
} }
function retunValues2 () returns (byte _b, bytes2 _b2, bytes3 _b3, bytes _blit, bytes5 _b5, bytes6 _b6, string _str, bytes7 _b7, bytes22 _b22, bytes32 _b32) { function retunValues2 () public returns (byte _b, bytes2 _b2, bytes3 _b3, bytes memory _blit, bytes5 _b5, bytes6 _b6, string memory _str, bytes7 _b7, bytes22 _b22, bytes32 _b32) {
_b = 0x12; _b = 0x12;
_b2 = 0x1223; _b2 = 0x1223;
_b5 = 0x43245; _b5 = hex"043245";
_b6 = 0x2345532532; _b6 = hex"2345532532";
_b7 = 0x3252353253253; _b7 = hex"03252353253253";
_b22 = 0x325235235325325325235325; _b22 = hex"325235235325325325235325";
_b32 = 0x32523532532523532523532523532; _b32 = hex"032523532532523532523532523532";
_blit = hex"123498"; _blit = hex"123498";
_str = "this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string"; _str = "this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string _ this is a long string";
} }
function retunValues3 () returns (ActionChoices _en, int[5][] _a1) { function retunValues3 () public returns (ActionChoices _en, int[5][] memory _a1) {
_en = ActionChoices.GoStraight; _en = ActionChoices.GoStraight;
int[5][] memory a = new int[5][](3); int[5][] memory a = new int[5][](3);
a[0] = [int(1),-45,-78,56,60]; a[0] = [int(1),-45,-78,56,60];
@ -197,18 +197,18 @@ var sources = [
_a1 = a; _a1 = a;
} }
}`}}, }`}},
{'browser/inputValues.sol': {content: `pragma solidity ^0.4.0; {'browser/inputValues.sol': {content: `
contract test { contract test {
event event1(int _i, uint indexed _u, string indexed _str, bytes4 _b, string _notIndexed); event event1(int _i, uint indexed _u, string indexed _str, bytes4 _b, string _notIndexed);
function inputValue1 (uint _u, int _i, string _str) returns (uint _uret, int _iret, string _strret) { function inputValue1 (uint _u, int _i, string memory _str) public returns (uint _uret, int _iret, string memory _strret) {
_uret = _u; _uret = _u;
_iret = _i; _iret = _i;
_strret = _str; _strret = _str;
} }
function inputValue2 (uint[3] _n, bytes8[4] _b8) returns (uint[3] _nret, bytes8[4] _b8ret){ function inputValue2 (uint[3] memory _n, bytes8[4] memory _b8) public returns (uint[3] memory _nret, bytes8[4] memory _b8ret){
_nret = _n; _nret = _n;
_b8ret = _b8; _b8ret = _b8;
event1(-123, 123, "test", 0x1234, "test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test "); emit event1(-123, 123, "test", hex"1234", "test _ test _ test _ test test _ test test _ test test _ test test _ test test _ test test _ test ");
} }
}`}} }`}}
] ]

@ -6,23 +6,22 @@ var sauce = require('./sauce')
var assetsTestContract = `import "./contract.sol"; var assetsTestContract = `import "./contract.sol";
contract Assets { contract Assets {
uint[] proposals; uint[] proposals;
function add(uint8 _numProposals) { function add(uint8 _numProposals) public {
proposals.length = _numProposals; proposals.length = _numProposals;
} }
} }
` `
var gmbhTestContract = ` var gmbhTestContract = `contract gmbh {
contract gmbh {
uint[] proposals; uint[] proposals;
function register(uint8 _numProposals) { function register(uint8 _numProposals) public {
proposals.length = _numProposals; proposals.length = _numProposals;
} }
} }
` `
var sources = [ var sources = [
{ {
'localhost/folder1/contract2.sol': {content: 'contract test2 { function get () returns (uint) { return 11; }}'} 'localhost/folder1/contract2.sol': {content: 'contract test2 { function get () public returns (uint) { return 11; }}'}
}, },
{ {
'localhost/src/gmbh/company.sol': {content: assetsTestContract} 'localhost/src/gmbh/company.sol': {content: assetsTestContract}

@ -169,16 +169,15 @@ function testGitHubImport (browser, callback) {
} }
*/ */
var abstractENS = `pragma solidity ^0.4.0; var abstractENS = `
contract AbstractENS { contract AbstractENS {
function owner(bytes32 node) constant returns(address); function owner(bytes32 node) public view returns(address);
function resolver(bytes32 node) constant returns(address); function resolver(bytes32 node) public view returns(address);
function ttl(bytes32 node) constant returns(uint64); function ttl(bytes32 node) public view returns(uint64);
function setOwner(bytes32 node, address owner); function setOwner(bytes32 node, address owner) public;
function setSubnodeOwner(bytes32 node, bytes32 label, address owner); function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public;
function setResolver(bytes32 node, address resolver); function setResolver(bytes32 node, address resolver) public;
function setTTL(bytes32 node, uint64 ttl); function setTTL(bytes32 node, uint64 ttl) public;
// Logged when the owner of a node assigns a new owner to a subnode. // Logged when the owner of a node assigns a new owner to a subnode.
event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);
@ -198,8 +197,8 @@ var ENS = `pragma solidity ^0.4.0;
import './AbstractENS.sol'; import './AbstractENS.sol';
/** /**
* The ENS registry contract. * The ENS registry contract.
*/ */
contract ENS is AbstractENS { contract ENS is AbstractENS {
struct Record { struct Record {
address owner; address owner;
@ -211,35 +210,35 @@ contract ENS is AbstractENS {
// Permits modifications only by the owner of the specified node. // Permits modifications only by the owner of the specified node.
modifier only_owner(bytes32 node) { modifier only_owner(bytes32 node) {
if (records[node].owner != msg.sender) throw; if (records[node].owner != msg.sender) revert();
_; _;
} }
/** /**
* Constructs a new ENS registrar. * Constructs a new ENS registrar.
*/ */
function ENS() { constructor() public {
records[0].owner = msg.sender; records[0].owner = msg.sender;
} }
/** /**
* Returns the address that owns the specified node. * Returns the address that owns the specified node.
*/ */
function owner(bytes32 node) constant returns (address) { function owner(bytes32 node) public view returns (address) {
return records[node].owner; return records[node].owner;
} }
/** /**
* Returns the address of the resolver for the specified node. * Returns the address of the resolver for the specified node.
*/ */
function resolver(bytes32 node) constant returns (address) { function resolver(bytes32 node) public view returns (address) {
return records[node].resolver; return records[node].resolver;
} }
/** /**
* Returns the TTL of a node, and any records associated with it. * Returns the TTL of a node, and any records associated with it.
*/ */
function ttl(bytes32 node) constant returns (uint64) { function ttl(bytes32 node) public view returns (uint64) {
return records[node].ttl; return records[node].ttl;
} }
@ -249,8 +248,8 @@ contract ENS is AbstractENS {
* @param node The node to transfer ownership of. * @param node The node to transfer ownership of.
* @param owner The address of the new owner. * @param owner The address of the new owner.
*/ */
function setOwner(bytes32 node, address owner) only_owner(node) { function setOwner(bytes32 node, address owner) public only_owner(node) {
Transfer(node, owner); emit Transfer(node, owner);
records[node].owner = owner; records[node].owner = owner;
} }
@ -261,9 +260,9 @@ contract ENS is AbstractENS {
* @param label The hash of the label specifying the subnode. * @param label The hash of the label specifying the subnode.
* @param owner The address of the new owner. * @param owner The address of the new owner.
*/ */
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) only_owner(node) { function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public only_owner(node) {
var subnode = sha3(node, label); bytes32 subnode = keccak256(abi.encodePacked(node, label));
NewOwner(node, label, owner); emit NewOwner(node, label, owner);
records[subnode].owner = owner; records[subnode].owner = owner;
} }
@ -272,8 +271,8 @@ contract ENS is AbstractENS {
* @param node The node to update. * @param node The node to update.
* @param resolver The address of the resolver. * @param resolver The address of the resolver.
*/ */
function setResolver(bytes32 node, address resolver) only_owner(node) { function setResolver(bytes32 node, address resolver) public only_owner(node) {
NewResolver(node, resolver); emit NewResolver(node, resolver);
records[node].resolver = resolver; records[node].resolver = resolver;
} }
@ -282,8 +281,8 @@ contract ENS is AbstractENS {
* @param node The node to update. * @param node The node to update.
* @param ttl The TTL in seconds. * @param ttl The TTL in seconds.
*/ */
function setTTL(bytes32 node, uint64 ttl) only_owner(node) { function setTTL(bytes32 node, uint64 ttl) public only_owner(node) {
NewTTL(node, ttl); emit NewTTL(node, ttl);
records[node].ttl = ttl; records[node].ttl = ttl;
} }
}` }`
@ -310,14 +309,14 @@ var sources = [
}, },
{ {
'browser/Untitled5.sol': {content: `library lib { 'browser/Untitled5.sol': {content: `library lib {
function get () returns (uint) { function getInt () public view returns (uint) {
return 45; return 45;
} }
} }
contract test { contract test {
function get () constant returns (uint) { function get () public view returns (uint) {
return lib.get(); return lib.getInt();
} }
}`} }`}
} }

@ -11,7 +11,7 @@ contract test1 { address test = tx.origin; }
contract test2 {} contract test2 {}
contract TooMuchGas { contract TooMuchGas {
uint x; uint x;
function() { function() external {
x++; x++;
uint test; uint test;
uint test1; uint test1;

@ -61,11 +61,11 @@ module.exports = {
} }
} }
var sources = [{'browser/testRecorder.sol': {content: `pragma solidity ^0.4.0;contract testRecorder { var sources = [{'browser/testRecorder.sol': {content: `contract testRecorder {
function testRecorder(uint p) { constructor(uint p) public {
} }
function set (uint _p) { function set (uint _p) public {
} }
}`}}] }`}}]

Loading…
Cancel
Save