From 0af68cbc9ccf4314a5a4637abbbaee0ea752afb8 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 9 Jun 2015 07:57:19 -0400 Subject: [PATCH] tdd integration poc --- boilerplate/package.json | 5 ++-- boilerplate/spec/contracts/simple_storage.js | 9 +++++++ boilerplate/spec/test.js | 26 ++++++++++++++++++++ index.js | 1 - package.json | 6 ++++- tasks/spec.coffee | 1 + 6 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 boilerplate/spec/contracts/simple_storage.js create mode 100644 boilerplate/spec/test.js create mode 100644 tasks/spec.coffee diff --git a/boilerplate/package.json b/boilerplate/package.json index 1cba0e361..280933681 100644 --- a/boilerplate/package.json +++ b/boilerplate/package.json @@ -10,7 +10,7 @@ "license": "ISC", "homepage": "", "devDependencies": { - "embark-framework": "^0.3.0", + "embark-framework": "/Users/iurimatias/Projects/embark-framework", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-coffee": "^0.13.0", "grunt-contrib-concat": "^0.5.1", @@ -19,6 +19,7 @@ "grunt-contrib-watch": "^0.6.1", "grunt": "^0.4.5", "grunt-cli": "^0.1.13", - "matchdep": "^0.3.0" + "matchdep": "^0.3.0", + "python": "^0.0.4" } } diff --git a/boilerplate/spec/contracts/simple_storage.js b/boilerplate/spec/contracts/simple_storage.js new file mode 100644 index 000000000..f8a793144 --- /dev/null +++ b/boilerplate/spec/contracts/simple_storage.js @@ -0,0 +1,9 @@ +EmbarkSpec = require("embark-framework").specs(); + +SimpleStorage = EmbarkSpec.SimpleStorage; + +SimpleStorage.set(100); + +a = SimpleStorage.get() +console.log(a) + diff --git a/boilerplate/spec/test.js b/boilerplate/spec/test.js new file mode 100644 index 000000000..9193dd8dd --- /dev/null +++ b/boilerplate/spec/test.js @@ -0,0 +1,26 @@ +var python = require('python').shell; +var web3 = require('web3'); + +web3.setProvider(new web3.providers.HttpProvider('http://localhost:8101')); +web3.eth.defaultAccount = web3.eth.accounts[0]; + +fs = require('fs'); +source = fs.readFileSync('./app/contracts/simple_storage.sol').toString() +compiled_contracts = web3.eth.compile.solidity(source) + +contract = compiled_contracts.SimpleStorage + +example_abi = JSON.stringify(contract.info.abiDefinition) +example_binary = contract.code.slice(2) + +python("from ethertdd import EvmContract", function() {}) +python("example_abi = '" + example_abi + "'", function() {}) +python("example_abi", function() { }) +python("example_binary = '" + example_binary + "'.decode('hex')", function() {}) +python("example_binary", function() { }) +python("contract = EvmContract(example_abi, example_binary)", function() {}) +python("contract.set(10)", function() {}) + +console.log("get") +python("contract.get()", function(err, data) { console.log("=>" + data)}) + diff --git a/index.js b/index.js index b57daf206..6265f352e 100644 --- a/index.js +++ b/index.js @@ -7,4 +7,3 @@ var express = require('express'); var compression = require('compression'); var commander = require('commander'); var wrench = require('wrench'); -console.log("dude!!!"); diff --git a/package.json b/package.json index 8f79dfbd4..f3ee13f6b 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,9 @@ "embark": "./bin/embark" }, "main": "./index.js", + "directories": { + "lib": "./lib" + }, "dependencies": { "commander": "^2.8.1", "compression": "^1.4.3", @@ -27,7 +30,8 @@ "shelljs": "^0.5.0", "web3": "^0.5.0", "wrench": "^1.5.8", - "hashmerge": "^1.0.2" + "hashmerge": "^1.0.2", + "python": "^0.0.4" }, "author": "Iuri Matias ", "contributors": [], diff --git a/tasks/spec.coffee b/tasks/spec.coffee new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/tasks/spec.coffee @@ -0,0 +1 @@ +