From d8cf8e98bda5cff6a7ca90bd907e2d71666fa989 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 9 Dec 2019 20:22:31 +0000 Subject: [PATCH] Add basic test cases for most of EVM->Ewasm translator --- test/libyul/ewasmTranslationTests/address.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/balance.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/blockhash.yul | 7 +++++++ .../ewasmTranslationTests/calldatacopy.yul | 8 ++++++++ .../ewasmTranslationTests/calldataload.yul | 7 +++++++ .../ewasmTranslationTests/calldatasize.yul | 7 +++++++ test/libyul/ewasmTranslationTests/caller.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/callvalue.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/codecopy.yul | 11 +++++++++++ test/libyul/ewasmTranslationTests/codesize.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/coinbase.yul | 7 +++++++ test/libyul/ewasmTranslationTests/difficulty.yul | 9 +++++++++ .../libyul/ewasmTranslationTests/extcodecopy.yul | 9 +++++++++ .../libyul/ewasmTranslationTests/extcodesize.yul | 8 ++++++++ test/libyul/ewasmTranslationTests/gas.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/gaslimit.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/gasprice.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/invalid.yul | 13 +++++++++++++ test/libyul/ewasmTranslationTests/iszero.yul | 14 ++++++++++++++ test/libyul/ewasmTranslationTests/keccak256.yul | 8 ++++++++ test/libyul/ewasmTranslationTests/log0.yul | 7 +++++++ test/libyul/ewasmTranslationTests/log1.yul | 7 +++++++ test/libyul/ewasmTranslationTests/log2.yul | 7 +++++++ test/libyul/ewasmTranslationTests/log3.yul | 7 +++++++ test/libyul/ewasmTranslationTests/log4.yul | 7 +++++++ test/libyul/ewasmTranslationTests/msize.yul | 11 +++++++++++ test/libyul/ewasmTranslationTests/mstore8.yul | 14 ++++++++++++++ test/libyul/ewasmTranslationTests/number.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/origin.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/pc.yul | 7 +++++++ test/libyul/ewasmTranslationTests/return.yul | 11 +++++++++++ .../ewasmTranslationTests/returndatacopy.yul | 10 ++++++++++ .../ewasmTranslationTests/returndatasize.yul | 9 +++++++++ test/libyul/ewasmTranslationTests/revert.yul | 13 +++++++++++++ .../ewasmTranslationTests/selfdestruct.yul | 10 ++++++++++ .../{shl.yul => shifts.yul} | 0 .../ewasmTranslationTests/simple_sload.yul | 16 ++++++++++++++++ test/libyul/ewasmTranslationTests/smoke_call.yul | 8 ++++++++ .../ewasmTranslationTests/smoke_callcode.yul | 8 ++++++++ .../ewasmTranslationTests/smoke_create.yul | 11 +++++++++++ .../ewasmTranslationTests/smoke_delegatecall.yul | 8 ++++++++ .../ewasmTranslationTests/smoke_staticcall.yul | 10 ++++++++++ test/libyul/ewasmTranslationTests/timestamp.yul | 9 +++++++++ 43 files changed, 388 insertions(+) create mode 100644 test/libyul/ewasmTranslationTests/address.yul create mode 100644 test/libyul/ewasmTranslationTests/balance.yul create mode 100644 test/libyul/ewasmTranslationTests/blockhash.yul create mode 100644 test/libyul/ewasmTranslationTests/calldatacopy.yul create mode 100644 test/libyul/ewasmTranslationTests/calldataload.yul create mode 100644 test/libyul/ewasmTranslationTests/calldatasize.yul create mode 100644 test/libyul/ewasmTranslationTests/caller.yul create mode 100644 test/libyul/ewasmTranslationTests/callvalue.yul create mode 100644 test/libyul/ewasmTranslationTests/codecopy.yul create mode 100644 test/libyul/ewasmTranslationTests/codesize.yul create mode 100644 test/libyul/ewasmTranslationTests/coinbase.yul create mode 100644 test/libyul/ewasmTranslationTests/difficulty.yul create mode 100644 test/libyul/ewasmTranslationTests/extcodecopy.yul create mode 100644 test/libyul/ewasmTranslationTests/extcodesize.yul create mode 100644 test/libyul/ewasmTranslationTests/gas.yul create mode 100644 test/libyul/ewasmTranslationTests/gaslimit.yul create mode 100644 test/libyul/ewasmTranslationTests/gasprice.yul create mode 100644 test/libyul/ewasmTranslationTests/invalid.yul create mode 100644 test/libyul/ewasmTranslationTests/iszero.yul create mode 100644 test/libyul/ewasmTranslationTests/keccak256.yul create mode 100644 test/libyul/ewasmTranslationTests/log0.yul create mode 100644 test/libyul/ewasmTranslationTests/log1.yul create mode 100644 test/libyul/ewasmTranslationTests/log2.yul create mode 100644 test/libyul/ewasmTranslationTests/log3.yul create mode 100644 test/libyul/ewasmTranslationTests/log4.yul create mode 100644 test/libyul/ewasmTranslationTests/msize.yul create mode 100644 test/libyul/ewasmTranslationTests/mstore8.yul create mode 100644 test/libyul/ewasmTranslationTests/number.yul create mode 100644 test/libyul/ewasmTranslationTests/origin.yul create mode 100644 test/libyul/ewasmTranslationTests/pc.yul create mode 100644 test/libyul/ewasmTranslationTests/return.yul create mode 100644 test/libyul/ewasmTranslationTests/returndatacopy.yul create mode 100644 test/libyul/ewasmTranslationTests/returndatasize.yul create mode 100644 test/libyul/ewasmTranslationTests/revert.yul create mode 100644 test/libyul/ewasmTranslationTests/selfdestruct.yul rename test/libyul/ewasmTranslationTests/{shl.yul => shifts.yul} (100%) create mode 100644 test/libyul/ewasmTranslationTests/simple_sload.yul create mode 100644 test/libyul/ewasmTranslationTests/smoke_call.yul create mode 100644 test/libyul/ewasmTranslationTests/smoke_callcode.yul create mode 100644 test/libyul/ewasmTranslationTests/smoke_create.yul create mode 100644 test/libyul/ewasmTranslationTests/smoke_delegatecall.yul create mode 100644 test/libyul/ewasmTranslationTests/smoke_staticcall.yul create mode 100644 test/libyul/ewasmTranslationTests/timestamp.yul diff --git a/test/libyul/ewasmTranslationTests/address.yul b/test/libyul/ewasmTranslationTests/address.yul new file mode 100644 index 000000000..405e8c09b --- /dev/null +++ b/test/libyul/ewasmTranslationTests/address.yul @@ -0,0 +1,9 @@ +{ + sstore(0, address()) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000000000000011111111000000000000000000000000 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000011111111000000000000000000000000 diff --git a/test/libyul/ewasmTranslationTests/balance.yul b/test/libyul/ewasmTranslationTests/balance.yul new file mode 100644 index 000000000..d9b4a8f54 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/balance.yul @@ -0,0 +1,9 @@ +{ + sstore(0, balance(address())) + sstore(1, balance(0)) +} +// ---- +// Trace: +// Memory dump: +// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/blockhash.yul b/test/libyul/ewasmTranslationTests/blockhash.yul new file mode 100644 index 000000000..4eb9b2954 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/blockhash.yul @@ -0,0 +1,7 @@ +{ + sstore(0, blockhash(1)) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/calldatacopy.yul b/test/libyul/ewasmTranslationTests/calldatacopy.yul new file mode 100644 index 000000000..0d7d57af0 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/calldatacopy.yul @@ -0,0 +1,8 @@ +{ + calldatacopy(0, 0, 32) + sstore(0, mload(0)) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/calldataload.yul b/test/libyul/ewasmTranslationTests/calldataload.yul new file mode 100644 index 000000000..f0b4008f6 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/calldataload.yul @@ -0,0 +1,7 @@ +{ + sstore(0, calldataload(0)) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/calldatasize.yul b/test/libyul/ewasmTranslationTests/calldatasize.yul new file mode 100644 index 000000000..229f6b461 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/calldatasize.yul @@ -0,0 +1,7 @@ +{ + sstore(0, calldatasize()) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/caller.yul b/test/libyul/ewasmTranslationTests/caller.yul new file mode 100644 index 000000000..8da3ba23d --- /dev/null +++ b/test/libyul/ewasmTranslationTests/caller.yul @@ -0,0 +1,9 @@ +{ + sstore(0, caller()) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000000000000044444444000000000000000000000000 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000044444444000000000000000000000000 diff --git a/test/libyul/ewasmTranslationTests/callvalue.yul b/test/libyul/ewasmTranslationTests/callvalue.yul new file mode 100644 index 000000000..cf9104f7a --- /dev/null +++ b/test/libyul/ewasmTranslationTests/callvalue.yul @@ -0,0 +1,9 @@ +{ + sstore(0, callvalue()) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000005555555500000000000000000000000000000000 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000005555555500000000000000000000000000000000 diff --git a/test/libyul/ewasmTranslationTests/codecopy.yul b/test/libyul/ewasmTranslationTests/codecopy.yul new file mode 100644 index 000000000..5b980c6b1 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/codecopy.yul @@ -0,0 +1,11 @@ +{ + codecopy(0x100, 0, codesize()) + sstore(0, mload(0x100)) +} +// ---- +// Trace: +// Memory dump: +// 20: 636f6465636f6465636f6465636f6465636f6465000000000000000000000000 +// 140: 636f6465636f6465636f6465636f6465636f6465000000000000000000000000 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 636f6465636f6465636f6465636f6465636f6465000000000000000000000000 diff --git a/test/libyul/ewasmTranslationTests/codesize.yul b/test/libyul/ewasmTranslationTests/codesize.yul new file mode 100644 index 000000000..ae96335fa --- /dev/null +++ b/test/libyul/ewasmTranslationTests/codesize.yul @@ -0,0 +1,9 @@ +{ + sstore(0, codesize()) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000000000000000000000000000000000000000000014 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000014 diff --git a/test/libyul/ewasmTranslationTests/coinbase.yul b/test/libyul/ewasmTranslationTests/coinbase.yul new file mode 100644 index 000000000..b63bd7bef --- /dev/null +++ b/test/libyul/ewasmTranslationTests/coinbase.yul @@ -0,0 +1,7 @@ +{ + sstore(0, coinbase()) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/difficulty.yul b/test/libyul/ewasmTranslationTests/difficulty.yul new file mode 100644 index 000000000..c467d51a7 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/difficulty.yul @@ -0,0 +1,9 @@ +{ + sstore(0, difficulty()) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000000000000000000000000000000000000009999999 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000009999999 diff --git a/test/libyul/ewasmTranslationTests/extcodecopy.yul b/test/libyul/ewasmTranslationTests/extcodecopy.yul new file mode 100644 index 000000000..dde32334c --- /dev/null +++ b/test/libyul/ewasmTranslationTests/extcodecopy.yul @@ -0,0 +1,9 @@ +{ + extcodecopy(address(), 0x100, 0, extcodesize(address())) + sstore(0, mload(0x100)) +} +// ---- +// Trace: +// Memory dump: +// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/extcodesize.yul b/test/libyul/ewasmTranslationTests/extcodesize.yul new file mode 100644 index 000000000..9c94d5990 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/extcodesize.yul @@ -0,0 +1,8 @@ +{ + sstore(0, extcodesize(address())) +} +// ---- +// Trace: +// Memory dump: +// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/gas.yul b/test/libyul/ewasmTranslationTests/gas.yul new file mode 100644 index 000000000..ef7125b26 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/gas.yul @@ -0,0 +1,9 @@ +{ + sstore(0, gas()) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000000000000000000000000000000000000000000099 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000099 diff --git a/test/libyul/ewasmTranslationTests/gaslimit.yul b/test/libyul/ewasmTranslationTests/gaslimit.yul new file mode 100644 index 000000000..d1d0cc2a8 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/gaslimit.yul @@ -0,0 +1,9 @@ +{ + sstore(0, gaslimit()) +} +// ---- +// Trace: +// Memory dump: +// 20: 00000000000000000000000000000000000000000000000000000000003d0900 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 00000000000000000000000000000000000000000000000000000000003d0900 diff --git a/test/libyul/ewasmTranslationTests/gasprice.yul b/test/libyul/ewasmTranslationTests/gasprice.yul new file mode 100644 index 000000000..97334e442 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/gasprice.yul @@ -0,0 +1,9 @@ +{ + sstore(0, gasprice()) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000006666666600000000000000000000000000000000 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000006666666600000000000000000000000000000000 diff --git a/test/libyul/ewasmTranslationTests/invalid.yul b/test/libyul/ewasmTranslationTests/invalid.yul new file mode 100644 index 000000000..229a609cd --- /dev/null +++ b/test/libyul/ewasmTranslationTests/invalid.yul @@ -0,0 +1,13 @@ +{ + sstore(0, 0x1234) + mstore(1, 0) + invalid() + sstore(0, 0x5678) + mstore(1, 0xff) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000000000000000000000000000000000000000001234 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000001234 diff --git a/test/libyul/ewasmTranslationTests/iszero.yul b/test/libyul/ewasmTranslationTests/iszero.yul new file mode 100644 index 000000000..5175e2245 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/iszero.yul @@ -0,0 +1,14 @@ +{ + let x := 0 + let y := 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20 + let z := 0x0000000000000000000111111111111111111111100000000000000000000000 + sstore(0, iszero(x)) + sstore(1, iszero(y)) + sstore(2, iszero(z)) +} +// ---- +// Trace: +// Memory dump: +// 0: 0000000000000000000000000000000000000000000000000000000000000002 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000001 diff --git a/test/libyul/ewasmTranslationTests/keccak256.yul b/test/libyul/ewasmTranslationTests/keccak256.yul new file mode 100644 index 000000000..916b1bfa1 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/keccak256.yul @@ -0,0 +1,8 @@ +{ + sstore(0, keccak256(0, 0)) + sstore(0, keccak256(0, 0x20)) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/log0.yul b/test/libyul/ewasmTranslationTests/log0.yul new file mode 100644 index 000000000..e940e899e --- /dev/null +++ b/test/libyul/ewasmTranslationTests/log0.yul @@ -0,0 +1,7 @@ +{ + log0(0x20, 0x40) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/log1.yul b/test/libyul/ewasmTranslationTests/log1.yul new file mode 100644 index 000000000..4f3c3a9d4 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/log1.yul @@ -0,0 +1,7 @@ +{ + log1(0x20, 0x40, 0x60) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/log2.yul b/test/libyul/ewasmTranslationTests/log2.yul new file mode 100644 index 000000000..f596bb97a --- /dev/null +++ b/test/libyul/ewasmTranslationTests/log2.yul @@ -0,0 +1,7 @@ +{ + log2(0x20, 0x40, 0x60, 0x80) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/log3.yul b/test/libyul/ewasmTranslationTests/log3.yul new file mode 100644 index 000000000..54d8dc28d --- /dev/null +++ b/test/libyul/ewasmTranslationTests/log3.yul @@ -0,0 +1,7 @@ +{ + log3(0x20, 0x40, 0x60, 0x80, 0xa0) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/log4.yul b/test/libyul/ewasmTranslationTests/log4.yul new file mode 100644 index 000000000..4a696e611 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/log4.yul @@ -0,0 +1,7 @@ +{ + log4(0x20, 0x40, 0x60, 0x80, 0xa0, 0xb0) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/msize.yul b/test/libyul/ewasmTranslationTests/msize.yul new file mode 100644 index 000000000..2fd0983f6 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/msize.yul @@ -0,0 +1,11 @@ +{ + sstore(0, msize()) + mstore(0x20, 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20) + mstore(0x40, mload(0x20)) + sstore(1, mload(0x40)) + sstore(2, msize()) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/mstore8.yul b/test/libyul/ewasmTranslationTests/mstore8.yul new file mode 100644 index 000000000..566638c68 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/mstore8.yul @@ -0,0 +1,14 @@ +{ + mstore(0x30, not(0)) + mstore8(0x20, 0xaa) + mstore8(0x25, 0xbbbb) + mstore8(0x26, 0xcc) + mstore8(0x3b, 0x11) + sstore(0, mload(0x20)) +} +// ---- +// Trace: +// Memory dump: +// 60: 00000000000000000000000000000000ffffffffffffffffffffffffffffffff +// 80: ffffffffffffffffffffffffffffffff00000000000000000000000000000000 +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/number.yul b/test/libyul/ewasmTranslationTests/number.yul new file mode 100644 index 000000000..83250247a --- /dev/null +++ b/test/libyul/ewasmTranslationTests/number.yul @@ -0,0 +1,9 @@ +{ + sstore(0, number()) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000000000000000000000000000000000000000000400 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000400 diff --git a/test/libyul/ewasmTranslationTests/origin.yul b/test/libyul/ewasmTranslationTests/origin.yul new file mode 100644 index 000000000..95523283c --- /dev/null +++ b/test/libyul/ewasmTranslationTests/origin.yul @@ -0,0 +1,9 @@ +{ + sstore(0, origin()) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000000000000033333333000000000000000000000000 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000033333333000000000000000000000000 diff --git a/test/libyul/ewasmTranslationTests/pc.yul b/test/libyul/ewasmTranslationTests/pc.yul new file mode 100644 index 000000000..4d88bc974 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/pc.yul @@ -0,0 +1,7 @@ +{ + sstore(0, pc()) +} +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/return.yul b/test/libyul/ewasmTranslationTests/return.yul new file mode 100644 index 000000000..bb8b14170 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/return.yul @@ -0,0 +1,11 @@ +{ + mstore(0x20, 0x1234556677889900aa) + return(0x20, 30) + invalid() +} +// ---- +// Trace: +// RETURN() [000000000000000000000000000000000000000000000012345566778899] +// Memory dump: +// 60: 00000000000000000000000000000000000000000000001234556677889900aa +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/returndatacopy.yul b/test/libyul/ewasmTranslationTests/returndatacopy.yul new file mode 100644 index 000000000..c90b16f13 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/returndatacopy.yul @@ -0,0 +1,10 @@ +{ + returndatacopy(0x100, 0, returndatasize()) + sstore(0, mload(0x100)) +} +// ==== +// EVMVersion: >=byzantium +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/returndatasize.yul b/test/libyul/ewasmTranslationTests/returndatasize.yul new file mode 100644 index 000000000..b6aea851d --- /dev/null +++ b/test/libyul/ewasmTranslationTests/returndatasize.yul @@ -0,0 +1,9 @@ +{ + sstore(0, returndatasize()) +} +// ==== +// EVMVersion: >=byzantium +// ---- +// Trace: +// Memory dump: +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/revert.yul b/test/libyul/ewasmTranslationTests/revert.yul new file mode 100644 index 000000000..fbb5fc272 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/revert.yul @@ -0,0 +1,13 @@ +{ + mstore(0x20, 0x1234556677889900aa) + revert(0x20, 30) + invalid() +} +// ==== +// EVMVersion: >=byzantium +// ---- +// Trace: +// REVERT() [000000000000000000000000000000000000000000000012345566778899] +// Memory dump: +// 60: 00000000000000000000000000000000000000000000001234556677889900aa +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/selfdestruct.yul b/test/libyul/ewasmTranslationTests/selfdestruct.yul new file mode 100644 index 000000000..07cf6170e --- /dev/null +++ b/test/libyul/ewasmTranslationTests/selfdestruct.yul @@ -0,0 +1,10 @@ +{ + selfdestruct(not(0)) + invalid() +} +// ---- +// Trace: +// SELFDESTRUCT() +// Memory dump: +// 40: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/shl.yul b/test/libyul/ewasmTranslationTests/shifts.yul similarity index 100% rename from test/libyul/ewasmTranslationTests/shl.yul rename to test/libyul/ewasmTranslationTests/shifts.yul diff --git a/test/libyul/ewasmTranslationTests/simple_sload.yul b/test/libyul/ewasmTranslationTests/simple_sload.yul new file mode 100644 index 000000000..6d4131a99 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/simple_sload.yul @@ -0,0 +1,16 @@ +{ + sstore(1, 7) + sstore(2, sub(0, 1)) + sstore(3, sload(1)) + sstore(4, sload(2)) +} +// ---- +// Trace: +// Memory dump: +// 0: 0000000000000000000000000000000000000000000000000000000000000004 +// 20: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000001: 0000000000000000000000000000000000000000000000000000000000000007 +// 0000000000000000000000000000000000000000000000000000000000000002: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +// 0000000000000000000000000000000000000000000000000000000000000003: 0000000000000000000000000000000000000000000000000000000000000007 +// 0000000000000000000000000000000000000000000000000000000000000004: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/test/libyul/ewasmTranslationTests/smoke_call.yul b/test/libyul/ewasmTranslationTests/smoke_call.yul new file mode 100644 index 000000000..2e33f8615 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/smoke_call.yul @@ -0,0 +1,8 @@ +{ + sstore(0, call(gas(), address(), 42, 0, 0x20, 0x20, 0x20)) +} +// ---- +// Trace: +// Memory dump: +// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/smoke_callcode.yul b/test/libyul/ewasmTranslationTests/smoke_callcode.yul new file mode 100644 index 000000000..f8b51d8df --- /dev/null +++ b/test/libyul/ewasmTranslationTests/smoke_callcode.yul @@ -0,0 +1,8 @@ +{ + sstore(0, callcode(gas(), address(), 42, 0, 0x20, 0x20, 0x20)) +} +// ---- +// Trace: +// Memory dump: +// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/smoke_create.yul b/test/libyul/ewasmTranslationTests/smoke_create.yul new file mode 100644 index 000000000..bfc29b2c0 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/smoke_create.yul @@ -0,0 +1,11 @@ +{ + let size := codesize() + codecopy(0, 0, size) + sstore(0, create(42, 0, size)) +} +// ---- +// Trace: +// Memory dump: +// 0: 0000000000000000000000000000000000000000000000000000000000000014 +// 40: 636f6465636f6465636f6465636f6465636f6465000000000000000000000000 +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/smoke_delegatecall.yul b/test/libyul/ewasmTranslationTests/smoke_delegatecall.yul new file mode 100644 index 000000000..b79232f7f --- /dev/null +++ b/test/libyul/ewasmTranslationTests/smoke_delegatecall.yul @@ -0,0 +1,8 @@ +{ + sstore(0, delegatecall(gas(), address(), 0, 0x20, 0x20, 0x20)) +} +// ---- +// Trace: +// Memory dump: +// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/smoke_staticcall.yul b/test/libyul/ewasmTranslationTests/smoke_staticcall.yul new file mode 100644 index 000000000..207ef3eeb --- /dev/null +++ b/test/libyul/ewasmTranslationTests/smoke_staticcall.yul @@ -0,0 +1,10 @@ +{ + sstore(0, staticcall(gas(), address(), 0, 0x20, 0x20, 0x20)) +} +// ==== +// EVMVersion: >=byzantium +// ---- +// Trace: +// Memory dump: +// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// Storage dump: diff --git a/test/libyul/ewasmTranslationTests/timestamp.yul b/test/libyul/ewasmTranslationTests/timestamp.yul new file mode 100644 index 000000000..9982590df --- /dev/null +++ b/test/libyul/ewasmTranslationTests/timestamp.yul @@ -0,0 +1,9 @@ +{ + sstore(0, timestamp()) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000000000000000000000000000000000000088888888 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000088888888