Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test FlowErc721 Halt If Ensure Requirement Not Met #253

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/concrete/flowErc721/Erc721FlowTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpr
import {DEFAULT_STATE_NAMESPACE} from "rain.interpreter.interface/interface/IInterpreterV2.sol";
import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol";
import {MissingSentinel} from "rain.solmem/lib/LibStackSentinel.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 Erc721FlowTest is FlowERC721Test {
using LibEvaluable for EvaluableV2;
Expand Down Expand Up @@ -499,4 +502,29 @@ contract Erc721FlowTest is FlowERC721Test {
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 testFlowErc721HaltIfEnsureRequirementNotMet() external {
(IFlowERC721V5 flow, EvaluableV2 memory evaluable) =
deployFlowERC721("FlowERC721", "F721", "https://www.rainprotocol.xyz/nft/");

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));
}
}
Loading