Boolean stack implementation #18

Open
navelbuffle wants to merge 17 commits from boolean-stack into offchain-start
Showing only changes of commit 2e214f95d3 - Show all commits
+11 -11
View File
@@ -23,12 +23,12 @@ contract Push3IntAdapterTest is Test {
} }
/** /**
* @notice Test run1In1Out with a minimal code array. * @notice Test run1In1Out with a minimal code array.
* For example, we might do a program that just leaves its input unchanged * For example, we might do a program that just leaves its input unchanged
* (like a NOOP). * (like a NOOP).
*/ */
function test_run1In1Out_noop() public view { function test_run1In1Out_noop() public view {
bytes memory code = hex"03000100"; bytes memory code = hex"04000100";
int256 inputVal = 123; int256 inputVal = 123;
int256 result = adapter.run1In1Out(code, inputVal); int256 result = adapter.run1In1Out(code, inputVal);
@@ -41,21 +41,21 @@ contract Push3IntAdapterTest is Test {
* @notice Test run2In1Out. We'll push 5, 7, do an op that leaves 12. * @notice Test run2In1Out. We'll push 5, 7, do an op that leaves 12.
*/ */
function test_run2In1Out_plus() public view { function test_run2In1Out_plus() public view {
bytes memory code = hex"03000101"; bytes memory code = hex"04000105";
int256 in1 = 5; int256 in1 = 5;
int256 in2 = 7; int256 in2 = 7;
int256 result = adapter.run2In1Out(code, in1, in2); int256 result = adapter.run2In1Out(code, in1, in2);
assertEq(result, 12, "Expected 5 + 7 = 12"); assertEq(result, 12, "Expected 5 + 7 = 12");
} }
/** /**
* @notice Test run1In2Out. Push a constant to a stack with 1. * @notice Test run1In2Out. Push a constant to a stack with 1.
* For now, we do a placeholder code. * For now, we do a placeholder code.
*/ */
function test_run1In2Out() public view { function test_run1In2Out() public view {
bytes memory code = hex"0300050200000003"; bytes memory code = hex"0400050200000003";
int256 inVal = 42; int256 inVal = 42;
(int256 top, int256 secondTop) = adapter.run1In2Out(code, inVal); (int256 top, int256 secondTop) = adapter.run1In2Out(code, inVal);
@@ -65,12 +65,12 @@ contract Push3IntAdapterTest is Test {
} }
/** /**
* @notice Test run0InNOut. * @notice Test run0InNOut.
* We'll feed a code that pushes some constants, and see the final stack. * We'll feed a code that pushes some constants, and see the final stack.
*/ */
function test_run0InNOut() public view { function test_run0InNOut() public view {
bytes memory code = hex"03000A02000000030200000005"; bytes memory code = hex"04000A02000000030200000005";
int256[] memory stackResult = adapter.run0InNOut(code); int256[] memory stackResult = adapter.run0InNOut(code);