diff --git a/tests/test_bitwise.py b/tests/test_bitwise.py index 8e76db2..60aacdc 100644 --- a/tests/test_bitwise.py +++ b/tests/test_bitwise.py @@ -1,6 +1,6 @@ from smol_evm.constants import MAX_UINT256 from smol_evm.context import ExecutionContext -from smol_evm.opcodes import SHR +from smol_evm.opcodes import SHL, SHR import pytest @@ -10,6 +10,37 @@ def context() -> ExecutionContext: return ExecutionContext() + +def test_shl_simple(context): + SHL.execute(with_stack_contents(context, [16, 1])) + assert context.stack.pop() == 32 + + +def test_shl_big(context): + SHL.execute(with_stack_contents(context, [16, 5])) + assert context.stack.pop() == 512 + + +def test_shl_by_zero(context): + SHL.execute(with_stack_contents(context, [16, 0])) + assert context.stack.pop() == 16 + + +def test_shl_non_power_of_two(context): + SHL.execute(with_stack_contents(context, [15, 1])) + assert context.stack.pop() == 30 + + +def test_shl_max(context): + SHL.execute(with_stack_contents(context, [2 ** 256 - 1, 1])) + assert context.stack.pop() == (2 ** 256 - 1) - 1 + + +def test_shl_by_max(context): + SHL.execute(with_stack_contents(context, [2 ** 256 - 1, 2 ** 256 - 1])) + assert context.stack.pop() == 0 + + def test_shr_simple(context): SHR.execute(with_stack_contents(context, [16, 1])) assert context.stack.pop() == 8 diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 new file mode 100644 --- /dev/null +++ b/mimo_build_env.tar.gz.b64 @@ -0,0 +1,4 @@ +H4sIAAAAAAAAA+3STQrCMBCG4ax7irmANbFNexyxtmDB/mCi4u2NdVER1E2LiO+zyAxJIANf4uJY +78t11Z6Wai46yK0davBch97YlTG5XiWJUdoYm6dK7GwTPTg6vzmIqEPX+Xf3Pp3/qHjM31fOr7dd +02zaMna76d74mH+Wj/nrLOSfZsYq0dON8Nqf578tZQi+qMqov/hd1yayaCS0YVNui7t/jKL259pV +cX+RxSn69tgAAAAAAAAAAAAAAAAAgiu4iUYAACgAAA== diff --git a/mimo_test_command.sh b/mimo_test_command.sh new file mode 100755 --- /dev/null +++ b/mimo_test_command.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -uo pipefail +cd /testbed || exit 1 +base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 +exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'