Merge branch 'next' into develop

This commit is contained in:
Iuri Matias 2017-10-22 08:37:24 -04:00
commit f3a8e68c60
25 changed files with 176 additions and 129 deletions

View File

@ -12,7 +12,8 @@
"rpcCorsDomain": "http://localhost:8000", "rpcCorsDomain": "http://localhost:8000",
"account": { "account": {
"password": "config/development/password" "password": "config/development/password"
} },
"wsOrigins": "http://localhost:8000"
}, },
"testnet": { "testnet": {
"enabled": true, "enabled": true,

View File

@ -2,6 +2,11 @@
"default": { "default": {
"enabled": true, "enabled": true,
"provider": "whisper", "provider": "whisper",
"available_providers": ["whisper", "orbit"] "available_providers": ["whisper", "orbit"],
"connection": {
"host": "localhost",
"port": 8546,
"type": "ws"
}
} }
} }

View File

@ -1,5 +1,18 @@
{ {
"default": { "default": {
"versions": {
"web3.js": "1.0.0-beta",
"solc": "0.4.18"
},
"deployment": {
"host": "localhost",
"port": 8545,
"type": "rpc"
},
"dappConnection": [
"$WEB3",
"http://localhost:8545"
],
"gas": "auto", "gas": "auto",
"contracts": { "contracts": {
} }

View File

@ -11,6 +11,7 @@
"enabled": true, "enabled": true,
"provider": "ipfs", "provider": "ipfs",
"host": "localhost", "host": "localhost",
"port": 5001 "port": 5001,
"getUrl": "http://localhost:8080/ipfs/"
} }
} }

View File

@ -1,16 +1,16 @@
pragma solidity ^0.4.7; pragma solidity ^0.4.18;
contract SimpleStorage { contract SimpleStorage {
uint public storedData; uint public storedData;
function SimpleStorage(uint initialValue) { function SimpleStorage(uint initialValue) public {
storedData = initialValue; storedData = initialValue;
} }
function set(uint x) { function set(uint x) public {
storedData = x; storedData = x;
} }
function get() constant returns (uint retVal) { function get() public view returns (uint retVal) {
return storedData; return storedData;
} }

View File

@ -12,7 +12,8 @@
"rpcCorsDomain": "http://localhost:8000", "rpcCorsDomain": "http://localhost:8000",
"account": { "account": {
"password": "config/development/password" "password": "config/development/password"
} },
"wsOrigins": "http://localhost:8000"
}, },
"testnet": { "testnet": {
"enabled": true, "enabled": true,

View File

@ -2,6 +2,11 @@
"default": { "default": {
"enabled": true, "enabled": true,
"provider": "whisper", "provider": "whisper",
"available_providers": ["whisper", "orbit"] "available_providers": ["whisper", "orbit"],
"connection": {
"host": "localhost",
"port": 8546,
"type": "ws"
}
} }
} }

View File

