mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Drop implicit alignment argument from FixedHash
This commit is contained in:
parent
725253551e
commit
2a41295d03
@ -61,7 +61,7 @@ public:
|
||||
explicit FixedHash() { m_data.fill(0); }
|
||||
|
||||
/// Construct from another hash, filling with zeroes or cropping as necessary.
|
||||
template <unsigned M> explicit FixedHash(FixedHash<M> const& _h, ConstructFromHashType _t = AlignLeft)
|
||||
template <unsigned M> explicit FixedHash(FixedHash<M> const& _h, ConstructFromHashType _t)
|
||||
{
|
||||
m_data.fill(0);
|
||||
unsigned c = std::min(M, N);
|
||||
|
@ -255,7 +255,7 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
|
||||
h160 createAddress(keccak256(
|
||||
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
||||
asBytes(to_string(sender.nonce++))
|
||||
));
|
||||
), h160::AlignLeft);
|
||||
message.destination = convertToEVMC(createAddress);
|
||||
code = evmc::bytes(message.input_data, message.input_data + message.input_size);
|
||||
}
|
||||
@ -266,7 +266,7 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
|
||||
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
||||
bytes(begin(message.create2_salt.bytes), end(message.create2_salt.bytes)) +
|
||||
keccak256(bytes(message.input_data, message.input_data + message.input_size)).asBytes()
|
||||
));
|
||||
), h160::AlignLeft);
|
||||
message.destination = convertToEVMC(createAddress);
|
||||
if (accounts.count(message.destination) && (
|
||||
accounts[message.destination].nonce > 0 ||
|
||||
|
@ -146,29 +146,30 @@ BOOST_AUTO_TEST_CASE(string_constructor_frombytes)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(converting_constructor)
|
||||
{
|
||||
// Truncation
|
||||
FixedHash<8> a = FixedHash<8>(FixedHash<12>("112233445566778899001122"));
|
||||
// Left-aligned truncation
|
||||
FixedHash<8> a = FixedHash<8>(FixedHash<12>("112233445566778899001122"), FixedHash<8>::AlignLeft);
|
||||
BOOST_CHECK_EQUAL(a.size, 8);
|
||||
BOOST_CHECK_EQUAL(a.hex(), "1122334455667788");
|
||||
|
||||
// Right-aligned truncation
|
||||
FixedHash<8> b = FixedHash<8>(FixedHash<12>("112233445566778899001122"), FixedHash<8>::AlignRight);
|
||||
BOOST_CHECK_EQUAL(b.size, 8);
|
||||
BOOST_CHECK_EQUAL(b.hex(), "5566778899001122");
|
||||
|
||||
// Left-aligned extension
|
||||
FixedHash<12> b = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::AlignLeft);
|
||||
BOOST_CHECK_EQUAL(b.size, 12);
|
||||
BOOST_CHECK_EQUAL(b.hex(), "112233445566778800000000");
|
||||
FixedHash<12> c = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::AlignLeft);
|
||||
BOOST_CHECK_EQUAL(c.size, 12);
|
||||
BOOST_CHECK_EQUAL(c.hex(), "112233445566778800000000");
|
||||
|
||||
// Right-aligned extension
|
||||
FixedHash<12> c = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::AlignRight);
|
||||
BOOST_CHECK_EQUAL(c.size, 12);
|
||||
BOOST_CHECK_EQUAL(c.hex(), "000000001122334455667788");
|
||||
|
||||
// Default setting
|
||||
FixedHash<12> d = FixedHash<12>(FixedHash<8>("1122334455667788"));
|
||||
BOOST_CHECK_EQUAL(d, b);
|
||||
FixedHash<12> d = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::AlignRight);
|
||||
BOOST_CHECK_EQUAL(d.size, 12);
|
||||
BOOST_CHECK_EQUAL(d.hex(), "000000001122334455667788");
|
||||
|
||||
// FailIfDifferent setting
|
||||
// TODO: Shouldn't this throw?
|
||||
FixedHash<12> e = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::FailIfDifferent);
|
||||
BOOST_CHECK_EQUAL(e, b);
|
||||
BOOST_CHECK_EQUAL(e, c);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(arith_constructor)
|
||||
|
@ -439,7 +439,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
|
||||
}
|
||||
else if (_fun == "getExternalCodeSize")
|
||||
// Generate "random" code length.
|
||||
return uint32_t(u256(keccak256(h256(readAddress(arg[0])))) & 0xfff);
|
||||
return uint32_t(u256(keccak256(h256(readAddress(arg[0]), h256::AlignLeft))) & 0xfff);
|
||||
else if (_fun == "getGasLeft")
|
||||
return 0x99;
|
||||
else if (_fun == "getBlockGasLimit")
|
||||
|
Loading…
Reference in New Issue
Block a user