diff options
author | Gav Wood <i@gavwood.com> | 2014-01-20 22:53:02 +0800 |
---|---|---|
committer | Gav Wood <i@gavwood.com> | 2014-01-20 22:53:02 +0800 |
commit | a08ce2bde1ea3f7650251e96c62389166972a249 (patch) | |
tree | b5c06fa2bedb4378cf5cbcfbef8cc415f925e91e /state.cpp | |
parent | 6eafb9e6f8ff3cd5520bdba953d69ea789a74a30 (diff) | |
download | dexon-solidity-a08ce2bde1ea3f7650251e96c62389166972a249.tar.gz dexon-solidity-a08ce2bde1ea3f7650251e96c62389166972a249.tar.zst dexon-solidity-a08ce2bde1ea3f7650251e96c62389166972a249.zip |
Various fixes.
Diffstat (limited to 'state.cpp')
-rw-r--r-- | state.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -20,43 +20,44 @@ * State test functions. */ +#include <secp256k1.h> +#include <BlockChain.h> #include <State.h> using namespace std; using namespace eth; -struct KeyPair -{ - KeyPair() {} - KeyPair(PrivateKey _k): priv(_k), addr(toPublic(_k)) {} - PrivateKey priv; - Address addr; -}; - int stateTest() { KeyPair me = sha3("Gav Wood"); KeyPair myMiner = sha3("Gav's Miner"); // KeyPair you = sha3("123"); - State s(myMiner.addr); + BlockChain bc("/tmp"); + State s(myMiner.address(), "/tmp"); // Mine to get some ether! - s.mine(); + s.commitToMine(bc); + while (!s.mine(100)) {} + bc.attemptImport(s.blockData()); + s.sync(bc); bytes tx; { Transaction t; - t.nonce = s.transactionsFrom(myMiner.addr); + t.nonce = s.transactionsFrom(myMiner.address()); t.fee = 0; - t.value = 1; // 1 wei. - t.receiveAddress = me.addr; - t.sign(myMiner.priv); + t.value = 1000000000; // 1e9 wei. + t.receiveAddress = me.address(); + t.sign(myMiner.secret()); tx = t.rlp(); } cout << RLP(tx) << endl; s.execute(tx); - // TODO: Mine to set in stone. + s.commitToMine(bc); + while (!s.mine(100)) {} + bc.attemptImport(s.blockData()); + s.sync(bc); return 0; } |