@ -1,5 +1,18 @@
{ {
"default": { "default": {
"versions": {
"web3.js": "1.0.0-beta",
"solc": "0.4.18"
},
"deployment": {
"host": "localhost",
"port": 8545,
"type": "rpc"
},
"dappConnection": [
"$WEB3",
"http://localhost:8545"
],
"gas": "auto", "gas": "auto",
"contracts": { "contracts": {
"SimpleStorage": { "SimpleStorage": {

View File

@ -11,6 +11,7 @@
"enabled": true, "enabled": true,
"provider": "ipfs", "provider": "ipfs",
"host": "localhost", "host": "localhost",
"port": 5001 "port": 5001,
"getUrl": "http://localhost:8080/ipfs/"
} }
} }

View File

@ -58,9 +58,9 @@ author = u'Iuri Matias'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = u'2.5' version = u'2.6'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = u'2.5.2' release = u'2.6.0'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View File

@ -43,9 +43,6 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ // expose the module cache /******/ // expose the module cache
/******/ __webpack_require__.c = installedModules; /******/ __webpack_require__.c = installedModules;
/******/ /******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports /******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) { /******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) { /******/ if(!__webpack_require__.o(exports, name)) {
@ -100,6 +97,7 @@ EmbarkJS.isNewWeb3 = function() {
EmbarkJS.Contract = function(options) { EmbarkJS.Contract = function(options) {
var self = this; var self = this;
var i, abiElement; var i, abiElement;
var ContractClass;
this.abi = options.abi; this.abi = options.abi;
this.address = options.address; this.address = options.address;
@ -110,14 +108,12 @@ EmbarkJS.Contract = function(options) {
// TODO: // TODO:
// add default **from** address // add default **from** address
// add gasPrice // add gasPrice
var ContractClass = new this.web3.eth.Contract(this.abi, this.address); ContractClass = new this.web3.eth.Contract(this.abi, this.address);
ContractClass.setProvider(this.web3.currentProvider); ContractClass.setProvider(this.web3.currentProvider);
return ContractClass; return ContractClass;
} else { } else {
ContractClass = this.web3.eth.contract(this.abi);
var ContractClass = this.web3.eth.contract(this.abi);
this.eventList = []; this.eventList = [];
@ -444,7 +440,7 @@ EmbarkJS.Messages.setProvider = function(provider, options) {
var self = this; var self = this;
var ipfs; var ipfs;
if (provider === 'whisper') { if (provider === 'whisper') {
this.providerName = 'whisper' this.providerName = 'whisper';
this.currentMessages = EmbarkJS.Messages.Whisper; this.currentMessages = EmbarkJS.Messages.Whisper;
let provider; let provider;
if (options === undefined) { if (options === undefined) {
@ -473,7 +469,7 @@ EmbarkJS.Messages.setProvider = function(provider, options) {
self.currentMessages.whisperVersion = self.currentMessages.web3.version.whisper; self.currentMessages.whisperVersion = self.currentMessages.web3.version.whisper;
}); });
} else if (provider === 'orbit') { } else if (provider === 'orbit') {
this.providerName = 'orbit' this.providerName = 'orbit';
this.currentMessages = EmbarkJS.Messages.Orbit; this.currentMessages = EmbarkJS.Messages.Orbit;
if (options === undefined) { if (options === undefined) {
ipfs = HaadIpfsApi('localhost', '5001'); ipfs = HaadIpfsApi('localhost', '5001');
@ -502,11 +498,12 @@ EmbarkJS.Messages.listenTo = function(options) {
EmbarkJS.Messages.Whisper = {}; EmbarkJS.Messages.Whisper = {};
EmbarkJS.Messages.Whisper.sendMessage = function(options) { EmbarkJS.Messages.Whisper.sendMessage = function(options) {
var topics, data, ttl, priority, payload;
if (EmbarkJS.Messages.isNewWeb3()) { if (EmbarkJS.Messages.isNewWeb3()) {
var topics = options.topic || options.topics; topics = options.topic || options.topics;
var data = options.data || options.payload; data = options.data || options.payload;
var ttl = options.ttl || 100; ttl = options.ttl || 100;
var priority = options.priority || 1000; priority = options.priority || 1000;
var powTime = options.powTime || 3; var powTime = options.powTime || 3;
var powTarget = options.powTarget || 0.5; var powTarget = options.powTarget || 0.5;
@ -520,7 +517,7 @@ EmbarkJS.Messages.Whisper.sendMessage = function(options) {
topics = this.web3.utils.toHex(topics).slice(0, 10); topics = this.web3.utils.toHex(topics).slice(0, 10);
var payload = JSON.stringify(data); payload = JSON.stringify(data);
let message = { let message = {
symKeyID: this.symKeyID, // encrypts using the sym key ID symKeyID: this.symKeyID, // encrypts using the sym key ID
@ -534,11 +531,11 @@ EmbarkJS.Messages.Whisper.sendMessage = function(options) {
this.web3.shh.post(message, function() { }); this.web3.shh.post(message, function() { });
} else { } else {
var topics = options.topic || options.topics; topics = options.topic || options.topics;
var data = options.data || options.payload; data = options.data || options.payload;
ttl = options.ttl || 100;
priority = options.priority || 1000;
var identity = options.identity || this.identity || web3.shh.newIdentity(); var identity = options.identity || this.identity || web3.shh.newIdentity();
var ttl = options.ttl || 100;
var priority = options.priority || 1000;
var _topics; var _topics;
if (topics === undefined) { if (topics === undefined) {
@ -556,7 +553,7 @@ EmbarkJS.Messages.Whisper.sendMessage = function(options) {
} }
topics = _topics; topics = _topics;
var payload = JSON.stringify(data); payload = JSON.stringify(data);
var message; var message;
message = { message = {
@ -567,13 +564,14 @@ EmbarkJS.Messages.Whisper.sendMessage = function(options) {
priority: priority priority: priority
}; };
return EmbarkJS.Messages.currentMessages.web3.shh.post(message, function() { console.log("message sent") }); return EmbarkJS.Messages.currentMessages.web3.shh.post(message, function() { });
} }
}; };
EmbarkJS.Messages.Whisper.listenTo = function(options) { EmbarkJS.Messages.Whisper.listenTo = function(options) {
var topics, _topics, messageEvents;
if (EmbarkJS.Messages.isNewWeb3()) { if (EmbarkJS.Messages.isNewWeb3()) {
var messageEvents = function() { messageEvents = function() {
this.cb = function() {}; this.cb = function() {};
}; };
@ -589,8 +587,8 @@ EmbarkJS.Messages.Whisper.listenTo = function(options) {
this.filter.stopWatching(); this.filter.stopWatching();
}; };
var topics = options.topic || options.topics; topics = options.topic || options.topics;
var _topics = []; _topics = [];
let promise = new messageEvents(); let promise = new messageEvents();
@ -621,10 +619,10 @@ EmbarkJS.Messages.Whisper.listenTo = function(options) {
return promise; return promise;
} else { } else {
var topics = options.topic || options.topics; topics = options.topic || options.topics;
var _topics = []; _topics = [];
var messageEvents = function() { messageEvents = function() {
this.cb = function() {}; this.cb = function() {};
}; };
@ -673,7 +671,7 @@ EmbarkJS.Messages.Whisper.listenTo = function(options) {
return promise; return promise;
} }
} };
EmbarkJS.Messages.Orbit = {}; EmbarkJS.Messages.Orbit = {};

View File

@ -162,7 +162,9 @@ class GethCommands {
function whisper(callback) { function whisper(callback) {
if (config.whisper) { if (config.whisper) {
rpc_api.push('shh'); rpc_api.push('shh');
ws_api.push('shh'); if (ws_api.indexOf('shh') === -1) {
ws_api.push('shh');
}
return callback(null, "--shh "); return callback(null, "--shh ");
} }
callback(""); callback("");

View File

@ -28,28 +28,28 @@ class CodeGenerator {
let self = this; let self = this;
// deprecated events; to remove in embark 2.7.0 // deprecated events; to remove in embark 2.7.0
this.events.setCommandHandler('abi-vanila', function(cb) { this.events.setCommandHandlerOnce('abi-vanila', function(cb) {
let vanillaABI = self.generateABI({useEmbarkJS: false}); let vanillaABI = self.generateABI({useEmbarkJS: false});
let contractsJSON = self.generateContractsJSON(); let contractsJSON = self.generateContractsJSON();
cb(vanillaABI, contractsJSON); cb(vanillaABI, contractsJSON);
}); });
this.events.setCommandHandler('abi', function(cb) { this.events.setCommandHandlerOnce('abi', function(cb) {
let embarkJSABI = self.generateABI({useEmbarkJS: true}); let embarkJSABI = self.generateABI({useEmbarkJS: true});
let contractsJSON = self.generateContractsJSON(); let contractsJSON = self.generateContractsJSON();
cb(embarkJSABI, contractsJSON); cb(embarkJSABI, contractsJSON);
}); });
this.events.setCommandHandler('abi-contracts-vanila', function(cb) { this.events.setCommandHandlerOnce('abi-contracts-vanila', function(cb) {
let vanillaContractsABI = self.generateContracts(false, true, false); let vanillaContractsABI = self.generateContracts(false, true, false);
let contractsJSON = self.generateContractsJSON(); let contractsJSON = self.generateContractsJSON();
cb(vanillaContractsABI, contractsJSON); cb(vanillaContractsABI, contractsJSON);
}); });
this.events.setCommandHandler('abi-vanila-deployment', function(cb) { this.events.setCommandHandlerOnce('abi-vanila-deployment', function(cb) {
let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true}); let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true});
let contractsJSON = self.generateContractsJSON(); let contractsJSON = self.generateContractsJSON();
@ -57,35 +57,34 @@ class CodeGenerator {
}); });
// new events // new events
this.events.setCommandHandler('code-vanila', function(cb) { this.events.setCommandHandlerOnce('code-vanila', function(cb) {
let vanillaABI = self.generateABI({useEmbarkJS: false}); let vanillaABI = self.generateABI({useEmbarkJS: false});
let contractsJSON = self.generateContractsJSON(); let contractsJSON = self.generateContractsJSON();
cb(vanillaABI, contractsJSON); cb(vanillaABI, contractsJSON);
}); });
this.events.setCommandHandler('code', function(cb) { this.events.setCommandHandlerOnce('code', function(cb) {
let embarkJSABI = self.generateABI({useEmbarkJS: true}); let embarkJSABI = self.generateABI({useEmbarkJS: true});
let contractsJSON = self.generateContractsJSON(); let contractsJSON = self.generateContractsJSON();
cb(embarkJSABI, contractsJSON); cb(embarkJSABI, contractsJSON);
}); });
this.events.setCommandHandler('code-contracts-vanila', function(cb) { this.events.setCommandHandlerOnce('code-contracts-vanila', function(cb) {
let vanillaContractsABI = self.generateContracts(false, true, false); let vanillaContractsABI = self.generateContracts(false, true, false);
let contractsJSON = self.generateContractsJSON(); let contractsJSON = self.generateContractsJSON();
cb(vanillaContractsABI, contractsJSON); cb(vanillaContractsABI, contractsJSON);
}); });
this.events.setCommandHandler('code-vanila-deployment', function(cb) { this.events.setCommandHandlerOnce('code-vanila-deployment', function(cb) {
let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true}); let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true});
let contractsJSON = self.generateContractsJSON(); let contractsJSON = self.generateContractsJSON();
cb(vanillaABI, contractsJSON); cb(vanillaABI, contractsJSON);
}); });
} }
generateProvider(isDeployment) { generateProvider(isDeployment) {
@ -222,8 +221,6 @@ class CodeGenerator {
result += Templates.exec_when_env_loaded({block: block}); result += Templates.exec_when_env_loaded({block: block});
} }
console.log(result);
return result; return result;
} }

View File

@ -79,7 +79,7 @@ Config.prototype.loadContractsConfigFile = function() {
var configObject = { var configObject = {
"versions": { "versions": {
"web3.js": "0.19.1", "web3.js": "0.19.1",
"solc": "0.4.17" "solc": "0.4.18"
}, },
"deployment": { "deployment": {
"host": "localhost", "host": "localhost",

View File

@ -42,4 +42,11 @@ EventEmitter.prototype.setCommandHandler = function(requestName, cb) {
}); });
}; };
EventEmitter.prototype.setCommandHandlerOnce = function(requestName, cb) {
log("setting command handler for: ", requestName);
return this.once('request:' + requestName, function(_cb) {
cb.call(this, _cb);
});
};
module.exports = EventEmitter; module.exports = EventEmitter;

View File

@ -3,7 +3,7 @@
"version": "2.6.0", "version": "2.6.0",
"description": "Embark is a framework that allows you to easily develop and deploy DApps", "description": "Embark is a framework that allows you to easily develop and deploy DApps",
"scripts": { "scripts": {
"test": "grunt jshint && mocha test/ --no-timeouts" "test": "grunt jshint && mocha test/ --no-timeouts && cd test_app/ && npm install && ../bin/embark test"
}, },
"bin": { "bin": {
"embark": "./bin/embark" "embark": "./bin/embark"
@ -33,7 +33,7 @@
"promptly": "^2.1.0", "promptly": "^2.1.0",
"serve-static": "^1.11.1", "serve-static": "^1.11.1",
"shelljs": "^0.5.0", "shelljs": "^0.5.0",
"solc": "0.4.17", "solc": "0.4.18",
"tar": "^3.1.5", "tar": "^3.1.5",
"toposort": "^1.0.0", "toposort": "^1.0.0",
"underscore": "^1.8.3", "underscore": "^1.8.3",

View File

@ -1,9 +1,9 @@
pragma solidity ^0.4.11; pragma solidity ^0.4.18;
contract AnotherStorage { contract AnotherStorage {
address public simpleStorageAddress; address public simpleStorageAddress;
address simpleStorageAddress2; address simpleStorageAddress2;
function AnotherStorage(address addr) { function AnotherStorage(address addr) public {
simpleStorageAddress = addr; simpleStorageAddress = addr;
} }

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.11; pragma solidity ^0.4.18;
/** /**
* @title Ownable * @title Ownable
@ -13,7 +13,7 @@ contract Ownable {
* @dev The Ownable constructor sets the original `owner` of the contract to the sender * @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account. * account.
*/ */
function Ownable() { function Ownable() public {
owner = msg.sender; owner = msg.sender;
} }
@ -23,7 +23,7 @@ contract Ownable {
*/ */
modifier onlyOwner() { modifier onlyOwner() {
if (msg.sender != owner) { if (msg.sender != owner) {
throw; revert();
} }
_; _;
} }
@ -33,7 +33,7 @@ contract Ownable {
* @dev Allows the current owner to transfer control of the contract to a newOwner. * @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to. * @param newOwner The address to transfer ownership to.
*/ */
function transferOwnership(address newOwner) onlyOwner { function transferOwnership(address newOwner) public onlyOwner {
if (newOwner != address(0)) { if (newOwner != address(0)) {
owner = newOwner; owner = newOwner;
} }

View File

@ -1,29 +1,29 @@
pragma solidity ^0.4.7; pragma solidity ^0.4.18;
import "ownable.sol"; import "ownable.sol";
contract SimpleStorage is Ownable { contract SimpleStorage is Ownable {
uint public storedData; uint public storedData;
function() payable { } function() public payable { }
function SimpleStorage(uint initialValue) { function SimpleStorage(uint initialValue) public {
storedData = initialValue; storedData = initialValue;
} }
function set(uint x) { function set(uint x) public {
storedData = x; storedData = x;
} }
function set2(uint x, uint unusedGiveWarning) onlyOwner { function set2(uint x, uint unusedGiveWarning) public onlyOwner {
storedData = x; storedData = x;
} }
function get() constant returns (uint retVal) { function get() public view returns (uint retVal) {
return storedData; return storedData;
} }
function getS() constant returns (string d) { function getS() public pure returns (string d) {
return "hello"; return "hello";
} }

View File

@ -1,8 +1,8 @@
pragma solidity ^0.4.11; pragma solidity ^0.4.18;
library ZAMyLib { library ZAMyLib {
function add(uint _a, uint _b) returns (uint _c) { function add(uint _a, uint _b) public pure returns (uint _c) {
return _a + _b; return _a + _b;
} }
@ -10,7 +10,7 @@ library ZAMyLib {
contract Test { contract Test {
function testAdd() constant returns (uint _result) { function testAdd() public pure returns (uint _result) {
return ZAMyLib.add(1, 2); return ZAMyLib.add(1, 2);
} }

View File

@ -1,6 +1,6 @@
// https://github.com/nexusdev/erc20/blob/master/contracts/base.sol // https://github.com/nexusdev/erc20/blob/master/contracts/base.sol
pragma solidity ^0.4.2; pragma solidity ^0.4.18;
contract Token { contract Token {
event Transfer(address indexed from, address indexed to, uint value); event Transfer(address indexed from, address indexed to, uint value);
@ -10,39 +10,39 @@ contract Token {
mapping( address => mapping( address => uint ) ) _approvals; mapping( address => mapping( address => uint ) ) _approvals;
uint public _supply; uint public _supply;
//uint public _supply2; //uint public _supply2;
function Token( uint initial_balance ) { function Token( uint initial_balance ) public {
_balances[msg.sender] = initial_balance; _balances[msg.sender] = initial_balance;
_supply = initial_balance; _supply = initial_balance;
} }
function totalSupply() constant returns (uint supply) { function totalSupply() public constant returns (uint supply) {
return _supply; return _supply;
} }
function balanceOf( address who ) constant returns (uint value) { function balanceOf( address who ) public constant returns (uint value) {
return _balances[who]; return _balances[who];
} }
function transfer( address to, uint value) returns (bool ok) { function transfer( address to, uint value) public returns (bool ok) {
if( _balances[msg.sender] < value ) { if( _balances[msg.sender] < value ) {
throw; revert();
} }
if( !safeToAdd(_balances[to], value) ) { if( !safeToAdd(_balances[to], value) ) {
throw; revert();
} }
_balances[msg.sender] -= value; _balances[msg.sender] -= value;
_balances[to] += value; _balances[to] += value;
Transfer( msg.sender, to, value ); Transfer( msg.sender, to, value );
return true; return true;
} }
function transferFrom( address from, address to, uint value) returns (bool ok) { function transferFrom( address from, address to, uint value) public returns (bool ok) {
// if you don't have enough balance, throw // if you don't have enough balance, throw
if( _balances[from] < value ) { if( _balances[from] < value ) {
throw; revert();
} }
// if you don't have approval, throw // if you don't have approval, throw
if( _approvals[from][msg.sender] < value ) { if( _approvals[from][msg.sender] < value ) {
throw; revert();
} }
if( !safeToAdd(_balances[to], value) ) { if( !safeToAdd(_balances[to], value) ) {
throw; revert();
} }
// transfer and return true // transfer and return true
_approvals[from][msg.sender] -= value; _approvals[from][msg.sender] -= value;
@ -51,16 +51,16 @@ contract Token {
Transfer( from, to, value ); Transfer( from, to, value );
return true; return true;
} }
function approve(address spender, uint value) returns (bool ok) { function approve(address spender, uint value) public returns (bool ok) {
// TODO: should increase instead // TODO: should increase instead
_approvals[msg.sender][spender] = value; _approvals[msg.sender][spender] = value;
Approval( msg.sender, spender, value ); Approval( msg.sender, spender, value );
return true; return true;
} }
function allowance(address owner, address spender) constant returns (uint _allowance) { function allowance(address owner, address spender) public constant returns (uint _allowance) {
return _approvals[owner][spender]; return _approvals[owner][spender];
} }
function safeToAdd(uint a, uint b) internal returns (bool) { function safeToAdd(uint a, uint b) internal pure returns (bool) {
return (a + b >= a); return (a + b >= a);
} }
} }

View File

@ -1,53 +1,56 @@
$(document).ready(function() { $(document).ready(function() {
async.waterfall([ document.getElementById("runTests").onclick = function() {
function test1(callback) { async.waterfall([
AnotherStorage.simpleStorageAddress().then(function(simpleStorageAddress) { function test1(callback) {
$("#tests").append("<br>test 1: " + (simpleStorageAddress === SimpleStorage.address)); AnotherStorage.methods.simpleStorageAddress().call().then(function(simpleStorageAddress) {
callback(); $("#tests").append("<br>test 1: " + (simpleStorageAddress === SimpleStorage._address));
});
},
function test2(callback) {
SimpleStorage.storedData().then(function(result) {
$("#tests").append("<br>test 2 (true first time): " + (result.toNumber() === 100));
$("#tests").append("<br>test 2 (true after): " + (result.toNumber() === 150));
callback();
});
},
function test3(callback) {
SimpleStorage.set(150).then(function() {
SimpleStorage.get().then(function(result) {
$("#tests").append("<br>test 3: " + (result.toNumber() === 150));
callback(); callback();
}); });
}); },
}, function test2(callback) {
function test4(callback) { SimpleStorage.methods.storedData().call().then(function(result) {
$("#tests").append("<br>test 4: " + (Token.address === "undefined")); $("#tests").append("<br>test 2 (true first time): " + (result === "100"));
$("#tests").append("<br>test 4: " + (MyToken.address !== undefined)); $("#tests").append("<br>test 2 (true after): " + (result === "150"));
$("#tests").append("<br>test 4: " + (MyToken2.address !== undefined)); callback();
callback(); });
}, },
function test5(callback) { function test3(callback) {
MyToken._supply().then(function(result) { SimpleStorage.methods.set(150).send({from: web3.eth.defaultAccount}).then(function() {
$("#tests").append("<br>test 5: " + (result.toNumber() === 1000)); SimpleStorage.methods.get().call().then(function(result) {
$("#tests").append("<br>test 3: " + (result === "150"));
callback();
});
});
},
function test4(callback) {
$("#tests").append("<br>test 4: " + (Token._address === null));
$("#tests").append("<br>test 4: " + (MyToken._address !== undefined));
$("#tests").append("<br>test 4: " + (MyToken2._address !== undefined));
callback(); callback();
}); },
}, function test5(callback) {
function test6(callback) { MyToken.methods._supply().call().then(function(result) {
MyToken2._supply().then(function(result) { $("#tests").append("<br>test 5: " + (result === "1000"));
$("#tests").append("<br>test 6: " + (result.toNumber() === 2000)); callback();
});
},
function test6(callback) {
MyToken2.methods._supply().call().then(function(result) {
$("#tests").append("<br>test 6: " + (result === "2000"));
callback();
});
},
function test7(callback) {
$("#tests").append("<br>test 7: " + (AlreadyDeployedToken._address === "0xeCE374063fE5Cc7EFbACA0a498477CaDA94E5AD6"));
callback(); callback();
}); }
}, ], function (err, result) {
function test7(callback) {
$("#tests").append("<br>test 7: " + (AlreadyDeployedToken.address === "0x123"));
callback();
}
], function (err, result) {
$("#tests").append("<br>done"); $("#tests").append("<br>done");
}); });
};
}); });

View File

@ -6,6 +6,7 @@
</head> </head>
<body class="container"> <body class="container">
<button id="runTests">Run Tests</button>
<div id="tests"></div> <div id="tests"></div>
</body> </body>

View File

@ -2,7 +2,7 @@
"default": { "default": {
"versions": { "versions": {
"web3.js": "1.0.0-beta", "web3.js": "1.0.0-beta",
"solc": "0.4.17" "solc": "0.4.18"
}, },
"deployment": { "deployment": {
"host": "localhost", "host": "localhost",

View File

@ -12,7 +12,6 @@
"devDependencies": {}, "devDependencies": {},
"dependencies": { "dependencies": {
"embark-babel": "^1.0.0", "embark-babel": "^1.0.0",
"embark-service": "./extensions/embark-service", "embark-service": "./extensions/embark-service"
"ethereumjs-testrpc": "^3.9.2"
} }
} }