Skip to content

Commit

Permalink
Ported flow construction initialize test
Browse files Browse the repository at this point in the history
  • Loading branch information
Erikd-dev committed Aug 5, 2024
1 parent a86384f commit 52c762b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/concrete/Flow/FlowConstructionInitializeTest.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.18;

import {Vm} from "forge-std/Test.sol";

import {InterpreterMockTest} from "test/abstract/InterpreterMockTest.sol";
import {IFlowV5} from "src/interface/unstable/IFlowV5.sol";
import {EvaluableConfigV3} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol";
import {Flow} from "src/concrete/basic/Flow.sol";
import {CloneFactory} from "rain.factory/src/concrete/CloneFactory.sol";
import {FlowUtilsAbstractTest} from "test/abstract/FlowUtilsAbstractTest.sol";

contract FlowConstructionInitializeTest is InterpreterMockTest, FlowUtilsAbstractTest {
CloneFactory internal immutable _iCloneFactory;
IFlowV5 internal immutable _flowImplementation;

constructor() {
vm.pauseGasMetering();
_iCloneFactory = new CloneFactory();
_flowImplementation = new Flow();
vm.resumeGasMetering();
}

function testFlowConstructionInitialize(address expression, bytes memory bytecode, uint256[] memory constants)
external
{
expressionDeployerDeployExpression2MockCall(expression, bytes(hex"0007"));

EvaluableConfigV3[] memory flowConfig = new EvaluableConfigV3[](1);
flowConfig[0] = EvaluableConfigV3(iDeployer, bytecode, constants);

vm.recordLogs();
_iCloneFactory.clone(address(_flowImplementation), abi.encode(flowConfig));

Vm.Log[] memory logs = vm.getRecordedLogs();
bytes32 eventSignature = keccak256("Initialize(address,(address,bytes,uint256[])[])");

Vm.Log memory concreteEvent = findEvent(logs, eventSignature);
(address sender, EvaluableConfigV3[] memory config) =
abi.decode(concreteEvent.data, (address, EvaluableConfigV3[]));

assertEq(sender, address(_iCloneFactory), "wrong sender in Initialize event");
assertEq(keccak256(abi.encode(flowConfig)), keccak256(abi.encode(config)), "wrong compare Structs");
}
}

0 comments on commit 52c762b

Please sign in to comment.