solidity/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol
Daniel Kirchner 44da8507b1 Change default EVM version to Shanghai.
Co-authored-by: Rodrigo Q. Saramago <rodrigoqsaramago@gmail.com>
2023-05-08 16:34:23 +02:00

21 lines
561 B
Solidity

// Tests transition between short and long encoding
contract c {
bytes data;
function test() public returns (uint256) {
for (uint8 i = 1; i < 40; i++) {
data.push(bytes1(i));
if (data.length != i) return 0x1000 + i;
if (data[data.length - 1] != bytes1(i)) return i;
}
for (uint8 i = 1; i < 40; i++)
if (data[i - 1] != bytes1(i)) return 0x1000000 + i;
return 0;
}
}
// ----
// test() -> 0
// gas irOptimized: 173252
// gas legacy: 215891
// gas legacyOptimized: 203615