-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ported flow construction initialize test
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |