Skip to content

Commit

Permalink
Do not use the precompile address 0x05 in the wallet tests (but a ran…
Browse files Browse the repository at this point in the history
…domized address)
  • Loading branch information
axic committed Oct 23, 2017
1 parent 3131830 commit dcbcd36
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions test/contracts/Wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,24 +559,24 @@ BOOST_AUTO_TEST_CASE(multisig_value_transfer)
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
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
Address destination = Address("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
m_sender = account(0);
sendEther(account(1), 10 * ether);
m_sender = account(1);
auto ophash = callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
auto ophash = callContractFunction("execute(address,uint256,bytes)", h256(destination, h256::AlignRight), 100, 0x60, 0x00);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
m_sender = account(0);
sendEther(account(2), 10 * ether);
m_sender = account(2);
callContractFunction("confirm(bytes32)", ophash);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
m_sender = account(0);
sendEther(account(3), 10 * ether);
m_sender = account(3);
callContractFunction("confirm(bytes32)", ophash);
// now it should go through
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 100);
BOOST_CHECK_EQUAL(balanceAt(destination), 100);
}

BOOST_AUTO_TEST_CASE(revoke_addOwner)
Expand Down Expand Up @@ -622,30 +622,31 @@ BOOST_AUTO_TEST_CASE(revoke_transaction)
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// create a transaction
Address deployer = m_sender;
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
Address destination = Address("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
m_sender = account(0);
sendEther(account(1), 10 * ether);
m_sender = account(1);
auto opHash = callContractFunction("execute(address,uint256,bytes)", h256(0x05), 100, 0x60, 0x00);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
auto opHash = callContractFunction("execute(address,uint256,bytes)", h256(destination, h256::AlignRight), 100, 0x60, 0x00);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
m_sender = account(0);
sendEther(account(2), 10 * ether);
m_sender = account(2);
callContractFunction("confirm(bytes32)", opHash);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
m_sender = account(0);
sendEther(account(1), 10 * ether);
m_sender = account(1);
BOOST_REQUIRE(callContractFunction("revoke(bytes32)", opHash) == encodeArgs());
m_sender = deployer;
callContractFunction("confirm(bytes32)", opHash);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
m_sender = account(0);
sendEther(account(3), 10 * ether);
m_sender = account(3);
callContractFunction("confirm(bytes32)", opHash);
// now it should go through
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 100);
BOOST_CHECK_EQUAL(balanceAt(destination), 100);
}

BOOST_AUTO_TEST_CASE(daylimit)
Expand All @@ -661,31 +662,32 @@ BOOST_AUTO_TEST_CASE(daylimit)
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());

// try to send tx over daylimit
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
Address destination = Address("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
sendEther(account(1), 10 * ether);
m_sender = account(1);
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", h256(0x05), 150, 0x60, 0x00) !=
callContractFunction("execute(address,uint256,bytes)", h256(destination, h256::AlignRight), 150, 0x60, 0x00) !=
encodeArgs(u256(0))
);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
// try to send tx under daylimit by stranger
m_sender = account(0);
sendEther(account(4), 10 * ether);
m_sender = account(4);
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", h256(0x05), 90, 0x60, 0x00) ==
callContractFunction("execute(address,uint256,bytes)", h256(destination, h256::AlignRight), 90, 0x60, 0x00) ==
encodeArgs(u256(0))
);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 0);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
// now send below limit by owner
m_sender = account(0);
sendEther(account(1), 10 * ether);
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", h256(0x05), 90, 0x60, 0x00) ==
callContractFunction("execute(address,uint256,bytes)", h256(destination, h256::AlignRight), 90, 0x60, 0x00) ==
encodeArgs(u256(0))
);
BOOST_CHECK_EQUAL(balanceAt(Address(0x05)), 90);
BOOST_CHECK_EQUAL(balanceAt(destination), 90);
}

BOOST_AUTO_TEST_CASE(daylimit_constructor)
Expand Down

0 comments on commit dcbcd36

Please sign in to comment.