diff --git a/test/concrete/flowErc1155/Erc1155FlowTest.sol b/test/concrete/flowErc1155/Erc1155FlowTest.sol index e6f7d837..ffd0c643 100644 --- a/test/concrete/flowErc1155/Erc1155FlowTest.sol +++ b/test/concrete/flowErc1155/Erc1155FlowTest.sol @@ -28,6 +28,9 @@ import {LibContextWrapper} from "test/lib/LibContextWrapper.sol"; import {LibEncodedDispatch} from "rain.interpreter.interface/lib/caller/LibEncodedDispatch.sol"; import {LibUint256Array} from "rain.solmem/lib/LibUint256Array.sol"; import {LibUint256Matrix} from "rain.solmem/lib/LibUint256Matrix.sol"; +import {FLOW_ENTRYPOINT, FLOW_MAX_OUTPUTS} from "src/abstract/FlowCommon.sol"; +import {LibEncodedDispatch} from "rain.interpreter.interface/lib/caller/LibEncodedDispatch.sol"; +import {LibContextWrapper} from "test/lib/LibContextWrapper.sol"; contract Erc1155FlowTest is FlowERC1155Test { using LibEvaluable for EvaluableV2; @@ -515,4 +518,28 @@ contract Erc1155FlowTest is FlowERC1155Test { flowInvalid.flow(evaluablesInvalid[0], new uint256[](0), new SignedContextV1[](0)); vm.stopPrank(); } + + /** + * @notice Tests that the flow halts if it does not meet the 'ensure' requirement. + */ + /// forge-config: default.fuzz.runs = 100 + function testFlowErc1155HaltIfEnsureRequirementNotMet(string memory uri) external { + (IFlowERC1155V5 flow, EvaluableV2 memory evaluable) = deployIFlowERC1155V5(uri); + + assumeEtchable(address(0), address(flow)); + + (uint256[] memory stack,) = mintAndBurnFlowStack(address(this), 20 ether, 10 ether, 5, transferEmpty()); + interpreterEval2MockCall(stack, new uint256[](0)); + + uint256[][] memory context = LibContextWrapper.buildAndSetContext( + new uint256[](0), new SignedContextV1[](0), address(this), address(flow) + ); + + interpreterEval2RevertCall( + address(flow), LibEncodedDispatch.encode2(evaluable.expression, FLOW_ENTRYPOINT, FLOW_MAX_OUTPUTS), context + ); + + vm.expectRevert("REVERT_EVAL2_CALL"); + flow.flow(evaluable, new uint256[](0), new SignedContextV1[](0)); + } }