aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDimitry <winsvega@mail.ru>2016-06-14 23:01:57 +0800
committerchriseth <c@ethdev.com>2016-06-29 05:18:55 +0800
commit763faf7b0e56cde9845772de5226c9b6f1a5d80a (patch)
tree14660008fc89ee655fd51563c268d45da43b5596 /test
parentce2258b71e632e01b3f50d47704352065cb01b5d (diff)
downloaddexon-solidity-763faf7b0e56cde9845772de5226c9b6f1a5d80a.tar.gz
dexon-solidity-763faf7b0e56cde9845772de5226c9b6f1a5d80a.tar.zst
dexon-solidity-763faf7b0e56cde9845772de5226c9b6f1a5d80a.zip
replace BalanceAt
add addressHasCode remove m_state and sealengine
Diffstat (limited to 'test')
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp4
-rw-r--r--test/contracts/Wallet.cpp26
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp6
-rw-r--r--test/libsolidity/SolidityExecutionFramework.cpp12
-rw-r--r--test/libsolidity/SolidityExecutionFramework.h3
5 files changed, 27 insertions, 24 deletions
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index 35f0842d..df521e7e 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -234,9 +234,9 @@ BOOST_AUTO_TEST_CASE(disown)
BOOST_CHECK(callContractFunction("setAddr(string,address)", u256(0x40), u256(124), u256(name.length()), name) == encodeArgs());
BOOST_CHECK(callContractFunction("setSubRegistrar(string,address)", u256(0x40), u256(125), u256(name.length()), name) == encodeArgs());
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x124)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x124)), 0);
BOOST_CHECK(callContractFunction("disown(string,address)", u256(0x40), u256(0x124), name.size(), name) == encodeArgs());
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x124)), m_fee);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x124)), m_fee);
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(u256(0)));
BOOST_CHECK(callContractFunction("content(string)", encodeDyn(name)) == encodeArgs(u256(0)));
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index 060525b0..29fe5b8d 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -555,17 +555,17 @@ BOOST_AUTO_TEST_CASE(multisig_value_transfer)
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// check that balance is and stays zero at destination address
h256 opHash("6244b4fa93f73e09db0ae52750095ca0364a76b72bc01723c97011fcb876cc9e");
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
m_sender = Address(0x12);
BOOST_REQUIRE(callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00) == encodeArgs(opHash));
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
m_sender = Address(0x13);
BOOST_REQUIRE(callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00) == encodeArgs(opHash));
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
m_sender = Address(0x14);
BOOST_REQUIRE(callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00) == encodeArgs(opHash));
// now it should go through
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 100);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 100);
}
BOOST_AUTO_TEST_CASE(revoke_addOwner)
@@ -606,22 +606,22 @@ BOOST_AUTO_TEST_CASE(revoke_transaction)
// create a transaction
Address deployer = m_sender;
h256 opHash("6244b4fa93f73e09db0ae52750095ca0364a76b72bc01723c97011fcb876cc9e");
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
m_sender = Address(0x12);
BOOST_REQUIRE(callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00) == encodeArgs(opHash));
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
m_sender = Address(0x13);
BOOST_REQUIRE(callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00) == encodeArgs(opHash));
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
m_sender = Address(0x12);
BOOST_REQUIRE(callContractFunction("revoke(bytes32)", opHash) == encodeArgs());
m_sender = deployer;
BOOST_REQUIRE(callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00) == encodeArgs(opHash));
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
m_sender = Address(0x14);
BOOST_REQUIRE(callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00) == encodeArgs(opHash));
// now it should go through
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 100);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 100);
}
BOOST_AUTO_TEST_CASE(daylimit)
@@ -637,27 +637,27 @@ BOOST_AUTO_TEST_CASE(daylimit)
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// try to send tx over daylimit
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
m_sender = Address(0x12);
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", h256(0x05), 150, 0x60, 0x00) !=
encodeArgs(u256(0))
);
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
// try to send tx under daylimit by stranger
m_sender = Address(0x77);
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", h256(0x05), 90, 0x60, 0x00) ==
encodeArgs(u256(0))
);
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 0);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
// now send below limit by owner
m_sender = Address(0x12);
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", h256(0x05), 90, 0x60, 0x00) ==
encodeArgs(u256(0))
);
- BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 90);
+ BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 90);
}
BOOST_AUTO_TEST_CASE(daylimit_constructor)
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 7ab49248..8689d61e 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -1653,7 +1653,7 @@ BOOST_AUTO_TEST_CASE(suicide)
compileAndRun(sourceCode, amount);
u160 address(23);
BOOST_CHECK(callContractFunction("a(address)", address) == bytes());
- BOOST_CHECK(!m_state.addressHasCode(m_contractAddress));
+ BOOST_CHECK(!addressHasCode(m_contractAddress));
BOOST_CHECK_EQUAL(balanceAt(address), amount);
}
@@ -1669,7 +1669,7 @@ BOOST_AUTO_TEST_CASE(selfdestruct)
compileAndRun(sourceCode, amount);
u160 address(23);
BOOST_CHECK(callContractFunction("a(address)", address) == bytes());
- BOOST_CHECK(!m_state.addressHasCode(m_contractAddress));
+ BOOST_CHECK(!addressHasCode(m_contractAddress));
BOOST_CHECK_EQUAL(balanceAt(address), amount);
}
@@ -2467,7 +2467,7 @@ BOOST_AUTO_TEST_CASE(use_std_lib)
compileAndRun(sourceCode, amount, "Icarus");
u256 balanceBefore = balanceAt(m_sender);
BOOST_CHECK(callContractFunction("kill()") == bytes());
- BOOST_CHECK(!m_state.addressHasCode(m_contractAddress));
+ BOOST_CHECK(!addressHasCode(m_contractAddress));
BOOST_CHECK(balanceAt(m_sender) > balanceBefore);
}
diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp
index db48c3a1..43d36f38 100644
--- a/test/libsolidity/SolidityExecutionFramework.cpp
+++ b/test/libsolidity/SolidityExecutionFramework.cpp
@@ -30,12 +30,10 @@ using namespace dev::solidity::test;
ExecutionFramework::ExecutionFramework():
- m_rpc(RPCSession::instance("/tmp/test/geth.ipc")),
- m_sender(m_rpc.account(0)),
- m_state(0)
+ m_rpc(RPCSession::instance("/home/wins/Ethereum/testnet/ethnode1/geth.ipc")),
+ m_sender(m_rpc.account(0))
{
eth::NoProof::init();
- m_sealEngine.reset(eth::ChainParams().createSealEngine());
if (g_logVerbosity != -1)
g_logVerbosity = 0;
@@ -84,6 +82,12 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256
}
}
+bool ExecutionFramework::addressHasCode(Address const& _addr)
+{
+ string code = m_rpc.eth_getCode(toString(_addr), "latest");
+ return !code.empty() && code != "0x";
+}
+
u256 ExecutionFramework::balanceAt(Address const& _addr)
{
return u256(m_rpc.eth_getBalance(toString(_addr), "latest"));
diff --git a/test/libsolidity/SolidityExecutionFramework.h b/test/libsolidity/SolidityExecutionFramework.h
index f2366d50..42b22c82 100644
--- a/test/libsolidity/SolidityExecutionFramework.h
+++ b/test/libsolidity/SolidityExecutionFramework.h
@@ -253,6 +253,7 @@ protected:
u256 balanceAt(Address const& _addr);
bool storageEmpty(Address const& _addr);
+ bool addressHasCode(Address const& _addr);
RPCSession& m_rpc;
@@ -263,7 +264,6 @@ protected:
bytes data;
};
- std::unique_ptr<eth::SealEngineFace> m_sealEngine;
size_t m_optimizeRuns = 200;
bool m_optimize = false;
bool m_addStandardSources = false;
@@ -271,7 +271,6 @@ protected:
Address m_sender;
Address m_contractAddress;
eth::EnvInfo m_envInfo;
- eth::State m_state;
u256 const m_gasPrice = 100 * eth::szabo;
u256 const m_gas = 100000000;
bytes m_output;