mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Working state-transition test.
This commit is contained in:
parent
a08ce2bde1
commit
8ab00968cb
17
state.cpp
17
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user