parent
6b2270d5d0
commit
ba6bbd8541
@ -1,17 +0,0 @@ |
||||
pragma solidity ^0.4.7; |
||||
contract SimpleStorage { |
||||
uint public storedData; |
||||
|
||||
function SimpleStorage() public { |
||||
storedData = 100; |
||||
} |
||||
|
||||
function set(uint x) public { |
||||
storedData = x; |
||||
} |
||||
|
||||
function get() public view returns (uint retVal) { |
||||
return storedData; |
||||
} |
||||
|
||||
} |
@ -1,26 +0,0 @@ |
||||
pragma solidity ^0.4.7; |
||||
import "./tests.sol"; |
||||
import "./simple_storage.sol"; |
||||
|
||||
contract MyTest2 { |
||||
SimpleStorage foo; |
||||
uint i = 0; |
||||
|
||||
function beforeEach() { |
||||
foo = new SimpleStorage(); |
||||
//if (i == 1) { |
||||
// foo.set(200); |
||||
//} |
||||
//i += 1; |
||||
} |
||||
|
||||
function initialValueShouldBe100() public constant returns (bool) { |
||||
return Assert.equal(foo.get(), 100, "initial value is not correct"); |
||||
//return foo.get() == 100; |
||||
} |
||||
|
||||
//function initialValueShouldBe200() public constant returns (bool) { |
||||
// return Assert.equal(foo.get(), 200, "initial value is not correct"); |
||||
//} |
||||
|
||||
} |
@ -1,44 +0,0 @@ |
||||
pragma solidity ^0.4.7; |
||||
import "./tests.sol"; |
||||
import "./simple_storage.sol"; |
||||
|
||||
//contract MyTest { |
||||
// SimpleStorage foo; |
||||
// |
||||
// function beforeAll() { |
||||
// foo = new SimpleStorage(); |
||||
// } |
||||
// |
||||
// function initialValueShouldBe100() public { |
||||
// Assert.equal(foo.get(), 100, "initial value is not correct"); |
||||
// } |
||||
// |
||||
// function initialValueShouldBe200() public { |
||||
// Assert.equal(foo.get(), 200, "initial value is not correct"); |
||||
// } |
||||
// |
||||
//} |
||||
|
||||
contract MyTest { |
||||
SimpleStorage foo; |
||||
uint i = 0; |
||||
|
||||
function beforeEach() { |
||||
foo = new SimpleStorage(); |
||||
//if (i == 1) { |
||||
// foo.set(200); |
||||
//} |
||||
//i += 1; |
||||
} |
||||
|
||||
function initialValueShouldBe100() public constant returns (bool) { |
||||
return Assert.equal(foo.get(), 100, "initial value is not correct"); |
||||
} |
||||
|
||||
//function initialValueShouldBe200() public constant returns (bool) { |
||||
// return Assert.equal(foo.get(), 200, "initial value is not correct"); |
||||
//} |
||||
|
||||
} |
||||
|
||||
|
@ -1,20 +0,0 @@ |
||||
pragma solidity ^0.4.7; |
||||
import "./tests.sol"; |
||||
|
||||
contract MyTest { |
||||
SimpleStorage foo; |
||||
|
||||
function beforeAll() { |
||||
foo = new SimpleStorage(); |
||||
} |
||||
|
||||
function initialValueShouldBe100() public { |
||||
Assert.equal(foo.get(), 100, "initial value is not correct"); |
||||
} |
||||
|
||||
function initialValueShouldBe200() public { |
||||
Assert.equal(foo.get(), 200, "initial value is not correct"); |
||||
} |
||||
|
||||
} |
||||
|
@ -1,62 +0,0 @@ |
||||
var async = require('async') |
||||
const Web3 = require('web3') |
||||
const Provider = require('./src/provider.js') |
||||
const Compiler = require('./src/compiler.js') |
||||
|
||||
let web3 = new Web3() |
||||
web3.setProvider(new Provider()) |
||||
let accounts = []; |
||||
|
||||
async.waterfall([ |
||||
function compileContract(next) { |
||||
Compiler.compileFileOrFiles('test.sol', false, next); |
||||
}, |
||||
function getAccounts(contracts, next) { |
||||
web3.eth.getAccounts((err, _accounts) => { |
||||
accounts = _accounts; |
||||
next(null, contracts); |
||||
}); |
||||
}, |
||||
function deployContract(contracts, next) { |
||||
let contract = contracts['test.sol'].SimpleStorage; |
||||
let abi = contract.abi; |
||||
let code = contract.evm.bytecode.object; |
||||
|
||||
console.dir(contracts); |
||||
|
||||
let contractObject = new web3.eth.Contract(abi) |
||||
let deployObject = contractObject.deploy({arguments: [], data: code}) |
||||
|
||||
deployObject.send({ |
||||
from: accounts[0], |
||||
gas: 1200000 |
||||
}).on('receipt', function (receipt) { |
||||
console.dir("==== got the receipt"); |
||||
console.dir(receipt); |
||||
|
||||
contractObject.options.address = receipt.contractAddress |
||||
contractObject.options.from = accounts[0] |
||||
contractObject.options.gas = 5000 * 1000 |
||||
//next(null, receipt.contractAddress);
|
||||
next(null, contractObject); |
||||
}) |
||||
}, |
||||
function callContract(contract, next) { |
||||
console.dir('=============='); |
||||
console.dir(contract); |
||||
|
||||
//contract.methods.storedData().call(console.dir);
|
||||
//contract.methods.get().call(console.dir);
|
||||
contract.methods.set(50).send({from: accounts[0]}).then(() => { |
||||
console.dir('value was set'); |
||||
next(null, contract); |
||||
}); |
||||
}, |
||||
function callContract2(contract, next) { |
||||
contract.methods.get2().call(console.dir); |
||||
next(null, contract); |
||||
} |
||||
], function(err, results) { |
||||
//console.dir(arguments);
|
||||
}); |
||||
|
@ -1,22 +0,0 @@ |
||||
pragma solidity ^0.4.7; |
||||
contract SimpleStorage { |
||||
uint public storedData; |
||||
|
||||
function SimpleStorage() public { |
||||
storedData = 100; |
||||
} |
||||
|
||||
function set(uint x) public { |
||||
storedData = x; |
||||
} |
||||
|
||||
function get() public view returns (uint retVal) { |
||||
return storedData; |
||||
} |
||||
|
||||
function get2() public constant returns (bool) { |
||||
return storedData != 2; |
||||
} |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue