aboutsummaryrefslogtreecommitdiffstats
path: root/state.cpp
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2014-01-21 02:43:11 +0800
committerGav Wood <i@gavwood.com>2014-01-21 02:43:11 +0800
commit8ab00968cbb09db65f45045ca8198cf402d00796 (patch)
treeed1112a8ad2e3bb0135548d0a07e4f1e77aa0a05 /state.cpp
parenta08ce2bde1ea3f7650251e96c62389166972a249 (diff)
downloaddexon-solidity-8ab00968cbb09db65f45045ca8198cf402d00796.tar.gz
dexon-solidity-8ab00968cbb09db65f45045ca8198cf402d00796.tar.zst
dexon-solidity-8ab00968cbb09db65f45045ca8198cf402d00796.zip
Working state-transition test.
Diffstat (limited to 'state.cpp')
-rw-r--r--state.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/state.cpp b/state.cpp
index 517e1d5d..ce12baaf 100644
--- a/state.cpp
+++ b/state.cpp
@@ -35,30 +35,43 @@ int stateTest()
BlockChain bc("/tmp");
State s(myMiner.address(), "/tmp");
+ cout << dec << "me: " << s.balance(me.address()) << endl;
+ cout << "myMiner: " << s.balance(myMiner.address()) << endl;
+
// Mine to get some ether!
s.commitToMine(bc);
while (!s.mine(100)) {}
bc.attemptImport(s.blockData());
s.sync(bc);
+ cout << "me: " << s.balance(me.address()) << endl;
+ cout << "myMiner: " << s.balance(myMiner.address()) << endl;
+
bytes tx;
{
Transaction t;
t.nonce = s.transactionsFrom(myMiner.address());
t.fee = 0;
- t.value = 1000000000; // 1e9 wei.
+ t.value = 1000; // 1e3 wei.
t.receiveAddress = me.address();
t.sign(myMiner.secret());
+ assert(t.sender() == myMiner.address());
tx = t.rlp();
}
- cout << RLP(tx) << endl;
s.execute(tx);
+ cout << "me: " << s.balance(me.address()) << endl;
+ cout << "myMiner: " << s.balance(myMiner.address()) << endl;
+
s.commitToMine(bc);
while (!s.mine(100)) {}
bc.attemptImport(s.blockData());
s.sync(bc);
+ cout << "me: " << s.balance(me.address()) << endl;
+ cout << "myMiner: " << s.balance(myMiner.address()) << endl;
+// s.dumpAccounts();
+
return 0;
}