diff --git a/old_test/blockchain.js b/old_test/blockchain.js deleted file mode 100644 index aa7580b14..000000000 --- a/old_test/blockchain.js +++ /dev/null @@ -1,46 +0,0 @@ -var Config = require('../lib/config/config.js'); -var Blockchain = require('../lib/blockchain.js'); -var assert = require('assert'); -var sinon = require('sinon'); - -describe('embark.blockchain', function() { - var blockchainConfig = (new Config.Blockchain()).loadConfigFile('test/support/blockchain.yml').config("development"); - - describe('#generate_basic_command', function() { - var blockchain = new Blockchain(blockchainConfig); - - it('should return correct cmd', function() { - assert.strictEqual(blockchain.generate_basic_command(), "geth --datadir=\"/tmp/embark\" --password config/password --port 30303 --rpc --rpcport 8101 --rpcaddr localhost --networkid "+blockchainConfig.networkId+" --rpccorsdomain=\"*\" --minerthreads \"1\" --mine --rpcapi \"eth,web3\" --maxpeers 4 "); - }); - }); - - describe('#list_command', function() { - var blockchain = new Blockchain(blockchainConfig); - blockchain.generate_basic_command = sinon.stub().returns("geth "); - - it('should generate command to list accounts', function() { - assert.equal(blockchain.list_command(), "geth --datadir=\"/tmp/embark\" --password config/password account list "); - }); - }); - - describe('#init_command', function() { - var blockchain = new Blockchain(blockchainConfig); - blockchain.generate_basic_command = sinon.stub().returns("geth "); - - it('should generate command to create an account', function() { - assert.equal(blockchain.init_command(), "geth --datadir=\"/tmp/embark\" --password config/password account new "); - }); - }); - - describe('#run_command', function() { - describe('with mine when needed config set', function() { - var blockchain = new Blockchain(blockchainConfig); - blockchain.generate_basic_command = sinon.stub().returns("geth "); - - it('should generate run command with script ', function() { - assert.equal(blockchain.run_command(), "geth js node_modules/embark-framework/js/mine.js"); - }); - }); - }); - -}); diff --git a/old_test/chain_manager.js b/old_test/chain_manager.js deleted file mode 100644 index 456ddc9a4..000000000 --- a/old_test/chain_manager.js +++ /dev/null @@ -1,66 +0,0 @@ -var ChainManager = require('../lib/chain_manager.js'); -var Config = require('../lib/config/config.js'); -var Blockchain = require('../lib/blockchain.js'); -var assert = require('assert'); -var fs = require('fs'); - -// TODO: replace with ethersim -var Web3 = require('web3'); -var web3 = new Web3(); -web3.setProvider(new web3.providers.HttpProvider("http://localhost:8101")); - -describe('embark.chain_manager', function() { - var chainFile = './test/support/chain_manager.json'; - fs.writeFileSync(chainFile, '{}'); - - var chainManager = (new ChainManager()).loadConfigFile(chainFile); - var blockchainConfig = (new Config.Blockchain()).loadConfigFile('test/support/blockchain.yml').config('development'); - - describe('#init', function() { - chainManager.init('development', blockchainConfig, web3); - - it('should initialize chain', function() { - var chain = chainManager.chainManagerConfig['0x245a1b878a79ee9d0fd46e19c89d0cefbaa475e74e45fa133e022da45943b111'] - assert.equal(chain != undefined, true); - }); - }); - - describe('#addContract', function() { - - it('should register a contract in the chain', function() { - chainManager.addContract("Foo", "123456", [], "0x123"); - - console.log(chainManager.chainManagerConfig); - var chain = chainManager.chainManagerConfig['0x245a1b878a79ee9d0fd46e19c89d0cefbaa475e74e45fa133e022da45943b111'] - var contract = chain.contracts["d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b"] - - assert.equal(contract.name, "Foo"); - assert.equal(contract.address, "0x123"); - }); - - }); - - describe('#getContract', function() { - - it('should a contract in the chain', function() { - var contract = chainManager.getContract("Foo", "123456", []); - - assert.equal(contract.name, "Foo"); - assert.equal(contract.address, "0x123"); - }); - - }); - - describe('#save', function() { - - it('should save changes in the chain', function() { - chainManager.save(); - - var chainFile = './test/support/chain_manager.json'; - var content = fs.readFileSync(chainFile).toString(); - assert.equal(content, '{"0x245a1b878a79ee9d0fd46e19c89d0cefbaa475e74e45fa133e022da45943b111\":{"contracts":{"d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b\":{"name":"Foo","address":"0x123"}}}}'); - }); - - }); - -}); diff --git a/old_test/compiler.js b/old_test/compiler.js deleted file mode 100644 index 0d1b8d192..000000000 --- a/old_test/compiler.js +++ /dev/null @@ -1,69 +0,0 @@ -var Compiler = require('../lib/compiler.js'); -var assert = require('assert'); - -describe('embark.compiler', function() { - - describe('compile a file', function() { - var files = [ - 'test/support/contracts/simple_storage.sol' - ]; - - it("should build a correct compiled object", function() { - var compiler = new Compiler(); - - var compiledFile = compiler.compile(files); - - assert.equal(compiledFile.SimpleStorage.code, '60606040526040516020806075833950608060405251600081905550604e8060276000396000f3606060405260e060020a60003504632a1afcd98114602e57806360fe47b11460365780636d4ce63c146040575b005b604460005481565b600435600055602c565b6000545b6060908152602090f3'); - - assert.equal(JSON.stringify(compiledFile.SimpleStorage.info.abiDefinition), '[{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"type":"function"},{"inputs":[{"name":"initialValue","type":"uint256"}],"type":"constructor"}]'); - }); - - }); - - describe('compile a file with an error', function() { - var files = [ - 'test/support/contracts/error.sol' - ]; - - it("throw an error", function() { - var compiler = new Compiler(); - - assert.throws(function() { compiler.compile(files) }, Error); - }); - - }); - - describe('compile a serpent file', function() { - var files = [ - 'test/support/contracts/cash.se' - ]; - - it("should build a correct compiled object", function() { - var compiler = new Compiler(); - - var compiledFile = compiler.compile(files); - - assert.equal(compiledFile.cash.code, '6000603f536a0186a000000000000000006040604059905901600090526000815232816020015280905020556103658061003a60003961039f56600061047f537c010000000000000000000000000000000000000000000000000000000060003504638357984f81141561005f57600435604052604060405990590160009052600081526040518160200152809050205460605260206060f35b63693200ce8114156101465760043560a05260243560c0523260e0526040604059905901600090526000815260e051816020015280905020546101005260c051610100511215156101385760c0516040604059905901600090526000815260e05181602001528090502054036040604059905901600090526000815260e0518160200152809050205560c0516040604059905901600090526000815260a05181602001528090502054016040604059905901600090526000815260a0518160200152809050205560c0516101c05260206101c0f3610145565b60006101e05260206101e0f35b5b6380b97fc081141561024c5760043560a05260243560c05260443561020052326102005114151561017e576000610220526020610220f35b6040604059905901600090526000815261020051816020015280905020546101005260c0516101005112151561023e5760c0516040604059905901600090526000815261020051816020015280905020540360406040599059016000905260008152610200518160200152809050205560c0516040604059905901600090526000815260a05181602001528090502054016040604059905901600090526000815260a0518160200152809050205560c0516102e05260206102e0f361024b565b6000610300526020610300f35b5b634c764abc8114156102b4576004356103205260243561034052610340516040604059905901600090526000815261032051816020015280905020540360406040599059016000905260008152610320518160200152809050205560016103a05260206103a0f35b63a92c9b8381141561031c57600435610320526024356103405261034051604060405990590160009052600081526103205181602001528090502054016040604059905901600090526000815261032051816020015280905020556001610400526020610400f35b631d62e92281141561036357600435604052602435610420526104205160406040599059016000905260008152604051816020015280905020556001610460526020610460f35b505b6000f3'); - - assert.equal(JSON.stringify(compiledFile.cash.info.abiDefinition), '[{\"name\":\"addCash(int256,int256)\",\"type\":\"function\",\"inputs\":[{\"name\":\"ID\",\"type\":\"int256\"},{\"name\":\"amount\",\"type\":\"int256\"}],\"outputs\":[{\"name\":\"out\",\"type\":\"int256\"}],\"constant\":true},{\"name\":\"balance(int256)\",\"type\":\"function\",\"inputs\":[{\"name\":\"address\",\"type\":\"int256\"}],\"outputs\":[{\"name\":\"out\",\"type\":\"int256\"}],\"constant\":true},{\"name\":\"send(int256,int256)\",\"type\":\"function\",\"inputs\":[{\"name\":\"recver\",\"type\":\"int256\"},{\"name\":\"value\",\"type\":\"int256\"}],\"outputs\":[{\"name\":\"out\",\"type\":\"int256\"}],\"constant\":true},{\"name\":\"sendFrom(int256,int256,int256)\",\"type\":\"function\",\"inputs\":[{\"name\":\"recver\",\"type\":\"int256\"},{\"name\":\"value\",\"type\":\"int256\"},{\"name\":\"from\",\"type\":\"int256\"}],\"outputs\":[{\"name\":\"out\",\"type\":\"int256\"}],\"constant\":true},{\"name\":\"setCash(int256,int256)\",\"type\":\"function\",\"inputs\":[{\"name\":\"address\",\"type\":\"int256\"},{\"name\":\"balance\",\"type\":\"int256\"}],\"outputs\":[{\"name\":\"out\",\"type\":\"int256\"}],\"constant\":true},{\"name\":\"subtractCash(int256,int256)\",\"type\":\"function\",\"inputs\":[{\"name\":\"ID\",\"type\":\"int256\"},{\"name\":\"amount\",\"type\":\"int256\"}],\"outputs\":[{\"name\":\"out\",\"type\":\"int256\"}],\"constant\":true}]'); - - }); - - }); - - describe('compile a file with an error', function() { - var files = [ - 'test/support/contracts/error.sol' - ]; - - it("throw an error", function() { - var compiler = new Compiler(); - - assert.throws(function() { compiler.compile(files) }, Error); - }); - - }); - - -}); - diff --git a/old_test/config.blockchain.js b/old_test/config.blockchain.js deleted file mode 100644 index 021e413e0..000000000 --- a/old_test/config.blockchain.js +++ /dev/null @@ -1,150 +0,0 @@ -var Config = require('../lib/config/config.js'); -var assert = require('assert'); - -describe('embark.config.blockchain', function() { - var blockchainConfig = new Config.Blockchain(); - - describe('#loadConfigFile', function() { - it('should read and load yml file', function() { - blockchainConfig.loadConfigFile('test/support/blockchain.yml'); - - assert.equal(blockchainConfig.blockchainConfig.hasOwnProperty('development'), true) - assert.equal(blockchainConfig.blockchainConfig.hasOwnProperty('staging'), true) - }); - - it('should throw exception reading invalid file', function() { - assert.throws(function() { blockchainConfig.loadConfigFile('test/support/invalid.yml') }, Error); - }); - }); - - describe('#loadConfig', function() { - it('should load config', function() { - var hsh = { - development: {}, - staging: {} - }; - - blockchainConfig.loadConfig(hsh); - - assert.equal(blockchainConfig.blockchainConfig.hasOwnProperty('development'), true) - assert.equal(blockchainConfig.blockchainConfig.hasOwnProperty('staging'), true) - }); - }); - - describe('#config', function() { - - it('should load environment', function() { - var hsh = { - development: { - rpc_host: 'localhost', - rpc_port: 8101, - rpc_whitelist: "*", - network_id: 0, - minerthreads: 1, - genesis_block: 'config/genesis.json', - datadir: '/tmp/embark', - chains: 'chains_development.json', - deploy_timeout: 45, - mine_when_needed: true, - gas_limit: 123, - gas_price: 100, - console: false, - account: { - init: true, - password: 'config/password' - } - }, - staging: {} - }; - - blockchainConfig.loadConfig(hsh); - - assert.deepEqual(blockchainConfig.config('development'), { - rpcHost: 'localhost', - rpcPort: 8101, - gasLimit: 123, - gasPrice: 100, - rpcWhitelist: "*", - testnet: false, - bootNodes: [], - whisper: false, - minerthreads: 1, - nat: [], - genesisBlock: 'config/genesis.json', - datadir: '/tmp/embark', - chains: 'chains_development.json', - deployTimeout: 45, - deploy_synchronously: false, - networkId: 0, - maxPeers: 4, - mine: false, - port: "30303", - console_toggle: false, - mine_when_needed: true, - geth_extra_opts: [], - account: { - init: true, - password: 'config/password' - } - }) - }); - - it('should return defaults', function() { - var hsh = { - development: { - rpc_host: 'localhost', - rpc_port: 8101, - rpc_whitelist: "*", - network_id: 0, - minerthreads: 1, - datadir: '/tmp/embark', - chains: undefined, - mine_when_needed: true, - console: false, - account: { - init: true, - password: 'config/password' - }, - }, - staging: {} - }; - - blockchainConfig.loadConfig(hsh); - - assert.deepEqual(blockchainConfig.config('development'), { - rpcHost: 'localhost', - rpcPort: 8101, - gasLimit: 500000, - gasPrice: 10000000000000, - rpcWhitelist: "*", - testnet: false, - bootNodes: [], - whisper: false, - minerthreads: 1, - nat: [], - genesisBlock: undefined, - datadir: '/tmp/embark', - chains: undefined, - deployTimeout: 20, - deploy_synchronously: false, - networkId: 0, - maxPeers: 4, - mine: false, - port: "30303", - console_toggle: false, - mine_when_needed: true, - geth_extra_opts: [], - account: { - init: true, - password: 'config/password' - } - }) - }); - - it('should load environment', function() { - var blockchainConfig = new Config.Blockchain(); - assert.throws(function() { blockchainConfig.config('development') }, Error); - }); - }); - -}); diff --git a/old_test/config.contracts.js b/old_test/config.contracts.js deleted file mode 100644 index d9d70ce14..000000000 --- a/old_test/config.contracts.js +++ /dev/null @@ -1,115 +0,0 @@ -var Config = require('../lib/config/config.js'); -var Compiler = require('../lib/compiler.js'); -var assert = require('assert'); -var sinon = require('sinon'); -require('mocha-sinon'); - -describe('embark.config.contracts', function() { - var _blockchainConfig = (new Config.Blockchain()).loadConfigFile('test/support/blockchain.yml'); - var blockchainConfig = _blockchainConfig.config("development"); - var compiler = new Compiler(_blockchainConfig); - - describe('#loadConfigFile', function() { - it('should read and load yml file', function() { - var contractsConfig = new Config.Contracts(blockchainConfig, compiler); - contractsConfig.loadConfigFile('test/support/contracts.yml'); - - assert.equal(contractsConfig.contractConfig.hasOwnProperty('development'), true) - assert.equal(contractsConfig.contractConfig.hasOwnProperty('staging'), true) - }); - - it('should throw exception reading invalid file', function() { - assert.throws(function() { contractsConfig.loadConfigFile('test/support/invalid.yml') }, Error); - }); - }); - - describe('#loadConfig', function() { - it('should load config', function() { - var contractsConfig = new Config.Contracts([], blockchainConfig, compiler); - var hsh = { - development: {}, - staging: {} - }; - - contractsConfig.loadConfig(hsh); - - assert.equal(contractsConfig.contractConfig.hasOwnProperty('development'), true) - assert.equal(contractsConfig.contractConfig.hasOwnProperty('staging'), true) - }); - }); - - describe('#compileContracts', function() { - context("simple contracts", function() { - before(function() { - files = [ - 'test/support/contracts/simple_storage.sol', - 'test/support/contracts/another_storage.sol' - ] - contractsConfig = new Config.Contracts(blockchainConfig, compiler); - contractsConfig.loadConfigFile('test/support/contracts.yml'); - contractsConfig.init(files, 'development'); - contractsConfig.compileContracts(); - }); - - it('add contracts to a list', function() { - //assert.deepEqual(contractsConfig.all_contracts, [ "SimpleStorage", "AnotherStorage" ]); - assert.deepEqual(contractsConfig.all_contracts, [ "AnotherStorage", "SimpleStorage" ]); - }); - }); - - context("contracts as arguments to other contracts", function() { - before(function() { - files = [ - 'test/support/contracts/wallet.sol', - 'test/support/contracts/simple_storage.sol', - 'test/support/contracts/another_storage.sol', - 'test/support/contracts/wallets.sol' - ] - contractsConfig = new Config.Contracts(blockchainConfig, compiler); - contractsConfig.loadConfigFile('test/support/arguments.yml'); - contractsConfig.init(files, 'development'); - contractsConfig.compileContracts('development'); - }); - - it('add contracts to a list', function() { - assert.deepEqual(contractsConfig.all_contracts, [ "SimpleStorage", "AnotherStorage", "Wallet", "Wallets" ]); - }); - }); - - context("contracts instances", function() { - before(function() { - files = [ - 'test/support/contracts/simple_storage.sol' - ] - contractsConfig = new Config.Contracts(blockchainConfig, compiler); - contractsConfig.loadConfigFile('test/support/instances.yml'); - contractsConfig.init(files, 'development'); - contractsConfig.compileContracts('development'); - }); - - it('add contracts to a list', function() { - assert.deepEqual(contractsConfig.all_contracts, [ "SimpleStorage", "BarStorage", "FooStorage" ]); - }); - }); - - context("contracts as arguments to other contracts with stubs", function() { - before(function() { - files = [ - 'test/support/contracts/crowdsale.sol', - 'test/support/contracts/token.sol' - ] - contractsConfig = new Config.Contracts(blockchainConfig, compiler); - contractsConfig.loadConfigFile('test/support/arguments2.yml'); - contractsConfig.init(files, 'development'); - contractsConfig.compileContracts('development'); - }); - - it('add contracts to a list', function() { - assert.deepEqual(contractsConfig.all_contracts, [ "token", "Crowdsale" ]); - }); - }); - - }); - -}); - diff --git a/old_test/deploy.js b/old_test/deploy.js deleted file mode 100644 index 9f33ea9fa..000000000 --- a/old_test/deploy.js +++ /dev/null @@ -1,261 +0,0 @@ -var Config = require('../lib/config/config.js'); -var Deploy = require('../lib/deploy.js'); -var Compiler = require('../lib/compiler.js'); -var ChainManager = require('../lib/chain_manager.js'); -var assert = require('assert'); -var web3 = require('web3'); - -// TODO: replace with ethersim -var Web3 = require('web3'); -var web3 = new Web3(); -web3.setProvider(new web3.providers.HttpProvider("http://localhost:8101")); - -setDeployConfig = function(config) { - var _blockchainConfig = (new Config.Blockchain()).loadConfigFile(config.blockchain); - var blockchainConfig = _blockchainConfig.config("development"); - var compiler = new Compiler(_blockchainConfig); - var contractsConfig = new Config.Contracts(blockchainConfig, compiler); - var chainManager = (new ChainManager()).loadConfigFile('./test/support/chain_manager.json'); - contractsConfig.loadConfigFile(config.contracts); - contractsConfig.init(config.files, 'development'); - compiler.init('development'); - return new Deploy('development', config.files, blockchainConfig, contractsConfig, chainManager, true, false, web3); -} - -function Done(fn) { - var self = this; - var called = false; - - /** - * - * @param {*} params... - */ - this.trigger = function (params) { - if(called) { - return; - } - - fn.apply(self, arguments); - called = true; - }; -} - -describe('embark.deploy', function() { - - describe('contracts as arguments to other contracts', function() { - var files = [ - 'test/support/contracts/wallet.sol', - 'test/support/contracts/simple_storage.sol', - 'test/support/contracts/another_storage.sol', - 'test/support/contracts/wallets.sol' - ]; - - describe('#deploy_contracts', function() { - var deploy = setDeployConfig({ - files: files, - blockchain: 'test/support/blockchain.yml', - contracts: 'test/support/arguments.yml' - }); - - it("should deploy contracts", function(fn) { - var doneWrap = new Done(fn); - - deploy.deploy_contracts("development", function() { - var all_contracts = ['Wallet', 'SimpleStorage', 'AnotherStorage', 'Wallets']; - for(var i=0; i < all_contracts.length; i++) { - var className = all_contracts[i]; - - assert.equal(deploy.deployedContracts.hasOwnProperty(className), true); - } - - doneWrap.trigger(); - }); - - }); - - }); - - describe('#generate_abi_file', function() { - var deploy = setDeployConfig({ - files: files, - blockchain: 'test/support/blockchain.yml', - contracts: 'test/support/arguments.yml' - }); - deploy.deployedContracts = { - "SimpleStorage": "0x123", - "AnotherStorage": "0x234" - } - deploy.contractDB = { - "SimpleStorage": {compiled: {info: {abiDefinition: 123}}}, - "AnotherStorage": {compiled: {info: {abiDefinition: 234}}} - } - - it("should deploy contracts", function() { - var result = ""; - - result += deploy.generate_provider_file(); - result += deploy.generate_abi_file(); - - assert.strictEqual(result, "var web3 = new Web3();web3.setProvider(new web3.providers.HttpProvider('http://localhost:8101'));web3.eth.defaultAccount = web3.eth.accounts[0];blockchain = {\"testnet\":false,\"rpcHost\":\"localhost\",\"rpcPort\":8101,\"gasLimit\":1000000,\"gasPrice\":10000000000000,\"rpcWhitelist\":\"*\",\"nat\":[],\"minerthreads\":1,\"genesisBlock\":\"config/genesis.json\",\"datadir\":\"/tmp/embark\",\"bootNodes\":[],\"deployTimeout\":20,\"networkId\":"+deploy.blockchainConfig.networkId+",\"maxPeers\":4,\"mine\":false,\"port\":\"30303\",\"console_toggle\":false,\"mine_when_needed\":true,\"whisper\":false,\"account\":{\"init\":true,\"password\":\"config/password\"},\"geth_extra_opts\":[],\"deploy_synchronously\":false};SimpleStorageAbi = 123;SimpleStorageContract = web3.eth.contract(SimpleStorageAbi);SimpleStorage = SimpleStorageContract.at('0x123');AnotherStorageAbi = 234;AnotherStorageContract = web3.eth.contract(AnotherStorageAbi);AnotherStorage = AnotherStorageContract.at('0x234');contractDB = {\"SimpleStorage\":{\"compiled\":{\"info\":{\"abiDefinition\":123}}},\"AnotherStorage\":{\"compiled\":{\"info\":{\"abiDefinition\":234}}}};"); - }); - }); - }); - - describe('contracts as arguments to other contracts with stubs', function() { - var files = [ - 'test/support/contracts/crowdsale.sol', - 'test/support/contracts/token.sol' - ]; - - describe('#deploy_contracts', function() { - var deploy = setDeployConfig({ - files: files, - blockchain: 'test/support/blockchain.yml', - contracts: 'test/support/arguments2.yml' - }); - - it("should deploy contracts", function(fn) { - var doneWrap = new Done(fn); - - deploy.deploy_contracts("development", function() { - - var all_contracts = ['token', 'Crowdsale']; - for(var i=0; i < all_contracts.length; i++) { - var className = all_contracts[i]; - - assert.equal(deploy.deployedContracts.hasOwnProperty(className), true); - } - - doneWrap.trigger(); - }); - - }); - - }); - - }); - - describe('contracts instances', function() { - var files = [ - 'test/support/contracts/simple_storage.sol' - ]; - - describe('#deploy_contracts', function() { - var deploy = setDeployConfig({ - files: files, - blockchain: 'test/support/blockchain.yml', - contracts: 'test/support/instances.yml' - }); - - it("should deploy contracts", function(fn) { - var doneWrap = new Done(fn); - - deploy.deploy_contracts("development", function() { - - var all_contracts = ['BarStorage', 'FooStorage']; - for(var i=0; i < all_contracts.length; i++) { - var className = all_contracts[i]; - - assert.equal(deploy.deployedContracts.hasOwnProperty(className), true); - } - assert.notEqual(deploy.deployedContracts.hasOwnProperty('SimpleStorage'), true); - - doneWrap.trigger(); - }); - }); - - }); - - }); - - describe('contracts deploy script', function() { - var files = [ - 'test/support/contracts/data_source.sol', - 'test/support/contracts/manager.sol' - ]; - - describe('#deploy_contracts', function() { - var deploy = setDeployConfig({ - files: files, - blockchain: 'test/support/blockchain.yml', - contracts: 'test/support/arguments3.yml' - }); - - it("should deploy contracts", function(fn) { - var doneWrap = new Done(fn); - - deploy.deploy_contracts("development", function() { - var all_contracts = ['DataSource', 'MyDataSource', 'Manager']; - for(var i=0; i < all_contracts.length; i++) { - var className = all_contracts[i]; - - assert.equal(deploy.deployedContracts.hasOwnProperty(className), true); - } - - doneWrap.trigger(); - }); - }); - - it("should execute deploy changes", function(fn) { - var doneWrap = new Done(fn); - - web3.setProvider(new web3.providers.HttpProvider('http://localhost:8101')); - web3.eth.defaultAccount = web3.eth.accounts[0]; - - data_source_abi = deploy.contractDB['DataSource'].compiled.info.abiDefinition; - data_source_address = deploy.deployedContracts['DataSource']; - my_data_source_abi = deploy.contractDB['MyDataSource'].compiled.info.abiDefinition; - my_data_source_address = deploy.deployedContracts['MyDataSource']; - manager_abi = deploy.contractDB['Manager'].compiled.info.abiDefinition; - manager_address = deploy.deployedContracts['Manager']; - - DataSource = web3.eth.contract(data_source_abi).at(data_source_address); - MyDataSource = web3.eth.contract(my_data_source_abi).at(my_data_source_address); - ManagerSource = web3.eth.contract(manager_abi).at(manager_address); - - assert.equal(DataSource.storeData().toNumber(), 5); - assert.equal(Manager.data().toString(), my_data_source_address); - - doneWrap.trigger(); - }); - - }); - - }); - - describe('contracts with addresses defined', function() { - var files = [ - 'test/support/contracts/simple_storage.sol' - ]; - - describe('#deploy_contracts', function() { - var deploy = setDeployConfig({ - files: files, - blockchain: 'test/support/blockchain.yml', - contracts: 'test/support/address.yml' - }); - - it("should not deploy contracts with addresses defined", function(fn) { - var doneWrap = new Done(fn); - - deploy.deploy_contracts("development", function() { - var expected_deploys = ['SimpleStorage', 'BarStorage', 'FooStorage']; - - for(var i=0; i < expected_deploys.length; i++) { - var className = expected_deploys[i]; - - assert.equal(deploy.deployedContracts.hasOwnProperty(className), true); - } - - assert.equal(deploy.deployedContracts['SimpleStorage'], '0x123'); - assert.equal(deploy.deployedContracts['BarStorage'], '0x234'); - - doneWrap.trigger(); - }); - }); - - }); - - }); - -}); diff --git a/old_test/support/address.yml b/old_test/support/address.yml deleted file mode 100644 index 9da323682..000000000 --- a/old_test/support/address.yml +++ /dev/null @@ -1,13 +0,0 @@ -development: - SimpleStorage: - address: 0x123 - args: - - 100 - BarStorage: - address: 0x234 - instanceOf: SimpleStorage - FooStorage: - instanceOf: SimpleStorage - args: - - 200 -staging: diff --git a/old_test/support/arguments.yml b/old_test/support/arguments.yml deleted file mode 100644 index fc0fe03bf..000000000 --- a/old_test/support/arguments.yml +++ /dev/null @@ -1,14 +0,0 @@ -development: - Wallet: - args: - - $AnotherStorage - SimpleStorage: - args: - - 100 - AnotherStorage: - args: - - 100 - Wallets: - args: - - $Wallet -staging: diff --git a/old_test/support/arguments2.yml b/old_test/support/arguments2.yml deleted file mode 100644 index 86765c6b8..000000000 --- a/old_test/support/arguments2.yml +++ /dev/null @@ -1,13 +0,0 @@ -development: - token: - args: - Crowdsale: - stubs: - - token - args: - - 0x123 - - 100000000000000000000 - - 30 - - 20000000000000000 - - $token -staging: diff --git a/old_test/support/arguments3.yml b/old_test/support/arguments3.yml deleted file mode 100644 index 7fe418f86..000000000 --- a/old_test/support/arguments3.yml +++ /dev/null @@ -1,15 +0,0 @@ -development: - DataSource: - args: - MyDataSource: - args: - instanceOf: DataSource - Manager: - stubs: - - DataSource - args: - - $DataSource - onDeploy: - - DataSource.set(5) - - Manager.update($MyDataSource) -staging: diff --git a/old_test/support/blockchain.yml b/old_test/support/blockchain.yml deleted file mode 100644 index 3612a11c1..000000000 --- a/old_test/support/blockchain.yml +++ /dev/null @@ -1,24 +0,0 @@ -development: - rpc_host: localhost - rpc_port: 8101 - rpc_whitelist: "*" - minerthreads: 1 - genesis_block: config/genesis.json - datadir: /tmp/embark - mine_when_needed: true - gas_limit: 1000000 - gas_price: 10000000000000 - console: false - account: - init: true - password: config/password -staging: - rpc_host: localhost - rpc_port: 8101 - rpc_whitelist: "*" - datadir: default - network_id: 0 - console: true - account: - init: false - address: diff --git a/old_test/support/chain_manager.json b/old_test/support/chain_manager.json deleted file mode 100644 index 602dff646..000000000 --- a/old_test/support/chain_manager.json +++ /dev/null @@ -1 +0,0 @@ -{"0x245a1b878a79ee9d0fd46e19c89d0cefbaa475e74e45fa133e022da45943b111":{"contracts":{"d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b":{"name":"Foo","address":"0x123"}}}} \ No newline at end of file diff --git a/old_test/support/contracts.yml b/old_test/support/contracts.yml deleted file mode 100644 index 56addd58b..000000000 --- a/old_test/support/contracts.yml +++ /dev/null @@ -1,2 +0,0 @@ -development: -staging: diff --git a/old_test/support/contracts/another_storage.sol b/old_test/support/contracts/another_storage.sol deleted file mode 100644 index ce3c0ac6b..000000000 --- a/old_test/support/contracts/another_storage.sol +++ /dev/null @@ -1,14 +0,0 @@ -contract AnotherStorage { - uint public storedData; - - function SimpleStorage(uint initialValue) { - storedData = initialValue; - } - - function set(uint x) { - storedData = x; - } - function get() constant returns (uint retVal) { - return storedData; - } -} diff --git a/old_test/support/contracts/cash.se b/old_test/support/contracts/cash.se deleted file mode 100644 index c70f0c57b..000000000 --- a/old_test/support/contracts/cash.se +++ /dev/null @@ -1,75 +0,0 @@ -# This software (Augur) allows buying && selling event outcomes in ethereum -# Copyright (C) 2015 Forecast Foundation -# This program is free software; you can redistribute it &&/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is free software: you can redistribute it &&/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# Any questions please contact joey@augur.net - -data cashcoinBalances[] - -def init(): - # test initial funds - self.cashcoinBalances[tx.origin] = 100000*2^64 - -# @return: cash balance of address -def balance(address): - return(self.cashcoinBalances[address]) - -# should send values as fixed point in UI (1 is 2^64, 4 is 4*2^64, .5 is 2^63, etc.) -# so cashcoin fees could just go to root branch, or we could not have fees besides -# gas fee to do a send transaction -# @return: value sent, 0 if fails -def send(recver, value): - sender = tx.origin - senderBalance = self.cashcoinBalances[sender] - if(senderBalance >= value): - self.cashcoinBalances[sender] -= value - self.cashcoinBalances[recver] += value - return(value) - else: - return(0) - -# @return value of cash sent; fail is 0 -def sendFrom(recver, value, from): - if(from!=tx.origin): - return(0) - senderBalance = self.cashcoinBalances[from] - if(senderBalance >= value): - self.cashcoinBalances[from] -= value - self.cashcoinBalances[recver] += value - return(value) - else: - return(0) - -# make sure only coming from specific contracts -def subtractCash(ID, amount): - #if(!self.whitelist.check(msg.sender)): - # return(-1) - self.cashcoinBalances[ID] -= amount - return(1) - -def addCash(ID, amount): - #if(!self.whitelist.check(msg.sender)): - # return(-1) - self.cashcoinBalances[ID] += amount - return(1) - -def setCash(address, balance): - #if !self.whitelist.check(msg.sender): - # return(-1) - self.cashcoinBalances[address] = balance - return(1) diff --git a/old_test/support/contracts/crowdsale.sol b/old_test/support/contracts/crowdsale.sol deleted file mode 100644 index a882dc819..000000000 --- a/old_test/support/contracts/crowdsale.sol +++ /dev/null @@ -1,51 +0,0 @@ -contract token { mapping (address => uint) public coinBalanceOf; function token() {} function sendCoin(address receiver, uint amount) returns(bool sufficient) { } } - -contract Crowdsale { - - address public beneficiary; - uint public fundingGoal; uint public amountRaised; uint public deadline; uint public price; - token public tokenReward; - Funder[] public funders; - event FundTransfer(address backer, uint amount, bool isContribution); - - /* data structure to hold information about campaign contributors */ - struct Funder { - address addr; - uint amount; - } - - /* at initialization, setup the owner */ - function Crowdsale(address _beneficiary, uint _fundingGoal, uint _duration, uint _price, token _reward) { - beneficiary = _beneficiary; - fundingGoal = _fundingGoal; - deadline = now + _duration * 1 minutes; - price = _price; - tokenReward = token(_reward); - } - - /* The function without name is the default function that is called whenever anyone sends funds to a contract */ - function () { - uint amount = msg.value; - funders[funders.length++] = Funder({addr: msg.sender, amount: amount}); - amountRaised += amount; - tokenReward.sendCoin(msg.sender, amount / price); - FundTransfer(msg.sender, amount, true); - } - - modifier afterDeadline() { if (now >= deadline) _ } - - /* checks if the goal or time limit has been reached and ends the campaign */ - function checkGoalReached() afterDeadline { - if (amountRaised >= fundingGoal){ - beneficiary.send(amountRaised); - FundTransfer(beneficiary, amountRaised, false); - } else { - FundTransfer(0, 11, false); - for (uint i = 0; i < funders.length; ++i) { - funders[i].addr.send(funders[i].amount); - FundTransfer(funders[i].addr, funders[i].amount, false); - } - } - suicide(beneficiary); - } -} diff --git a/old_test/support/contracts/data_source.sol b/old_test/support/contracts/data_source.sol deleted file mode 100644 index 90b0c7843..000000000 --- a/old_test/support/contracts/data_source.sol +++ /dev/null @@ -1,11 +0,0 @@ -contract DataSource { - uint public storeData; - - function DataSource() { - } - - function set(uint num) { - storeData = num; - } - -} diff --git a/old_test/support/contracts/error.sol b/old_test/support/contracts/error.sol deleted file mode 100644 index c15c51587..000000000 --- a/old_test/support/contracts/error.sol +++ /dev/null @@ -1,14 +0,0 @@ -contract SimpleStorage { - uint public storedData; - - function SimpleStorage(uint initialValue) { - storedData2 = initialValue; - } - - function set(uint x) { - storedData = x; - } - function get() constant returns (uint retVal) { - return storedData; - } -} diff --git a/old_test/support/contracts/manager.sol b/old_test/support/contracts/manager.sol deleted file mode 100644 index 0445cee2e..000000000 --- a/old_test/support/contracts/manager.sol +++ /dev/null @@ -1,11 +0,0 @@ -contract Manager { - address public data; - - function Manager(address dataAddress) { - data = dataAddress; - } - - function update(address _addr) { - data = _addr; - } -} diff --git a/old_test/support/contracts/other.se b/old_test/support/contracts/other.se deleted file mode 100644 index c70f0c57b..000000000 --- a/old_test/support/contracts/other.se +++ /dev/null @@ -1,75 +0,0 @@ -# This software (Augur) allows buying && selling event outcomes in ethereum -# Copyright (C) 2015 Forecast Foundation -# This program is free software; you can redistribute it &&/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is free software: you can redistribute it &&/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# Any questions please contact joey@augur.net - -data cashcoinBalances[] - -def init(): - # test initial funds - self.cashcoinBalances[tx.origin] = 100000*2^64 - -# @return: cash balance of address -def balance(address): - return(self.cashcoinBalances[address]) - -# should send values as fixed point in UI (1 is 2^64, 4 is 4*2^64, .5 is 2^63, etc.) -# so cashcoin fees could just go to root branch, or we could not have fees besides -# gas fee to do a send transaction -# @return: value sent, 0 if fails -def send(recver, value): - sender = tx.origin - senderBalance = self.cashcoinBalances[sender] - if(senderBalance >= value): - self.cashcoinBalances[sender] -= value - self.cashcoinBalances[recver] += value - return(value) - else: - return(0) - -# @return value of cash sent; fail is 0 -def sendFrom(recver, value, from): - if(from!=tx.origin): - return(0) - senderBalance = self.cashcoinBalances[from] - if(senderBalance >= value): - self.cashcoinBalances[from] -= value - self.cashcoinBalances[recver] += value - return(value) - else: - return(0) - -# make sure only coming from specific contracts -def subtractCash(ID, amount): - #if(!self.whitelist.check(msg.sender)): - # return(-1) - self.cashcoinBalances[ID] -= amount - return(1) - -def addCash(ID, amount): - #if(!self.whitelist.check(msg.sender)): - # return(-1) - self.cashcoinBalances[ID] += amount - return(1) - -def setCash(address, balance): - #if !self.whitelist.check(msg.sender): - # return(-1) - self.cashcoinBalances[address] = balance - return(1) diff --git a/old_test/support/contracts/simple_storage.sol b/old_test/support/contracts/simple_storage.sol deleted file mode 100644 index 0b12e43db..000000000 --- a/old_test/support/contracts/simple_storage.sol +++ /dev/null @@ -1,14 +0,0 @@ -contract SimpleStorage { - uint public storedData; - - function SimpleStorage(uint initialValue) { - storedData = initialValue; - } - - function set(uint x) { - storedData = x; - } - function get() constant returns (uint retVal) { - return storedData; - } -} diff --git a/old_test/support/contracts/token.sol b/old_test/support/contracts/token.sol deleted file mode 100644 index 9f67a1515..000000000 --- a/old_test/support/contracts/token.sol +++ /dev/null @@ -1,19 +0,0 @@ -contract token { - mapping (address => uint) public coinBalanceOf; - event CoinTransfer(address sender, address receiver, uint amount); - - /* Initializes contract with initial supply tokens to the creator of the contract */ - function token(uint supply) { - //coinBalanceOf[msg.sender] = (supply || 10000); - coinBalanceOf[msg.sender] = 10000; - } - - /* Very simple trade function */ - function sendCoin(address receiver, uint amount) returns(bool sufficient) { - if (coinBalanceOf[msg.sender] < amount) return false; - coinBalanceOf[msg.sender] -= amount; - coinBalanceOf[receiver] += amount; - CoinTransfer(msg.sender, receiver, amount); - return true; - } -} diff --git a/old_test/support/contracts/wallet.sol b/old_test/support/contracts/wallet.sol deleted file mode 100644 index 576e8648f..000000000 --- a/old_test/support/contracts/wallet.sol +++ /dev/null @@ -1,8 +0,0 @@ -contract Wallet { - address currency; - - function Wallet(address c) { - currency = c; - } - -} diff --git a/old_test/support/contracts/wallets.sol b/old_test/support/contracts/wallets.sol deleted file mode 100644 index 38e3f0eb8..000000000 --- a/old_test/support/contracts/wallets.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract Wallets { - address wallet; - - function Wallet(address w) { - wallet = w; - } - -} - diff --git a/old_test/support/instances.yml b/old_test/support/instances.yml deleted file mode 100644 index 04172a485..000000000 --- a/old_test/support/instances.yml +++ /dev/null @@ -1,12 +0,0 @@ -development: - SimpleStorage: - deploy: false - args: - - 100 - BarStorage: - instanceOf: SimpleStorage - FooStorage: - instanceOf: SimpleStorage - args: - - 200 -staging: diff --git a/old_test/test.js b/old_test/test.js deleted file mode 100644 index 1c0d16607..000000000 --- a/old_test/test.js +++ /dev/null @@ -1,29 +0,0 @@ -var Config = require('../lib/config/config.js'); -var Test = require('../lib/test.js'); -var Compiler = require('../lib/compiler.js'); -var assert = require('assert'); - -//var contractFiles = grunt.file.expand("./app/contracts/**/*.sol") - -describe('embark.test', function() { - //var files = [ - // 'test/support/contracts/simple_storage.sol' - //] - //var _blockchainConfig = (new Config.Blockchain()).loadConfigFile('test/support/blockchain.yml'); - //var blockchainConfig = _blockchainConfig.config("development"); - //var compiler = new Compiler(_blockchainConfig); - //var contractsConfig = new Config.Contracts(blockchainConfig, compiler); - //contractsConfig.loadConfigFile('test/support/contracts.yml'); - //contractsConfig.init(files, 'development'); - - //describe('simple test', function() { - // var embarkSpec = new Test(contractsConfig, files); - - // it('execute simple test', function() { - // var SimpleStorage = embarkSpec.request('SimpleStorage', [100]) - - // assert.equal(SimpleStorage.storedData(), '100'); - // }); - //}); - -});