diff options
Diffstat (limited to 'test/contracts')
-rw-r--r-- | test/contracts/AuctionRegistrar.cpp | 33 | ||||
-rw-r--r-- | test/contracts/FixedFeeRegistrar.cpp | 21 | ||||
-rw-r--r-- | test/contracts/LLL_ENS.cpp | 1 | ||||
-rw-r--r-- | test/contracts/LLL_ERC20.cpp | 5 | ||||
-rw-r--r-- | test/contracts/Wallet.cpp | 11 |
5 files changed, 40 insertions, 31 deletions
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp index f5abb83d..3d759aa0 100644 --- a/test/contracts/AuctionRegistrar.cpp +++ b/test/contracts/AuctionRegistrar.cpp @@ -43,20 +43,20 @@ static char const* registrarCode = R"DELIMITER( pragma solidity ^0.4.0; contract NameRegister { - function addr(string _name) constant returns (address o_owner); - function name(address _owner) constant returns (string o_name); + function addr(string _name) view returns (address o_owner); + function name(address _owner) view returns (string o_name); } contract Registrar is NameRegister { event Changed(string indexed name); event PrimaryChanged(string indexed name, address indexed addr); - function owner(string _name) constant returns (address o_owner); - function addr(string _name) constant returns (address o_address); - function subRegistrar(string _name) constant returns (address o_subRegistrar); - function content(string _name) constant returns (bytes32 o_content); + function owner(string _name) view returns (address o_owner); + function addr(string _name) view returns (address o_address); + function subRegistrar(string _name) view returns (address o_subRegistrar); + function content(string _name) view returns (bytes32 o_content); - function name(address _owner) constant returns (string o_name); + function name(address _owner) view returns (string o_name); } contract AuctionSystem { @@ -67,7 +67,7 @@ contract AuctionSystem { function onAuctionEnd(string _name) internal; function bid(string _name, address _bidder, uint _value) internal { - var auction = m_auctions[_name]; + Auction storage auction = m_auctions[_name]; if (auction.endDate > 0 && now > auction.endDate) { emit AuctionEnded(_name, auction.highestBidder); @@ -117,9 +117,9 @@ contract GlobalRegistrar is Registrar, AuctionSystem { } function onAuctionEnd(string _name) internal { - var auction = m_auctions[_name]; - var record = m_toRecord[_name]; - var previousOwner = record.owner; + Auction storage auction = m_auctions[_name]; + Record storage record = m_toRecord[_name]; + address previousOwner = record.owner; record.renewalDate = now + c_renewalInterval; record.owner = auction.highestBidder; emit Changed(_name); @@ -201,11 +201,11 @@ contract GlobalRegistrar is Registrar, AuctionSystem { return true; } - function owner(string _name) constant returns (address) { return m_toRecord[_name].owner; } - function addr(string _name) constant returns (address) { return m_toRecord[_name].primary; } - function subRegistrar(string _name) constant returns (address) { return m_toRecord[_name].subRegistrar; } - function content(string _name) constant returns (bytes32) { return m_toRecord[_name].content; } - function name(address _addr) constant returns (string o_name) { return m_toName[_addr]; } + function owner(string _name) view returns (address) { return m_toRecord[_name].owner; } + function addr(string _name) view returns (address) { return m_toRecord[_name].primary; } + function subRegistrar(string _name) view returns (address) { return m_toRecord[_name].subRegistrar; } + function content(string _name) view returns (bytes32) { return m_toRecord[_name].content; } + function name(address _addr) view returns (string o_name) { return m_toName[_addr]; } mapping (address => string) m_toName; mapping (string => Record) m_toRecord; @@ -223,6 +223,7 @@ protected: s_compiledRegistrar.reset(new bytes(compileContract(registrarCode, "GlobalRegistrar"))); sendMessage(*s_compiledRegistrar, true); + BOOST_REQUIRE(m_transactionSuccessful); BOOST_REQUIRE(!m_output.empty()); } diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp index 142f4144..87f801b0 100644 --- a/test/contracts/FixedFeeRegistrar.cpp +++ b/test/contracts/FixedFeeRegistrar.cpp @@ -58,10 +58,10 @@ pragma solidity ^0.4.0; contract Registrar { event Changed(string indexed name); - function owner(string _name) constant returns (address o_owner); - function addr(string _name) constant returns (address o_address); - function subRegistrar(string _name) constant returns (address o_subRegistrar); - function content(string _name) constant returns (bytes32 o_content); + function owner(string _name) view returns (address o_owner); + function addr(string _name) view returns (address o_address); + function subRegistrar(string _name) view returns (address o_subRegistrar); + function content(string _name) view returns (bytes32 o_content); } contract FixedFeeRegistrar is Registrar { @@ -104,20 +104,20 @@ contract FixedFeeRegistrar is Registrar { emit Changed(_name); } - function record(string _name) constant returns (address o_addr, address o_subRegistrar, bytes32 o_content, address o_owner) { + function record(string _name) view returns (address o_addr, address o_subRegistrar, bytes32 o_content, address o_owner) { Record rec = m_record(_name); o_addr = rec.addr; o_subRegistrar = rec.subRegistrar; o_content = rec.content; o_owner = rec.owner; } - function addr(string _name) constant returns (address) { return m_record(_name).addr; } - function subRegistrar(string _name) constant returns (address) { return m_record(_name).subRegistrar; } - function content(string _name) constant returns (bytes32) { return m_record(_name).content; } - function owner(string _name) constant returns (address) { return m_record(_name).owner; } + function addr(string _name) view returns (address) { return m_record(_name).addr; } + function subRegistrar(string _name) view returns (address) { return m_record(_name).subRegistrar; } + function content(string _name) view returns (bytes32) { return m_record(_name).content; } + function owner(string _name) view returns (address) { return m_record(_name).owner; } Record[2**253] m_recordData; - function m_record(string _name) constant internal returns (Record storage o_record) { + function m_record(string _name) view internal returns (Record storage o_record) { return m_recordData[uint(keccak256(bytes(_name))) / 8]; } uint constant c_fee = 69 ether; @@ -135,6 +135,7 @@ protected: s_compiledRegistrar.reset(new bytes(compileContract(registrarCode, "FixedFeeRegistrar"))); sendMessage(*s_compiledRegistrar, true); + BOOST_REQUIRE(m_transactionSuccessful); BOOST_REQUIRE(!m_output.empty()); } u256 const m_fee = u256("69000000000000000000"); diff --git a/test/contracts/LLL_ENS.cpp b/test/contracts/LLL_ENS.cpp index 028d58c8..3461c577 100644 --- a/test/contracts/LLL_ENS.cpp +++ b/test/contracts/LLL_ENS.cpp @@ -349,6 +349,7 @@ protected: BOOST_REQUIRE(errors.empty()); } sendMessage(*s_compiledEns, true); + BOOST_REQUIRE(m_transactionSuccessful); BOOST_REQUIRE(!m_output.empty()); } diff --git a/test/contracts/LLL_ERC20.cpp b/test/contracts/LLL_ERC20.cpp index 60b43e4f..89d1c4f0 100644 --- a/test/contracts/LLL_ERC20.cpp +++ b/test/contracts/LLL_ERC20.cpp @@ -400,6 +400,7 @@ protected: BOOST_REQUIRE(errors.empty()); } sendMessage(*s_compiledErc20, true); + BOOST_REQUIRE(m_transactionSuccessful); BOOST_REQUIRE(!m_output.empty()); } @@ -629,18 +630,22 @@ BOOST_AUTO_TEST_CASE(bad_data) // Correct data: transfer(address _to, 1). sendMessage((bytes)fromHex("a9059cbb") + (bytes)fromHex("000000000000000000000000123456789a123456789a123456789a123456789a") + encodeArgs(1), false, 0); + BOOST_CHECK(m_transactionSuccessful); BOOST_CHECK(m_output == SUCCESS); // Too little data (address is truncated by one byte). sendMessage((bytes)fromHex("a9059cbb") + (bytes)fromHex("000000000000000000000000123456789a123456789a123456789a12345678") + encodeArgs(1), false, 0); + BOOST_CHECK(!m_transactionSuccessful); BOOST_CHECK(m_output != SUCCESS); // Too much data (address is extended with a zero byte). sendMessage((bytes)fromHex("a9059cbb") + (bytes)fromHex("000000000000000000000000123456789a123456789a123456789a123456789a00") + encodeArgs(1), false, 0); + BOOST_CHECK(!m_transactionSuccessful); BOOST_CHECK(m_output != SUCCESS); // Invalid address (a bit above the 160th is set). sendMessage((bytes)fromHex("a9059cbb") + (bytes)fromHex("000000000000000000000100123456789a123456789a123456789a123456789a") + encodeArgs(1), false, 0); + BOOST_CHECK(!m_transactionSuccessful); BOOST_CHECK(m_output != SUCCESS); } diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp index 6328b518..fb104300 100644 --- a/test/contracts/Wallet.cpp +++ b/test/contracts/Wallet.cpp @@ -119,7 +119,7 @@ contract multiowned { // make sure they're an owner if (ownerIndex == 0) return; uint ownerIndexBit = 2**ownerIndex; - var pending = m_pending[_operation]; + PendingState pending = m_pending[_operation]; if (pending.ownersDone & ownerIndexBit > 0) { pending.yetNeeded++; pending.ownersDone -= ownerIndexBit; @@ -177,8 +177,8 @@ contract multiowned { return m_ownerIndex[uint(_addr)] > 0; } - function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) { - var pending = m_pending[_operation]; + function hasConfirmed(bytes32 _operation, address _owner) view returns (bool) { + PendingState pending = m_pending[_operation]; uint ownerIndex = m_ownerIndex[uint(_owner)]; // make sure they're an owner @@ -201,7 +201,7 @@ contract multiowned { // make sure they're an owner if (ownerIndex == 0) return; - var pending = m_pending[_operation]; + PendingState pending = m_pending[_operation]; // if we're not yet working on this operation, switch over and reset the confirmation status. if (pending.yetNeeded == 0) { // reset count of confirmations needed. @@ -319,7 +319,7 @@ contract daylimit is multiowned { return false; } // determines today's index. - function today() private constant returns (uint) { return now / 1 days; } + function today() private view returns (uint) { return now / 1 days; } // FIELDS @@ -451,6 +451,7 @@ protected: bytes args = encodeArgs(u256(0x60), _required, _dailyLimit, u256(_owners.size()), _owners); sendMessage(*s_compiledWallet + args, true, _value); + BOOST_REQUIRE(m_transactionSuccessful); BOOST_REQUIRE(!m_output.empty()); } }; |