aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2014-01-21 23:51:57 +0800
committerGav Wood <i@gavwood.com>2014-01-21 23:51:57 +0800
commit129e4b4dfca26d896815f1b95e103f3f488468fc (patch)
treec8c3ffd426445af46237b348f96e4b7d948febb1
parent8ab00968cbb09db65f45045ca8198cf402d00796 (diff)
downloaddexon-solidity-129e4b4dfca26d896815f1b95e103f3f488468fc.tar.gz
dexon-solidity-129e4b4dfca26d896815f1b95e103f3f488468fc.tar.zst
dexon-solidity-129e4b4dfca26d896815f1b95e103f3f488468fc.zip
State updater tested and working pretty well.
-rw-r--r--main.cpp8
-rw-r--r--state.cpp41
2 files changed, 30 insertions, 19 deletions
diff --git a/main.cpp b/main.cpp
index ff2be2a5..e082b6ca 100644
--- a/main.cpp
+++ b/main.cpp
@@ -31,11 +31,11 @@ int hexPrefixTest();
int main()
{
- hexPrefixTest();
- rlpTest();
- trieTest();
+// hexPrefixTest();
+// rlpTest();
+// trieTest();
// daggerTest();
- cryptoTest();
+// cryptoTest();
stateTest();
return 0;
}
diff --git a/state.cpp b/state.cpp
index ce12baaf..d4201c57 100644
--- a/state.cpp
+++ b/state.cpp
@@ -32,21 +32,31 @@ int stateTest()
KeyPair myMiner = sha3("Gav's Miner");
// KeyPair you = sha3("123");
- BlockChain bc("/tmp");
- State s(myMiner.address(), "/tmp");
+ Defaults::setDBPath("/tmp");
- cout << dec << "me: " << s.balance(me.address()) << endl;
- cout << "myMiner: " << s.balance(myMiner.address()) << endl;
+ Overlay stateDB = State::openDB();
+ 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!
s.commitToMine(bc);
- while (!s.mine(100)) {}
- bc.attemptImport(s.blockData());
+ while (s.mine(100).empty()) {}
+ bc.attemptImport(s.blockData(), stateDB);
+
+ cout << bc;
+
s.sync(bc);
- cout << "me: " << s.balance(me.address()) << endl;
- cout << "myMiner: " << s.balance(myMiner.address()) << endl;
+ cout << s;
+ // Inject a transaction to transfer funds from miner to me.
bytes tx;
{
Transaction t;
@@ -60,17 +70,18 @@ int stateTest()
}
s.execute(tx);
- cout << "me: " << s.balance(me.address()) << endl;
- cout << "myMiner: " << s.balance(myMiner.address()) << endl;
+ cout << s;
+ // Mine to get some ether and set in stone.
s.commitToMine(bc);
- while (!s.mine(100)) {}
- bc.attemptImport(s.blockData());
+ while (s.mine(100).empty()) {}
+ bc.attemptImport(s.blockData(), stateDB);
+
+ cout << bc;
+
s.sync(bc);
- cout << "me: " << s.balance(me.address()) << endl;
- cout << "myMiner: " << s.balance(myMiner.address()) << endl;
-// s.dumpAccounts();
+ cout << s;
return 0;
}