Skip to content

Commit

Permalink
Add testFlowErc1155HaltIfEnsureRequirementNotMet
Browse files Browse the repository at this point in the history
  • Loading branch information
ninokeldishvili committed Sep 27, 2024
1 parent 1d1f09f commit 9df87c6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/concrete/flowErc1155/Erc1155FlowTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}

0 comments on commit 9df87c6

Please sign in to comment.