diff --git a/test/abstract/FlowTest.sol b/test/abstract/FlowTest.sol index ee8d39a3..392b308c 100644 --- a/test/abstract/FlowTest.sol +++ b/test/abstract/FlowTest.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.25; import {Vm} from "forge-std/Test.sol"; -import {FlowUtilsAbstractTest} from "test/abstract/FlowUtilsAbstractTest.sol"; +import {FlowTransferOperation} from "test/abstract/FlowTransferOperation.sol"; import {InterpreterMockTest} from "test/abstract/InterpreterMockTest.sol"; import {EvaluableConfigV3} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; @@ -16,7 +16,7 @@ import {Flow} from "../../src/concrete/Flow.sol"; import {LibUint256Matrix} from "rain.solmem/lib/LibUint256Matrix.sol"; import {LibUint256Array} from "rain.solmem/lib/LibUint256Array.sol"; -abstract contract FlowTest is FlowUtilsAbstractTest, InterpreterMockTest { +abstract contract FlowTest is FlowTransferOperation, InterpreterMockTest { using LibLogHelper for Vm.Log[]; using LibStackGeneration for uint256; using Address for address; diff --git a/test/src/concrete/Flow.construction.t.sol b/test/src/concrete/Flow.construction.t.sol index 099e270d..e210f957 100644 --- a/test/src/concrete/Flow.construction.t.sol +++ b/test/src/concrete/Flow.construction.t.sol @@ -8,6 +8,7 @@ import {EvaluableConfigV3} from "rain.interpreter.interface/interface/IInterpret import {FlowTest} from "test/abstract/FlowTest.sol"; import {EmptyFlowConfig, InsufficientFlowOutputs, UnsupportedFlowInputs} from "../../../src/error/ErrFlow.sol"; import {MIN_FLOW_SENTINELS} from "../../../src/interface/IFlowV5.sol"; +import {LibLogHelper} from "test/lib/LibLogHelper.sol"; contract FlowConstructionTest is FlowTest { function testFlowConstructionEmptyConfigReverts() external { @@ -94,7 +95,7 @@ contract FlowConstructionTest is FlowTest { Vm.Log[] memory logs = vm.getRecordedLogs(); bytes32 eventSignature = keccak256("Initialize(address,(address,bytes,uint256[])[])"); - Vm.Log memory concreteEvent = findEvent(logs, eventSignature); + Vm.Log memory concreteEvent = LibLogHelper.findEvent(logs, eventSignature); (address sender, EvaluableConfigV3[] memory config) = abi.decode(concreteEvent.data, (address, EvaluableConfigV3[])); diff --git a/test/src/concrete/Flow.context.t.sol b/test/src/concrete/Flow.context.t.sol index 66727b6b..5f164223 100644 --- a/test/src/concrete/Flow.context.t.sol +++ b/test/src/concrete/Flow.context.t.sol @@ -3,12 +3,14 @@ pragma solidity =0.8.25; import {FlowTest} from "test/abstract/FlowTest.sol"; -import {IFlowV5} from "../../../src/interface/IFlowV5.sol"; +import {IFlowV5, RAIN_FLOW_SENTINEL} from "../../../src/interface/IFlowV5.sol"; +import {Sentinel} from "rain.solmem/lib/LibStackSentinel.sol"; import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; import {FLOW_MAX_OUTPUTS, FLOW_ENTRYPOINT} from "../../../src/concrete/Flow.sol"; import {LibEncodedDispatch} from "rain.interpreter.interface/lib/caller/LibEncodedDispatch.sol"; import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import {LibContextWrapper} from "test/lib/LibContextWrapper.sol"; +import {LibStackGeneration} from "test/lib/LibStackGeneration.sol"; contract FlowContextTest is FlowTest { /** @@ -26,7 +28,8 @@ contract FlowContextTest is FlowTest { LibContextWrapper.buildAndSetContext(callerContext, signedContext, address(alice), address(flow)); { - uint256[] memory stack = generateFlowStack(transferEmpty()); + uint256[] memory stack = + LibStackGeneration.generateFlowStack(Sentinel.unwrap(RAIN_FLOW_SENTINEL), transferEmpty()); interpreterEval2MockCall(stack, new uint256[](0)); diff --git a/test/src/concrete/Flow.expression.t.sol b/test/src/concrete/Flow.expression.t.sol index 15b7522b..904ab4e5 100644 --- a/test/src/concrete/Flow.expression.t.sol +++ b/test/src/concrete/Flow.expression.t.sol @@ -12,6 +12,7 @@ import {LibUint256Matrix} from "rain.solmem/lib/LibUint256Matrix.sol"; import {LibContextWrapper} from "test/lib/LibContextWrapper.sol"; import {IInterpreterCallerV2} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import {SignContextLib} from "test/lib/SignContextLib.sol"; +import {LibLogHelper} from "test/lib/LibLogHelper.sol"; contract FlowExpressionTest is FlowTest, IInterpreterCallerV2 { using SignContextLib for Vm; @@ -74,7 +75,7 @@ contract FlowExpressionTest is FlowTest, IInterpreterCallerV2 { ); Vm.Log[] memory logs = vm.getRecordedLogs(); - Vm.Log memory log = findEvent(logs, keccak256("Context(address,uint256[][])")); + Vm.Log memory log = LibLogHelper.findEvent(logs, keccak256("Context(address,uint256[][])")); (address sender, uint256[][] memory buildContextOutput) = abi.decode(log.data, (address, uint256[][])); assertEq(sender, address(this), "wrong sender"); diff --git a/test/src/concrete/Flow.preview.t.sol b/test/src/concrete/Flow.preview.t.sol index 6e634415..856e749b 100644 --- a/test/src/concrete/Flow.preview.t.sol +++ b/test/src/concrete/Flow.preview.t.sol @@ -15,6 +15,7 @@ import { } from "../../../src/interface/IFlowV5.sol"; import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; import {LibEvaluable} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; +import {LibStackGeneration} from "test/lib/LibStackGeneration.sol"; contract FlowPreviewTest is FlowTest { using LibEvaluable for EvaluableV2; @@ -179,7 +180,7 @@ contract FlowPreviewTest is FlowTest { FlowTransferV1 memory flowTransfer = FlowTransferV1(new ERC20Transfer[](0), new ERC721Transfer[](0), new ERC1155Transfer[](0)); - uint256[] memory stack = generateFlowStack(flowTransfer); + uint256[] memory stack = LibStackGeneration.generateFlowStack(Sentinel.unwrap(RAIN_FLOW_SENTINEL), flowTransfer); assertEq( keccak256(abi.encode(flowTransfer)), keccak256(abi.encode(flow.stackToFlow(stack))), "wrong compare Structs" ); diff --git a/test/src/concrete/Flow.signedContext.t.sol b/test/src/concrete/Flow.signedContext.t.sol index 6ccf59bc..a632c3b1 100644 --- a/test/src/concrete/Flow.signedContext.t.sol +++ b/test/src/concrete/Flow.signedContext.t.sol @@ -5,9 +5,11 @@ pragma solidity =0.8.25; import {Vm} from "forge-std/Test.sol"; import {FlowTest} from "test/abstract/FlowTest.sol"; import {SignContextLib} from "test/lib/SignContextLib.sol"; -import {IFlowV5} from "../../../src/interface/IFlowV5.sol"; +import {IFlowV5, RAIN_FLOW_SENTINEL} from "../../../src/interface/IFlowV5.sol"; +import {Sentinel} from "rain.solmem/lib/LibStackSentinel.sol"; import {EvaluableV2, SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import {InvalidSignature} from "rain.interpreter.interface/lib/caller/LibContext.sol"; +import {LibStackGeneration} from "test/lib/LibStackGeneration.sol"; contract FlowSignedContextTest is FlowTest { using SignContextLib for Vm; @@ -32,7 +34,8 @@ contract FlowSignedContextTest is FlowTest { signedContexts[0] = vm.signContext(aliceKey, aliceKey, context0); signedContexts[1] = vm.signContext(aliceKey, aliceKey, context1); - uint256[] memory stack = generateFlowStack(transferEmpty()); + uint256[] memory stack = + LibStackGeneration.generateFlowStack(Sentinel.unwrap(RAIN_FLOW_SENTINEL), transferEmpty()); interpreterEval2MockCall(stack, new uint256[](0)); flow.flow(evaluable, new uint256[](0), signedContexts); @@ -63,7 +66,8 @@ contract FlowSignedContextTest is FlowTest { SignedContextV1[] memory signedContext = new SignedContextV1[](1); signedContext[0] = vm.signContext(aliceKey, aliceKey, context0); - uint256[] memory stack = generateFlowStack(transferEmpty()); + uint256[] memory stack = + LibStackGeneration.generateFlowStack(Sentinel.unwrap(RAIN_FLOW_SENTINEL), transferEmpty()); interpreterEval2MockCall(stack, new uint256[](0)); flow.flow(evaluable, new uint256[](0), signedContext); diff --git a/test/src/concrete/Flow.time.t.sol b/test/src/concrete/Flow.time.t.sol index 4c9c38d7..c6f37a85 100644 --- a/test/src/concrete/Flow.time.t.sol +++ b/test/src/concrete/Flow.time.t.sol @@ -3,10 +3,12 @@ pragma solidity =0.8.25; import {FlowTest} from "test/abstract/FlowTest.sol"; -import {IFlowV5} from "../../../src/interface/IFlowV5.sol"; +import {IFlowV5, RAIN_FLOW_SENTINEL} from "../../../src/interface/IFlowV5.sol"; +import {Sentinel} from "rain.solmem/lib/LibStackSentinel.sol"; import {EvaluableV2, SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import {DEFAULT_STATE_NAMESPACE} from "rain.interpreter.interface/interface/IInterpreterV2.sol"; import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; +import {LibStackGeneration} from "test/lib/LibStackGeneration.sol"; contract FlowTimeTest is FlowTest { function testFlowBasicFlowTime(uint256[] memory writeToStore) public { @@ -14,7 +16,8 @@ contract FlowTimeTest is FlowTest { (IFlowV5 flow, EvaluableV2 memory evaluable) = deployFlow(); - uint256[] memory stack = generateFlowStack(transferEmpty()); + uint256[] memory stack = + LibStackGeneration.generateFlowStack(Sentinel.unwrap(RAIN_FLOW_SENTINEL), transferEmpty()); interpreterEval2MockCall(stack, writeToStore); diff --git a/test/src/concrete/Flow.transfer.t.sol b/test/src/concrete/Flow.transfer.t.sol index fae09e19..f3686fcc 100644 --- a/test/src/concrete/Flow.transfer.t.sol +++ b/test/src/concrete/Flow.transfer.t.sol @@ -187,8 +187,10 @@ contract FlowTransferTest is FlowTest { erc20Transfers[0] = ERC20Transfer({token: TOKEN_A, from: bob, to: address(flow), amount: erc20Amount}); erc20Transfers[1] = ERC20Transfer({token: TOKEN_B, from: address(flow), to: alice, amount: erc20Amount}); - uint256[] memory stack = - generateFlowStack(FlowTransferV1(erc20Transfers, new ERC721Transfer[](0), new ERC1155Transfer[](0))); + uint256[] memory stack = LibStackGeneration.generateFlowStack( + Sentinel.unwrap(RAIN_FLOW_SENTINEL), + FlowTransferV1(erc20Transfers, new ERC721Transfer[](0), new ERC1155Transfer[](0)) + ); interpreterEval2MockCall(stack, new uint256[](0)); } @@ -204,8 +206,10 @@ contract FlowTransferTest is FlowTest { erc20Transfers[1] = ERC20Transfer({token: TOKEN_B, from: bob, to: alice, amount: erc20Amount}); vm.mockCall(TOKEN_A, abi.encodeWithSelector(IERC20.transferFrom.selector), abi.encode(true)); - uint256[] memory stack = - generateFlowStack(FlowTransferV1(erc20Transfers, new ERC721Transfer[](0), new ERC1155Transfer[](0))); + uint256[] memory stack = LibStackGeneration.generateFlowStack( + Sentinel.unwrap(RAIN_FLOW_SENTINEL), + FlowTransferV1(erc20Transfers, new ERC721Transfer[](0), new ERC1155Transfer[](0)) + ); interpreterEval2MockCall(stack, new uint256[](0)); } @@ -237,8 +241,10 @@ contract FlowTransferTest is FlowTest { erc721Transfers[0] = ERC721Transfer({token: TOKEN_A, from: bob, to: address(flow), id: erc721TokenId}); erc721Transfers[1] = ERC721Transfer({token: TOKEN_B, from: address(flow), to: alice, id: erc721TokenId}); - uint256[] memory stack = - generateFlowStack(FlowTransferV1(new ERC20Transfer[](0), erc721Transfers, new ERC1155Transfer[](0))); + uint256[] memory stack = LibStackGeneration.generateFlowStack( + Sentinel.unwrap(RAIN_FLOW_SENTINEL), + FlowTransferV1(new ERC20Transfer[](0), erc721Transfers, new ERC1155Transfer[](0)) + ); interpreterEval2MockCall(stack, new uint256[](0)); } @@ -281,8 +287,10 @@ contract FlowTransferTest is FlowTest { token: TOKEN_B, from: address(flow), to: alice, id: erc1155InTokenId, amount: erc1155InAmount }); - uint256[] memory stack = - generateFlowStack(FlowTransferV1(new ERC20Transfer[](0), new ERC721Transfer[](0), erc1155Transfers)); + uint256[] memory stack = LibStackGeneration.generateFlowStack( + Sentinel.unwrap(RAIN_FLOW_SENTINEL), + FlowTransferV1(new ERC20Transfer[](0), new ERC721Transfer[](0), erc1155Transfers) + ); interpreterEval2MockCall(stack, new uint256[](0)); }