-
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.
FlowERC721 Construction InitializeTest
- Loading branch information
Showing
2 changed files
with
79 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,30 @@ | ||
// SPDX-License-Identifier: CAL | ||
pragma solidity ^0.8.18; | ||
|
||
import {Vm} from "forge-std/Test.sol"; | ||
|
||
import {InterpreterMockTest} from "test/abstract/InterpreterMockTest.sol"; | ||
import {IFlowERC721V5} from "src/interface/unstable/IFlowERC721V5.sol"; | ||
import {FlowERC721} from "src/concrete/erc721/FlowERC721.sol"; | ||
import {CloneFactory} from "rain.factory/src/concrete/CloneFactory.sol"; | ||
import {FlowUtilsAbstractTest} from "test/abstract/FlowUtilsAbstractTest.sol"; | ||
import {IExpressionDeployerV3} from "rain.interpreter.interface/interface/IExpressionDeployerV3.sol"; | ||
import {REVERTING_MOCK_BYTECODE} from "test/abstract/TestConstants.sol"; | ||
|
||
contract FlowERC721Test is InterpreterMockTest, FlowUtilsAbstractTest { | ||
CloneFactory internal immutable iCloneFactory; | ||
IFlowERC721V5 internal immutable iFlowERC721Implementation; | ||
IExpressionDeployerV3 internal immutable iDeployerForEvalHandleTransfer; | ||
|
||
constructor() { | ||
vm.pauseGasMetering(); | ||
iCloneFactory = new CloneFactory(); | ||
iFlowERC721Implementation = new FlowERC721(); | ||
vm.pauseGasMetering(); | ||
iDeployerForEvalHandleTransfer = | ||
IExpressionDeployerV3(address(uint160(uint256(keccak256("deployer.for.evalhandle.transfer.rain.test"))))); | ||
vm.etch(address(iInterpreter), REVERTING_MOCK_BYTECODE); | ||
|
||
vm.resumeGasMetering(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
test/concrete/flowErc721/FlowConstructionInitializeTest.sol
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,49 @@ | ||
// SPDX-License-Identifier: CAL | ||
pragma solidity ^0.8.18; | ||
|
||
import {Vm} from "forge-std/Test.sol"; | ||
|
||
import {FlowERC721ConfigV2} from "src/interface/unstable/IFlowERC721V5.sol"; | ||
import {EvaluableConfigV3} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; | ||
import {IExpressionDeployerV3} from "rain.interpreter.interface/interface/IExpressionDeployerV3.sol"; | ||
import {FlowERC721Test} from "test/abstract/FlowERC721Test.sol"; | ||
|
||
contract FlowConstructionInitializeTest is FlowERC721Test { | ||
function testFlowConstructionInitialize(address expression, bytes memory bytecode, uint256[] memory constants) | ||
external | ||
{ | ||
expressionDeployerDeployExpression2MockCall(expression, bytes(hex"0006")); | ||
|
||
EvaluableConfigV3[] memory flowConfig = new EvaluableConfigV3[](1); | ||
flowConfig[0] = EvaluableConfigV3(iDeployer, bytecode, constants); | ||
|
||
vm.mockCall( | ||
address(iDeployerForEvalHandleTransfer), | ||
abi.encodeWithSelector(IExpressionDeployerV3.deployExpression2.selector), | ||
abi.encode(iInterpreter, iStore, expression, bytes(hex"00000006")) | ||
); | ||
|
||
FlowERC721ConfigV2 memory flowERC721ConfigV2 = FlowERC721ConfigV2( | ||
"Flow ERC721", | ||
"F721", | ||
"https://www.rainprotocol.xyz/nft/", | ||
EvaluableConfigV3(iDeployerForEvalHandleTransfer, bytecode, constants), | ||
flowConfig | ||
); | ||
|
||
vm.recordLogs(); | ||
iCloneFactory.clone(address(iFlowERC721Implementation), abi.encode(flowERC721ConfigV2)); | ||
|
||
Vm.Log[] memory logs = vm.getRecordedLogs(); | ||
bytes32 eventSignature = keccak256( | ||
"Initialize(address,(string,string,string,(address,bytes,uint256[]),(address,bytes,uint256[])[]))" | ||
); | ||
|
||
Vm.Log memory concreteEvent = findEvent(logs, eventSignature); | ||
(address sender, FlowERC721ConfigV2 memory config) = | ||
abi.decode(concreteEvent.data, (address, FlowERC721ConfigV2)); | ||
|
||
assertEq(sender, address(iCloneFactory), "wrong sender in Initialize event"); | ||
assertEq(keccak256(abi.encode(flowERC721ConfigV2)), keccak256(abi.encode(config)), "wrong compare Structs"); | ||
} | ||
} |