aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Jentzsch <jentzsch.software@gmail.com>2014-11-06 01:30:38 +0800
committerChristoph Jentzsch <jentzsch.software@gmail.com>2014-11-06 01:30:38 +0800
commit6b6bb65eb8bdca8754d334510fc6938ff4b1ef5c (patch)
treed2775998cd0051a5e53a4f7528be3487667a77c6
parent26f4637205d91ba6bb3db4b70b51d9e8b2b41b8e (diff)
downloaddexon-solidity-6b6bb65eb8bdca8754d334510fc6938ff4b1ef5c.tar.gz
dexon-solidity-6b6bb65eb8bdca8754d334510fc6938ff4b1ef5c.tar.zst
dexon-solidity-6b6bb65eb8bdca8754d334510fc6938ff4b1ef5c.zip
Update transactions, style fix
-rw-r--r--TestHelper.cpp61
-rw-r--r--state.cpp8
-rw-r--r--stateOriginal.cpp7
-rw-r--r--vm.cpp14
-rw-r--r--vmSha3TestFiller.json30
5 files changed, 35 insertions, 85 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp
index 68fdd748..277c3351 100644
--- a/TestHelper.cpp
+++ b/TestHelper.cpp
@@ -65,7 +65,7 @@ void connectClients(Client& c1, Client& c2)
namespace test
{
-ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller):m_TestObject(_o)
+ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller): m_TestObject(_o)
{
importEnv(_o["env"].get_obj());
importState(_o["pre"].get_obj(), m_statePre);
@@ -79,12 +79,12 @@ ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller):m_TestObject(_o)
void ImportTest::importEnv(json_spirit::mObject& _o)
{
- assert(_o.count("previousHash") > 0);
- assert(_o.count("currentGasLimit") > 0);
- assert(_o.count("currentDifficulty") > 0);
- assert(_o.count("currentTimestamp") > 0);
- assert(_o.count("currentCoinbase") > 0);
- assert(_o.count("currentNumber") > 0);
+ BOOST_REQUIRE(_o.count("previousHash") > 0);
+ BOOST_REQUIRE(_o.count("currentGasLimit") > 0);
+ BOOST_REQUIRE(_o.count("currentDifficulty") > 0);
+ BOOST_REQUIRE(_o.count("currentTimestamp") > 0);
+ BOOST_REQUIRE(_o.count("currentCoinbase") > 0);
+ BOOST_REQUIRE(_o.count("currentNumber") > 0);
m_environment.previousBlock.hash = h256(_o["previousHash"].get_str());
m_environment.currentBlock.number = toInt(_o["currentNumber"]);
@@ -103,10 +103,10 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
{
json_spirit::mObject o = i.second.get_obj();
- assert(o.count("balance") > 0);
- assert(o.count("nonce") > 0);
- assert(o.count("storage") > 0);
- assert(o.count("code") > 0);
+ BOOST_REQUIRE(o.count("balance") > 0);
+ BOOST_REQUIRE(o.count("nonce") > 0);
+ BOOST_REQUIRE(o.count("storage") > 0);
+ BOOST_REQUIRE(o.count("code") > 0);
Address address = Address(i.first);
@@ -115,8 +115,7 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
bytes code = importCode(o);
- toInt(o["nonce"]);
- if (toHex(code).size())
+ if (code.size())
{
_state.m_cache[address] = Account(toInt(o["balance"]), Account::ContractConception);
i.second.get_obj()["code"] = "0x" + toHex(code); //preperation for export
@@ -134,23 +133,17 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
void ImportTest::importTransaction(json_spirit::mObject& _o)
{
- assert(_o.count("nonce")> 0);
- assert(_o.count("gasPrice") > 0);
- assert(_o.count("gasLimit") > 0);
- assert(_o.count("to") > 0);
- assert(_o.count("value") > 0);
- assert(_o.count("secretKey") > 0);
- assert(_o.count("data") > 0);
-
- m_transaction.nonce = toInt(_o["nonce"]);
- m_transaction.gasPrice = toInt(_o["gasPrice"]);
- m_transaction.gas = toInt(_o["gasLimit"]);
- m_transaction.receiveAddress = Address(_o["to"].get_str());
- m_transaction.type = m_transaction.receiveAddress ? Transaction::MessageCall : Transaction::ContractCreation;
- m_transaction.value = toInt(_o["value"]);
- Secret secretKey = Secret(_o["secretKey"].get_str());
- m_transaction.sign(secretKey);
- m_transaction.data = importData(_o);
+ BOOST_REQUIRE(_o.count("nonce")> 0);
+ BOOST_REQUIRE(_o.count("gasPrice") > 0);
+ BOOST_REQUIRE(_o.count("gasLimit") > 0);
+ BOOST_REQUIRE(_o.count("to") > 0);
+ BOOST_REQUIRE(_o.count("value") > 0);
+ BOOST_REQUIRE(_o.count("secretKey") > 0);
+ BOOST_REQUIRE(_o.count("data") > 0);
+
+ m_transaction = _o["to"].get_str().empty() ?
+ Transaction(toInt(_o["value"]), toInt(_o["gasPrice"]), toInt(_o["gasLimit"]), importData(_o), toInt(_o["nonce"]), Secret(_o["secretKey"].get_str())) :
+ Transaction(toInt(_o["value"]), toInt(_o["gasPrice"]), toInt(_o["gasLimit"]), Address(_o["to"].get_str()), importData(_o), toInt(_o["nonce"]), Secret(_o["secretKey"].get_str()));
}
void ImportTest::exportTest(bytes _output, State& _statePost)
@@ -210,7 +203,7 @@ byte toByte(json_spirit::mValue const& _v)
return 0;
}
-bytes importData(json_spirit::mObject & _o)
+bytes importData(json_spirit::mObject& _o)
{
bytes data;
if (_o["data"].type() == json_spirit::str_type)
@@ -225,7 +218,7 @@ bytes importData(json_spirit::mObject & _o)
return data;
}
-bytes importCode(json_spirit::mObject & _o)
+bytes importCode(json_spirit::mObject& _o)
{
bytes code;
if (_o["code"].type() == json_spirit::str_type)
@@ -238,11 +231,11 @@ bytes importCode(json_spirit::mObject & _o)
code.clear();
for (auto const& j: _o["code"].get_array())
code.push_back(toByte(j));
- }
+ }
return code;
}
-void checkOutput(bytes const& _output, json_spirit::mObject & _o)
+void checkOutput(bytes const& _output, json_spirit::mObject& _o)
{
int j = 0;
if (_o["out"].type() == json_spirit::array_type)
diff --git a/state.cpp b/state.cpp
index 3a81821e..2e313cc4 100644
--- a/state.cpp
+++ b/state.cpp
@@ -121,10 +121,10 @@ BOOST_AUTO_TEST_CASE(stExample)
dev::test::executeTests("stExample", "/StateTests", dev::test::doStateTests);
}
-//BOOST_AUTO_TEST_CASE(stSystemOperationsTest)
-//{
-// dev::test::executeStateTests("stSystemOperationsTest");
-//}
+BOOST_AUTO_TEST_CASE(stSystemOperationsTest)
+{
+ dev::test::executeTests("stSystemOperationsTest", "/StateTests", dev::test::doStateTests);
+}
BOOST_AUTO_TEST_CASE(tmp)
{
diff --git a/stateOriginal.cpp b/stateOriginal.cpp
index e6b3ab95..8344894f 100644
--- a/stateOriginal.cpp
+++ b/stateOriginal.cpp
@@ -65,12 +65,7 @@ int stateTest()
// Inject a transaction to transfer funds from miner to me.
bytes tx;
{
- Transaction t;
- t.nonce = s.transactionsFrom(myMiner.address());
- t.value = 1000; // 1e3 wei.
- t.type = eth::Transaction::MessageCall;
- t.receiveAddress = me.address();
- t.sign(myMiner.secret());
+ Transaction t(1000, 0, 0, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret());
assert(t.sender() == myMiner.address());
tx = t.rlp();
}
diff --git a/vm.cpp b/vm.cpp
index b9df6af2..0457d7bb 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -232,8 +232,8 @@ void FakeExtVM::importCallCreates(mArray& _callcreates)
BOOST_REQUIRE(tx.count("destination") > 0);
BOOST_REQUIRE(tx.count("gasLimit") > 0);
Transaction t = tx["destination"].get_str().empty() ?
- Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), data) :
- Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), Address(tx["destination"].get_str()), data);
+ Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), data.toBytes()) :
+ Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), Address(tx["destination"].get_str()), data.toBytes());
callcreates.push_back(t);
}
}
@@ -423,16 +423,6 @@ BOOST_AUTO_TEST_CASE(vmPushDupSwapTest)
dev::test::executeTests("vmPushDupSwapTest", "/VMTests", dev::test::doVMTests);
}
-BOOST_AUTO_TEST_CASE(vmNamecoin)
-{
- dev::test::executeTests("vmNamecoin", "/VMTests", dev::test::doVMTests);
-}
-
-//BOOST_AUTO_TEST_CASE(vmSystemOperationsTest)
-//{
-// dev::test::executeTests("vmSystemOperationsTest", "/VMTests", dev::test::doVMTests);
-//}
-
BOOST_AUTO_TEST_CASE(userDefinedFile)
{
if (boost::unit_test::framework::master_test_suite().argc == 2)
diff --git a/vmSha3TestFiller.json b/vmSha3TestFiller.json
index 03391e8c..beb1ea22 100644
--- a/vmSha3TestFiller.json
+++ b/vmSha3TestFiller.json
@@ -167,7 +167,7 @@
}
},
- "sha3_4": {
+ "sha3_5": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
@@ -194,32 +194,4 @@
"gas" : "10000"
}
},
-
-// "sha3_5": {
-// "env" : {
-// "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
-// "currentNumber" : "0",
-// "currentGasLimit" : "1000000",
-// "currentDifficulty" : "256",
-// "currentTimestamp" : 1,
-// "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
-// },
-// "pre" : {
-// "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
-// "balance" : "1000000000000000000",
-// "nonce" : 0,
-// "code" : "{ [[ 0 ]] (SHA3 100 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)}",
-// "storage": {}
-// }
-// },
-// "exec" : {
-// "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
-// "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
-// "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
-// "value" : "1000000000000000000",
-// "data" : "",
-// "gasPrice" : "100000000000000",
-// "gas" : "10000"
-// }
-// }
}