aboutsummaryrefslogtreecommitdiffstats
path: root/test/contracts
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-06-18 08:08:20 +0800
committerchriseth <c@ethdev.com>2016-06-29 05:18:55 +0800
commite5db096da9a2bfb3e6445b2d89cf730c7e22dc6d (patch)
tree3e950203ff1b0cb53f81447f1350feb3add0da27 /test/contracts
parent007132a78e5d97e0476e1153b14f0ae63f458b04 (diff)
downloaddexon-solidity-e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d.tar
dexon-solidity-e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d.tar.gz
dexon-solidity-e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d.tar.bz2
dexon-solidity-e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d.tar.lz
dexon-solidity-e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d.tar.xz
dexon-solidity-e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d.tar.zst
dexon-solidity-e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d.zip
Fix some more tests.
Diffstat (limited to 'test/contracts')
-rw-r--r--test/contracts/AuctionRegistrar.cpp87
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp37
-rw-r--r--test/contracts/Wallet.cpp103
3 files changed, 130 insertions, 97 deletions
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index e30f4572..0eee42a4 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -285,8 +285,8 @@ protected:
}
};
- u256 const m_biddingTime = u256(7 * 24 * 3600);
- u256 const m_renewalInterval = u256(365 * 24 * 3600);
+ size_t const m_biddingTime = size_t(7 * 24 * 3600);
+ size_t const m_renewalInterval = size_t(365 * 24 * 3600);
};
}
@@ -304,7 +304,6 @@ BOOST_AUTO_TEST_CASE(reserve)
// Test that reserving works for long strings
deployRegistrar();
vector<string> names{"abcabcabcabcabc", "defdefdefdefdef", "ghighighighighighighighighighighighighighighi"};
- m_sender = Address(0x123);
RegistrarInterface registrar(*this);
@@ -315,7 +314,7 @@ BOOST_AUTO_TEST_CASE(reserve)
for (auto const& name: names)
{
registrar.reserve(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), u160(0x123));
+ BOOST_CHECK_EQUAL(registrar.owner(name), u160(m_sender));
}
}
@@ -324,14 +323,14 @@ BOOST_AUTO_TEST_CASE(double_reserve_long)
// Test that it is not possible to re-reserve from a different address.
deployRegistrar();
string name = "abcabcabcabcabcabcabcabcabcabca";
- m_sender = Address(0x123);
RegistrarInterface registrar(*this);
registrar.reserve(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), u160(0x123));
+ BOOST_CHECK_EQUAL(registrar.owner(name), m_sender);
- m_sender = Address(0x124);
+ sendEther(account(1), u256(10) * eth::ether);
+ m_sender = account(1);
registrar.reserve(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), u160(0x123));
+ BOOST_CHECK_EQUAL(registrar.owner(name), account(0));
}
BOOST_AUTO_TEST_CASE(properties)
@@ -341,14 +340,17 @@ BOOST_AUTO_TEST_CASE(properties)
RegistrarInterface registrar(*this);
string names[] = {"abcaeouoeuaoeuaoeu", "defncboagufra,fui", "ghagpyajfbcuajouhaeoi"};
size_t addr = 0x9872543;
+ size_t count = 1;
for (string const& name: names)
{
- addr++;
- size_t sender = addr + 10007;
- m_sender = Address(sender);
+ m_sender = account(0);
+ sendEther(account(count), u256(20) * eth::ether);
+ m_sender = account(count);
+ auto sender = m_sender;
+ addr += count;
// setting by sender works
registrar.reserve(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), u160(sender));
+ BOOST_CHECK_EQUAL(registrar.owner(name), sender);
registrar.setAddress(name, addr, true);
BOOST_CHECK_EQUAL(registrar.addr(name), u160(addr));
registrar.setSubRegistrar(name, addr + 20);
@@ -357,14 +359,15 @@ BOOST_AUTO_TEST_CASE(properties)
BOOST_CHECK_EQUAL(registrar.content(name), h256(u256(addr + 90)));
// but not by someone else
- m_sender = Address(h256(addr + 10007 - 1));
- BOOST_CHECK_EQUAL(registrar.owner(name), u160(sender));
+ m_sender = account(count - 1);
+ BOOST_CHECK_EQUAL(registrar.owner(name), sender);
registrar.setAddress(name, addr + 1, true);
BOOST_CHECK_EQUAL(registrar.addr(name), u160(addr));
registrar.setSubRegistrar(name, addr + 20 + 1);
BOOST_CHECK_EQUAL(registrar.subRegistrar(name), u160(addr + 20));
registrar.setContent(name, h256(u256(addr + 90 + 1)));
BOOST_CHECK_EQUAL(registrar.content(name), h256(u256(addr + 90)));
+ count++;
}
}
@@ -372,7 +375,6 @@ BOOST_AUTO_TEST_CASE(transfer)
{
deployRegistrar();
string name = "abcaoeguaoucaeoduceo";
- m_sender = Address(0x123);
RegistrarInterface registrar(*this);
registrar.reserve(name);
registrar.setContent(name, h256(u256(123)));
@@ -385,7 +387,7 @@ BOOST_AUTO_TEST_CASE(disown)
{
deployRegistrar();
string name = "abcaoeguaoucaeoduceo";
- m_sender = Address(0x123);
+
RegistrarInterface registrar(*this);
registrar.reserve(name);
registrar.setContent(name, h256(u256(123)));
@@ -394,11 +396,12 @@ BOOST_AUTO_TEST_CASE(disown)
BOOST_CHECK_EQUAL(registrar.name(u160(124)), name);
// someone else tries disowning
- m_sender = Address(0x128);
+ sendEther(account(1), u256(10) * eth::ether);
+ m_sender = account(1);
registrar.disown(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), 0x123);
+ BOOST_CHECK_EQUAL(registrar.owner(name), account(0));
- m_sender = Address(0x123);
+ m_sender = account(0);
registrar.disown(name);
BOOST_CHECK_EQUAL(registrar.owner(name), 0);
BOOST_CHECK_EQUAL(registrar.addr(name), 0);
@@ -411,7 +414,7 @@ BOOST_AUTO_TEST_CASE(auction_simple)
{
deployRegistrar();
string name = "x";
- m_sender = Address(0x123);
+
RegistrarInterface registrar(*this);
// initiate auction
registrar.setNextValue(8);
@@ -421,68 +424,70 @@ BOOST_AUTO_TEST_CASE(auction_simple)
m_envInfo.setTimestamp(m_envInfo.timestamp() + m_biddingTime + 10);
// trigger auction again
registrar.reserve(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), 0x123);
+ BOOST_CHECK_EQUAL(registrar.owner(name), m_sender);
}
BOOST_AUTO_TEST_CASE(auction_bidding)
{
deployRegistrar();
string name = "x";
- m_sender = Address(0x123);
+
+ unsigned startTime = 0x776347e2;
+ m_rpc.test_modifyTimestamp(startTime);
+
RegistrarInterface registrar(*this);
// initiate auction
registrar.setNextValue(8);
registrar.reserve(name);
BOOST_CHECK_EQUAL(registrar.owner(name), 0);
// overbid self
- m_envInfo.setTimestamp(m_biddingTime - 10);
+ m_rpc.test_modifyTimestamp(startTime + m_biddingTime - 10);
registrar.setNextValue(12);
registrar.reserve(name);
// another bid by someone else
- m_sender = Address(0x124);
- m_envInfo.setTimestamp(2 * m_biddingTime - 50);
+ sendEther(account(1), 10 * eth::ether);
+ m_sender = account(1);
+ m_rpc.test_modifyTimestamp(startTime + 2 * m_biddingTime - 50);
registrar.setNextValue(13);
registrar.reserve(name);
BOOST_CHECK_EQUAL(registrar.owner(name), 0);
// end auction by first bidder (which is not highest) trying to overbid again (too late)
- m_sender = Address(0x123);
- m_envInfo.setTimestamp(4 * m_biddingTime);
+ m_sender = account(0);
+ m_rpc.test_modifyTimestamp(startTime + 4 * m_biddingTime);
registrar.setNextValue(20);
registrar.reserve(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), 0x124);
+ BOOST_CHECK_EQUAL(registrar.owner(name), account(1));
}
BOOST_AUTO_TEST_CASE(auction_renewal)
{
deployRegistrar();
+
string name = "x";
RegistrarInterface registrar(*this);
+ size_t startTime = currentTimestamp();
// register name by auction
- m_sender = Address(0x123);
registrar.setNextValue(8);
registrar.reserve(name);
- m_envInfo.setTimestamp(4 * m_biddingTime);
+ m_rpc.test_modifyTimestamp(startTime + 4 * m_biddingTime);
registrar.reserve(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), 0x123);
+ BOOST_CHECK_EQUAL(registrar.owner(name), m_sender);
// try to re-register before interval end
- m_sender = Address(0x222);
+ sendEther(account(1), 10 * eth::ether);
+ m_sender = account(1);
+ m_rpc.test_modifyTimestamp(currentTimestamp() + m_renewalInterval - 1);
registrar.setNextValue(80);
- m_envInfo.setTimestamp(m_envInfo.timestamp() + m_renewalInterval - 1);
registrar.reserve(name);
- m_envInfo.setTimestamp(m_envInfo.timestamp() + m_biddingTime);
- // if there is a bug in the renewal logic, this would transfer the ownership to 0x222,
+ m_rpc.test_modifyTimestamp(currentTimestamp() + m_biddingTime);
+ // if there is a bug in the renewal logic, this would transfer the ownership to account(1),
// but if there is no bug, this will initiate the auction, albeit with a zero bid
registrar.reserve(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), 0x123);
+ BOOST_CHECK_EQUAL(registrar.owner(name), account(0));
- m_envInfo.setTimestamp(m_envInfo.timestamp() + 2);
registrar.setNextValue(80);
registrar.reserve(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), 0x123);
- m_envInfo.setTimestamp(m_envInfo.timestamp() + m_biddingTime + 2);
- registrar.reserve(name);
- BOOST_CHECK_EQUAL(registrar.owner(name), 0x222);
+ BOOST_CHECK_EQUAL(registrar.owner(name), account(1));
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index df521e7e..8575d1fc 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -157,11 +157,10 @@ BOOST_AUTO_TEST_CASE(reserve)
// Test that reserving works and fee is taken into account.
deployRegistrar();
string name[] = {"abc", "def", "ghi"};
- m_sender = Address(0x123);
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name[0])) == encodeArgs());
- BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[0])) == encodeArgs(h256(0x123)));
+ BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[0])) == encodeArgs(h256(account(0), h256::AlignRight)));
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee + 1, encodeDyn(name[1])) == encodeArgs());
- BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[1])) == encodeArgs(h256(0x123)));
+ BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[1])) == encodeArgs(h256(account(0), h256::AlignRight)));
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee - 1, encodeDyn(name[2])) == encodeArgs());
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[2])) == encodeArgs(h256(0)));
}
@@ -171,13 +170,13 @@ BOOST_AUTO_TEST_CASE(double_reserve)
// Test that it is not possible to re-reserve from a different address.
deployRegistrar();
string name = "abc";
- m_sender = Address(0x123);
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
- BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(h256(0x123)));
+ BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(h256(account(0), h256::AlignRight)));
- m_sender = Address(0x124);
+ sendEther(account(1), 10 * eth::ether);
+ m_sender = account(1);
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
- BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(h256(0x123)));
+ BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(h256(account(0), h256::AlignRight)));
}
BOOST_AUTO_TEST_CASE(properties)
@@ -186,29 +185,35 @@ BOOST_AUTO_TEST_CASE(properties)
deployRegistrar();
string names[] = {"abc", "def", "ghi"};
size_t addr = 0x9872543;
+ size_t count = 1;
for (string const& name: names)
{
addr++;
- size_t sender = addr + 10007;
- m_sender = Address(sender);
+ m_sender = account(0);
+ sendEther(account(count), 10 * eth::ether);
+ m_sender = account(count);
+ Address owner = m_sender;
// setting by sender works
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
- BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(u256(sender)));
+ BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(h256(owner, h256::AlignRight)));
BOOST_CHECK(callContractFunction("setAddr(string,address)", u256(0x40), u256(addr), u256(name.length()), name) == encodeArgs());
BOOST_CHECK(callContractFunction("addr(string)", encodeDyn(name)) == encodeArgs(addr));
BOOST_CHECK(callContractFunction("setSubRegistrar(string,address)", u256(0x40), addr + 20, u256(name.length()), name) == encodeArgs());
BOOST_CHECK(callContractFunction("subRegistrar(string)", encodeDyn(name)) == encodeArgs(addr + 20));
BOOST_CHECK(callContractFunction("setContent(string,bytes32)", u256(0x40), addr + 90, u256(name.length()), name) == encodeArgs());
BOOST_CHECK(callContractFunction("content(string)", encodeDyn(name)) == encodeArgs(addr + 90));
+ count++;
// but not by someone else
- m_sender = Address(h256(addr + 10007 - 1));
- BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(sender));
+ sendEther(account(count), 10 * eth::ether);
+ m_sender = account(count);
+ BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(h256(owner, h256::AlignRight)));
BOOST_CHECK(callContractFunction("setAddr(string,address)", u256(0x40), addr + 1, u256(name.length()), name) == encodeArgs());
BOOST_CHECK(callContractFunction("addr(string)", encodeDyn(name)) == encodeArgs(addr));
BOOST_CHECK(callContractFunction("setSubRegistrar(string,address)", u256(0x40), addr + 20 + 1, u256(name.length()), name) == encodeArgs());
BOOST_CHECK(callContractFunction("subRegistrar(string)", encodeDyn(name)) == encodeArgs(addr + 20));
BOOST_CHECK(callContractFunction("setContent(string,bytes32)", u256(0x40), addr + 90 + 1, u256(name.length()), name) == encodeArgs());
BOOST_CHECK(callContractFunction("content(string)", encodeDyn(name)) == encodeArgs(addr + 90));
+ count++;
}
}
@@ -216,21 +221,19 @@ BOOST_AUTO_TEST_CASE(transfer)
{
deployRegistrar();
string name = "abc";
- m_sender = Address(0x123);
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
- BOOST_CHECK(callContractFunction("setContent(string,bytes32)", u256(0x40), u256(123), u256(name.length()), name) == encodeArgs());
+ BOOST_CHECK(callContractFunction("setContent(string,bytes32)", u256(0x40), h256(account(0), h256::AlignRight), u256(name.length()), name) == encodeArgs());
BOOST_CHECK(callContractFunction("transfer(string,address)", u256(0x40), u256(555), u256(name.length()), name) == encodeArgs());
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(u256(555)));
- BOOST_CHECK(callContractFunction("content(string)", encodeDyn(name)) == encodeArgs(u256(123)));
+ BOOST_CHECK(callContractFunction("content(string)", encodeDyn(name)) == encodeArgs(h256(account(0), h256::AlignRight)));
}
BOOST_AUTO_TEST_CASE(disown)
{
deployRegistrar();
string name = "abc";
- m_sender = Address(0x123);
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
- BOOST_CHECK(callContractFunction("setContent(string,bytes32)", u256(0x40), u256(123), u256(name.length()), name) == encodeArgs());
+ BOOST_CHECK(callContractFunction("setContent(string,bytes32)", u256(0x40), h256(account(0), h256::AlignRight), u256(name.length()), name) == encodeArgs());
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());
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index 29fe5b8d..fbab2404 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -471,19 +471,22 @@ BOOST_AUTO_TEST_CASE(add_owners)
{
deployWallet(200);
Address originalOwner = m_sender;
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x12)) == encodeArgs());
- BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x12)) == encodeArgs(true));
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs(true));
// now let the new owner add someone
- m_sender = Address(0x12);
+ sendEther(account(1), 10 * eth::ether);
+ m_sender = account(1);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x13)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x13)) == encodeArgs(true));
// and check that a non-owner cannot add a new owner
- m_sender = Address(0x50);
+ m_sender = account(0);
+ sendEther(account(2), 10 * eth::ether);
+ m_sender = account(2);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x20)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x20)) == encodeArgs(false));
// finally check that all the owners are there
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(originalOwner, h256::AlignRight)) == encodeArgs(true));
- BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x12)) == encodeArgs(true));
+ BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs(true));
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x13)) == encodeArgs(true));
}
@@ -548,22 +551,27 @@ BOOST_AUTO_TEST_CASE(initial_owners)
BOOST_AUTO_TEST_CASE(multisig_value_transfer)
{
deployWallet(200);
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x12)) == encodeArgs());
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x13)) == encodeArgs());
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x14)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(2), h256::AlignRight)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(3), h256::AlignRight)) == encodeArgs());
// 4 owners, set required to 3
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// check that balance is and stays zero at destination address
- h256 opHash("6244b4fa93f73e09db0ae52750095ca0364a76b72bc01723c97011fcb876cc9e");
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));
+ m_sender = account(0);
+ sendEther(account(1), 10 * eth::ether);
+ m_sender = account(1);
+ auto ophash = callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00);
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));
+ m_sender = account(0);
+ sendEther(account(2), 10 * eth::ether);
+ m_sender = account(2);
+ callContractFunction("confirm(bytes32)", ophash);
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));
+ m_sender = account(0);
+ sendEther(account(3), 10 * eth::ether);
+ m_sender = account(3);
+ callContractFunction("confirm(bytes32)", ophash);
// now it should go through
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 100);
}
@@ -571,9 +579,9 @@ BOOST_AUTO_TEST_CASE(multisig_value_transfer)
BOOST_AUTO_TEST_CASE(revoke_addOwner)
{
deployWallet();
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x12)) == encodeArgs());
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x13)) == encodeArgs());
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x14)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(2), h256::AlignRight)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(3), h256::AlignRight)) == encodeArgs());
// 4 owners, set required to 3
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// add a new owner
@@ -581,16 +589,22 @@ BOOST_AUTO_TEST_CASE(revoke_addOwner)
h256 opHash = sha3(FixedHash<4>(dev::sha3("addOwner(address)")).asBytes() + h256(0x33).asBytes());
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(false));
- m_sender = Address(0x12);
+ m_sender = account(0);
+ sendEther(account(1), 10 * eth::ether);
+ m_sender = account(1);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(false));
// revoke one confirmation
m_sender = deployer;
BOOST_REQUIRE(callContractFunction("revoke(bytes32)", opHash) == encodeArgs());
- m_sender = Address(0x13);
+ m_sender = account(0);
+ sendEther(account(2), 10 * eth::ether);
+ m_sender = account(2);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(false));
- m_sender = Address(0x14);
+ m_sender = account(0);
+ sendEther(account(3), 10 * eth::ether);
+ m_sender = account(3);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(true));
}
@@ -598,28 +612,35 @@ BOOST_AUTO_TEST_CASE(revoke_addOwner)
BOOST_AUTO_TEST_CASE(revoke_transaction)
{
deployWallet(200);
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x12)) == encodeArgs());
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x13)) == encodeArgs());
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x14)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(2), h256::AlignRight)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(3), h256::AlignRight)) == encodeArgs());
// 4 owners, set required to 3
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// create a transaction
Address deployer = m_sender;
- h256 opHash("6244b4fa93f73e09db0ae52750095ca0364a76b72bc01723c97011fcb876cc9e");
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));
+ m_sender = account(0);
+ sendEther(account(1), 10 * eth::ether);
+ m_sender = account(1);
+ auto opHash = callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00);
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));
+ m_sender = account(0);
+ sendEther(account(2), 10 * eth::ether);
+ m_sender = account(2);
+ callContractFunction("confirm(bytes32)", opHash);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
- m_sender = Address(0x12);
+ m_sender = account(0);
+ sendEther(account(1), 10 * eth::ether);
+ m_sender = account(1);
BOOST_REQUIRE(callContractFunction("revoke(bytes32)", opHash) == encodeArgs());
m_sender = deployer;
- BOOST_REQUIRE(callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00) == encodeArgs(opHash));
+ callContractFunction("confirm(bytes32)", opHash);
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));
+ m_sender = account(0);
+ sendEther(account(3), 10 * eth::ether);
+ m_sender = account(3);
+ callContractFunction("confirm(bytes32)", opHash);
// now it should go through
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 100);
}
@@ -630,29 +651,33 @@ BOOST_AUTO_TEST_CASE(daylimit)
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(0)));
BOOST_REQUIRE(callContractFunction("setDailyLimit(uint256)", h256(100)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(100)));
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x12)) == encodeArgs());
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x13)) == encodeArgs());
- BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x14)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(2), h256::AlignRight)) == encodeArgs());
+ BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(3), h256::AlignRight)) == encodeArgs());
// 4 owners, set required to 3
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// try to send tx over daylimit
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
- m_sender = Address(0x12);
+ sendEther(account(1), 10 * eth::ether);
+ m_sender = account(1);
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", h256(0x05), 150, 0x60, 0x00) !=
encodeArgs(u256(0))
);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
// try to send tx under daylimit by stranger
- m_sender = Address(0x77);
+ m_sender = account(0);
+ sendEther(account(4), 10 * eth::ether);
+ m_sender = account(4);
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", h256(0x05), 90, 0x60, 0x00) ==
encodeArgs(u256(0))
);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
// now send below limit by owner
- m_sender = Address(0x12);
+ m_sender = account(0);
+ sendEther(account(1), 10 * eth::ether);
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", h256(0x05), 90, 0x60, 0x00) ==
encodeArgs(u256(0))