mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
State updater tested and working pretty well.
This commit is contained in:
parent
8ab00968cb
commit
129e4b4dfc
8
main.cpp
8
main.cpp
@ -31,11 +31,11 @@ int hexPrefixTest();
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
hexPrefixTest();
|
// hexPrefixTest();
|
||||||
rlpTest();
|
// rlpTest();
|
||||||
trieTest();
|
// trieTest();
|
||||||
// daggerTest();
|
// daggerTest();
|
||||||
cryptoTest();
|
// cryptoTest();
|
||||||
stateTest();
|
stateTest();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
41
state.cpp
41
state.cpp
@ -32,21 +32,31 @@ int stateTest()
|
|||||||
KeyPair myMiner = sha3("Gav's Miner");
|
KeyPair myMiner = sha3("Gav's Miner");
|
||||||
// KeyPair you = sha3("123");
|
// KeyPair you = sha3("123");
|
||||||
|
|
||||||
BlockChain bc("/tmp");
|
Defaults::setDBPath("/tmp");
|
||||||
State s(myMiner.address(), "/tmp");
|
|
||||||
|
|
||||||
cout << dec << "me: " << s.balance(me.address()) << endl;
|
Overlay stateDB = State::openDB();
|
||||||
cout << "myMiner: " << s.balance(myMiner.address()) << endl;
|
BlockChain bc;
|
||||||
|
State s(myMiner.address(), stateDB);
|
||||||
|
|
||||||
|
cout << bc;
|
||||||
|
|
||||||
|
// Sync up - this won't do much until we use the last state.
|
||||||
|
s.sync(bc);
|
||||||
|
|
||||||
|
cout << s;
|
||||||
|
|
||||||
// Mine to get some ether!
|
// Mine to get some ether!
|
||||||
s.commitToMine(bc);
|
s.commitToMine(bc);
|
||||||
while (!s.mine(100)) {}
|
while (s.mine(100).empty()) {}
|
||||||
bc.attemptImport(s.blockData());
|
bc.attemptImport(s.blockData(), stateDB);
|
||||||
|
|
||||||
|
cout << bc;
|
||||||
|
|
||||||
s.sync(bc);
|
s.sync(bc);
|
||||||
|
|
||||||
cout << "me: " << s.balance(me.address()) << endl;
|
cout << s;
|
||||||
cout << "myMiner: " << s.balance(myMiner.address()) << endl;
|
|
||||||
|
|
||||||
|
// Inject a transaction to transfer funds from miner to me.
|
||||||
bytes tx;
|
bytes tx;
|
||||||
{
|
{
|
||||||
Transaction t;
|
Transaction t;
|
||||||
@ -60,17 +70,18 @@ int stateTest()
|
|||||||
}
|
}
|
||||||
s.execute(tx);
|
s.execute(tx);
|
||||||
|
|
||||||
cout << "me: " << s.balance(me.address()) << endl;
|
cout << s;
|
||||||
cout << "myMiner: " << s.balance(myMiner.address()) << endl;
|
|
||||||
|
|
||||||
|
// Mine to get some ether and set in stone.
|
||||||
s.commitToMine(bc);
|
s.commitToMine(bc);
|
||||||
while (!s.mine(100)) {}
|
while (s.mine(100).empty()) {}
|
||||||
bc.attemptImport(s.blockData());
|
bc.attemptImport(s.blockData(), stateDB);
|
||||||
|
|
||||||
|
cout << bc;
|
||||||
|
|
||||||
s.sync(bc);
|
s.sync(bc);
|
||||||
|
|
||||||
cout << "me: " << s.balance(me.address()) << endl;
|
cout << s;
|
||||||
cout << "myMiner: " << s.balance(myMiner.address()) << endl;
|
|
||||||
// s.dumpAccounts();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user