Skip to content

Commit 9ec5be8

Browse files
committed
Merge pull request #100 from iurimatias/develop
merge develop
2 parents 381896c + d07ddaf commit 9ec5be8

File tree

17 files changed

+264
-274
lines changed

17 files changed

+264
-274
lines changed

README.md

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
This Readme applies to Embark 1.0.0 Beta which is currently under development. For the old version please check the old [readme](https://github.com/iurimatias/embark-framework/blob/0.9.3/README.md)
2+
13
What is embark
24
======
35

@@ -11,18 +13,18 @@ With Embark you can:
1113
* Do Test Driven Development with Contracts using Javascript.
1214
* Easily deploy to & use decentralized systems such as IPFS.
1315
* Keep track of deployed contracts, deploy only when truly needed.
16+
* Manage different chains (e.g testnet, private net, livenet)
1417
* Quickly create advanced DApps using multiple contracts.
1518

1619
See the [Wiki](https://github.com/iurimatias/embark-framework/wiki) for more details.
1720

1821
Installation
1922
======
20-
Requirements: geth (1.0.0), solc (0.1.0) or serpent (develop), node (0.12.2) and npm
21-
22-
For specs: pyethereum, ethertdd.py
23+
Requirements: geth (1.1.3 or higher), node (0.12.2) and npm
24+
Optional: serpent (develop) if using contracts with Serpent
2325

2426
```Bash
25-
$ npm install -g embark-framework grunt-cli
27+
$ npm -g install embark-framework
2628
```
2729

2830
See [Complete Installation Instructions](https://github.com/iurimatias/embark-framework/wiki/Installation).
@@ -35,11 +37,19 @@ You can easily create a sample working DApp with the following:
3537
$ embark demo
3638
$ cd embark_demo
3739
```
38-
To run the ethereum node for development purposes simply run:
40+
41+
To run a ethereum rpc simulator simply run:
42+
43+
```Bash
44+
$ embark simulator
45+
```
46+
47+
Or Alternatively, you can run a REAL ethereum node for development purposes:
3948

4049
```Bash
4150
$ embark blockchain
4251
```
52+
4353
By default embark blockchain will mine a minimum amount of ether and will only mine when new transactions come in. This is quite usefull to keep a low CPU. The option can be configured at config/blockchain.yml
4454

4555
Then, in another command line:
@@ -199,42 +209,41 @@ You can also define contract interfaces (Stubs) and actions to do on deployment
199209
Tests
200210
======
201211

202-
You can run specs with ```embark spec```, it will run any files ending *_spec.js under ```spec/```.
212+
You can run specs with ```embark spec```, it will run any test files under ```test/```.
203213

204214
Embark includes a testing lib to fastly run & test your contracts in a EVM.
205215

206216
```Javascript
207-
# spec/contracts/simple_storage_spec.js
208-
Embark = require('embark-framework');
209-
Embark.init();
210-
Embark.blockchainConfig.loadConfigFile('config/blockchain.yml');
211-
Embark.contractsConfig.loadConfigFile('config/contracts.yml');
212-
213-
var files = ['app/contracts/simpleStorage.sol'];
214-
Embark.contractsConfig.init(files, 'development');
215-
216-
var EmbarkSpec = Embark.tests(files);
217-
218-
describe("SimpleStorage", function() {
219-
beforeAll(function() {
220-
// equivalent to initializing SimpleStorage with param 150
221-
SimpleStorage = EmbarkSpec.request("SimpleStorage", [150]);
217+
# test/simple_storage_spec.js
218+
var assert = require('assert');
219+
var Embark = require('embark-framework');
220+
var EmbarkSpec = Embark.initTests();
221+
222+
describe("SimpleStorage", function(done) {
223+
before(function(done) {
224+
EmbarkSpec.deployAll(done);
222225
});
223226

224-
it("should set constructor value", function() {
225-
expect(SimpleStorage.storedData()).toEqual('150');
227+
it("should set constructor value", function(done) {
228+
SimpleStorage.storedData(function(err, result) {
229+
assert.equal(result.toNumber(), 100);
230+
done();
231+
});
226232
});
227233

228-
it("set storage value", function() {
229-
SimpleStorage.set(100);
230-
expect(SimpleStorage.get()).toEqual('100');
234+
it("set storage value", function(done) {
235+
SimpleStorage.set(150, function() {
236+
SimpleStorage.get(function(err, result) {
237+
assert.equal(result.toNumber(), 150);
238+
done();
239+
});
240+
});
231241
});
232242

233243
})
234244
```
235245

236-
Embark uses [Jasmine](https://jasmine.github.io/2.3/introduction.html) by default, but you can use any testing framework you want.
237-
246+
Embark uses [Mocha](http://mochajs.org/) by default, but you can use any testing framework you want.
238247

239248
Working with different chains
240249
======
@@ -258,6 +267,7 @@ The environment is a specific blockchain configuration that can be managed at co
258267
chains: chains_staging.json
259268
network_id: 0
260269
console: true
270+
geth_extra_opts: --vmdebug
261271
account:
262272
init: false
263273
address: 0x123

bin/embark

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var wrench = require('wrench');
66
var grunt = require('grunt');
77
require('shelljs/global');
88
var readYaml = require('read-yaml');
9+
var EtherSim = require('ethersim');
910
var Embark = require('..');
1011

1112
var run = function(cmd) {
@@ -14,7 +15,7 @@ var run = function(cmd) {
1415
}
1516
}
1617

17-
var deploy = function(env, embarkConfig) {
18+
var deploy = function(env, embarkConfig, cb) {
1819
var contractFiles = grunt.file.expand(embarkConfig.contracts);
1920
var destFile = embarkConfig.output;
2021

@@ -24,12 +25,14 @@ var deploy = function(env, embarkConfig) {
2425

2526
var chainFile = Embark.blockchainConfig.blockchainConfig[env].chains || embarkConfig.chains || './chains.json';
2627

27-
abi = Embark.deployContracts(env, contractFiles, destFile, chainFile);
28-
grunt.file.write(destFile, abi);
28+
abi = Embark.deployContracts(env, contractFiles, destFile, chainFile, true, true, function(abi) {
29+
grunt.file.write(destFile, abi);
30+
cb();
31+
});
2932
}
3033

3134
program
32-
.version('0.9.2')
35+
.version('1.0.2');
3336

3437
program.command('new [name]').description('New application').action(function(name) {
3538
if (name === undefined) {
@@ -53,7 +56,7 @@ program.command('deploy [env]').description('deploy contracts').action(function(
5356
run("grunt deploy_contracts:" + env);
5457
}
5558
else {
56-
deploy(env, embarkConfig);
59+
deploy(env, embarkConfig, function() { exit(); });
5760
}
5861
});
5962

@@ -105,15 +108,16 @@ program.command('run [env]').description('run dapp').action(function(env_) {
105108
}
106109
});
107110

108-
program.command('spec').description('run specs').action(function() {
111+
program.command('spec').description('run tests').action(function() {
109112
var embarkConfig = readYaml.sync("./embark.yml");
110113

111114
if (embarkConfig.type === "grunt") {
112-
run('jasmine');
115+
run('mocha test/ --no-timeouts');
113116
}
114117
else {
115118
console.log("command not available in meteor or manual mode yet");
116119
console.log("note: you can use embark tests with any framework");
120+
console.log("try running mocha test/");
117121
}
118122
});
119123

@@ -155,7 +159,7 @@ program.command('demo').description('create a working dapp with a SimpleStorage
155159
wrench.copyDirSyncRecursive(boilerPath, targetDir);
156160
wrench.copyDirSyncRecursive(demoPath + "/app", targetDir + "/app", {forceDelete: true});
157161
wrench.copyDirSyncRecursive(demoPath + "/config", targetDir + "/config", {forceDelete: true});
158-
wrench.copyDirSyncRecursive(demoPath + "/spec", targetDir + "/spec", {forceDelete: true});
162+
wrench.copyDirSyncRecursive(demoPath + "/test", targetDir + "/test", {forceDelete: true});
159163

160164
cd(targetDir);
161165
run('npm install');
@@ -170,10 +174,14 @@ program.command('meteor_demo').description('create a working meteor dapp with a
170174
console.log('\n\ninit complete');
171175
});
172176

177+
program.command('simulator').description('run a fast ethereum rpc simulator').action(function() {
178+
EtherSim.startServer();
179+
});
180+
173181
program.parse(process.argv)
174182

175183
if (!process.argv.slice(2).length) {
176184
program.outputHelp();
177185
}
178186

179-
exit();
187+
//exit();

boilerplate/Gruntfile.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = (grunt) ->
22

3+
grunt.option 'stack', true
34
grunt.loadNpmTasks "grunt-embark"
45
grunt.loadTasks "tasks"
56

@@ -111,4 +112,3 @@ module.exports = (grunt) ->
111112

112113
grunt.registerTask "deploy", ["coffee", "deploy_contracts", "concat", "copy", "server", "watch"]
113114
grunt.registerTask "build", ["clean", "deploy_contracts", "coffee", "concat", "uglify", "copy"]
114-

boilerplate/config/blockchain.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ development:
1414
account:
1515
init: true
1616
password: config/password
17+
num: 1
1718
staging:
1819
rpc_host: localhost
1920
rpc_port: 8101
@@ -22,6 +23,9 @@ staging:
2223
network_id: 0
2324
max_peers: 4
2425
console: true
26+
bootnodes:
27+
boot: false
28+
enodes: [] #insert enode urls here.
2529
account:
2630
init: false
2731
address:
@@ -33,6 +37,9 @@ production:
3337
network_id: 1
3438
max_peers: 4
3539
console: true
40+
bootnodes:
41+
boot: false
42+
enodes: []
3643
account:
3744
init: false
3845
address:

boilerplate/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"license": "ISC",
1111
"homepage": "",
1212
"devDependencies": {
13-
"embark-framework": "^0.9.2",
14-
"grunt-embark": "^0.4.3",
13+
"embark-framework": "^1.0.2",
14+
"grunt-embark": "^0.5.1",
1515
"grunt-contrib-clean": "^0.6.0",
1616
"grunt-contrib-coffee": "^0.13.0",
1717
"grunt-contrib-concat": "^0.5.1",
@@ -21,6 +21,7 @@
2121
"grunt": "^0.4.5",
2222
"grunt-cli": "^0.1.13",
2323
"matchdep": "^0.3.0",
24+
"mocha": "^2.2.5",
2425
"express": "^4.12.3",
2526
"read-yaml": "^1.0.0",
2627
"compression": "^1.4.3"

boilerplate/spec/support/jasmine.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

demo/spec/contracts/simple_storage_spec.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

demo/spec/support/jasmine.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

demo/test/simple_storage_spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var assert = require('assert');
2+
var Embark = require('embark-framework');
3+
var EmbarkSpec = Embark.initTests();
4+
5+
describe("SimpleStorage", function(done) {
6+
before(function(done) {
7+
EmbarkSpec.deployAll(done);
8+
});
9+
10+
it("should set constructor value", function(done) {
11+
SimpleStorage.storedData(function(err, result) {
12+
assert.equal(result.toNumber(), 100);
13+
done();
14+
});
15+
});
16+
17+
it("set storage value", function(done) {
18+
SimpleStorage.set(150, function() {
19+
SimpleStorage.get(function(err, result) {
20+
assert.equal(result.toNumber(), 150);
21+
done();
22+
});
23+
});
24+
});
25+
26+
})

lib/blockchain.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Blockchain.prototype.generate_basic_command = function() {
1616
cmd += "--logfile=\"" + config.datadir + ".log\" ";
1717
}
1818

19+
if (config.geth_extra_opts) {
20+
cmd += config.geth_extra_opts + " ";
21+
}
22+
1923
cmd += "--port " + config.port + " ";
2024
cmd += "--rpc ";
2125
cmd += "--rpcport " + config.rpcPort + " ";
@@ -27,7 +31,9 @@ Blockchain.prototype.generate_basic_command = function() {
2731
cmd += "--minerthreads \"" + config.minerthreads + "\" ";
2832
}
2933

30-
cmd += "--mine ";
34+
if(config.mine)
35+
cmd += "--mine ";
36+
3137
if (config.genesisBlock !== void 0) {
3238
cmd += "--genesis=\"" + config.genesisBlock + "\" ";
3339
}
@@ -69,6 +75,13 @@ Blockchain.prototype.run_command = function(address, use_tmp) {
6975
cmd += "--unlock " + address + " ";
7076
}
7177

78+
if (config.bootNodes !== undefined && config.bootNodes.boot == true){
79+
cmd += "--bootnodes ";
80+
for (var i = 0; i < config.bootNodes.enodes.length; i++){
81+
cmd += config.bootNodes.enodes[i] + " ";
82+
}
83+
}
84+
7285
if (config.console_toggle) {
7386
cmd += "console";
7487
}
@@ -87,6 +100,10 @@ Blockchain.prototype.run_command = function(address, use_tmp) {
87100

88101
Blockchain.prototype.get_address = function() {
89102
var config = this.config;
103+
104+
if(config.account.address)
105+
return config.account.address;
106+
90107
var address = null;
91108

92109
if (config.account.init) {

0 commit comments

Comments
 (0)