From 9d16a2ea0546897a980822a92204a2e37cdd78d4 Mon Sep 17 00:00:00 2001 From: ninokeldishvili Date: Wed, 7 Aug 2024 07:45:08 +0400 Subject: [PATCH] Update testValidateMultipleSignedContexts, remove unused imports and fmt --- test/abstract/FlowUtilsAbstractTest.sol | 2 +- test/abstract/SignContextAbstractTest.sol | 2 +- .../flow1155/FlowSignedContextTest.sol | 46 ++++++------------- 3 files changed, 15 insertions(+), 35 deletions(-) diff --git a/test/abstract/FlowUtilsAbstractTest.sol b/test/abstract/FlowUtilsAbstractTest.sol index 63491fc9..b3eb31b5 100644 --- a/test/abstract/FlowUtilsAbstractTest.sol +++ b/test/abstract/FlowUtilsAbstractTest.sol @@ -152,4 +152,4 @@ abstract contract FlowUtilsAbstractTest is Test { } revert("Event not found!"); } -} \ No newline at end of file +} diff --git a/test/abstract/SignContextAbstractTest.sol b/test/abstract/SignContextAbstractTest.sol index 81e71d19..dac4f00b 100644 --- a/test/abstract/SignContextAbstractTest.sol +++ b/test/abstract/SignContextAbstractTest.sol @@ -24,4 +24,4 @@ abstract contract SignContextAbstractTest is Test { return signedContext; } -} \ No newline at end of file +} diff --git a/test/concrete/flow1155/FlowSignedContextTest.sol b/test/concrete/flow1155/FlowSignedContextTest.sol index 01bb3e8f..5c5aa7e2 100644 --- a/test/concrete/flow1155/FlowSignedContextTest.sol +++ b/test/concrete/flow1155/FlowSignedContextTest.sol @@ -10,51 +10,31 @@ import { ERC1155Transfer, ERC1155SupplyChange } from "test/abstract/FlowUtilsAbstractTest.sol"; -import { - IFlowERC1155V5, FlowERC1155ConfigV3, FlowERC1155IOV1 -} from "../../../src/interface/unstable/IFlowERC1155V5.sol"; -import {LibFlow} from "../../../src/lib/LibFlow.sol"; -import { - EvaluableV2, - SignedContextV1, - EvaluableConfigV3 -} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; -import {IInterpreterV2} from "rain.interpreter.interface/interface/IInterpreterV2.sol"; -import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; -import {InterpreterMockTest} from "../../abstract/InterpreterMockTest.sol"; +import {IFlowERC1155V5} from "../../../src/interface/unstable/IFlowERC1155V5.sol"; +import {EvaluableV2, SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import {FlowERC1155Test} from "../../abstract/FlowERC1155Test.sol"; +import {SignContextAbstractTest} from "../../abstract/SignContextAbstractTest.sol"; -contract FlowSignedContextTest is FlowERC1155Test { - function testValidateMultipleSignedContexts(string memory uri, bytes memory context0, bytes memory context1) +contract FlowSignedContextTest is SignContextAbstractTest, FlowUtilsAbstractTest, FlowERC1155Test { + function testValidateMultipleSignedContexts(string memory uri, uint256[] memory context0, uint256[] memory context1) public { + (IFlowERC1155V5 erc1155Flow, EvaluableV2 memory evaluable) = deployIFlowERC1155V5(uri); address alice = vm.addr(1); address bob = vm.addr(2); - vm.startPrank(alice); - - (IFlowERC1155V5 erc1155Flow, EvaluableV2 memory evaluable) = deployIFlowERC1155V5(uri); - - bytes32 hash = keccak256(context0); - (uint8 v0, bytes32 r0, bytes32 s0) = vm.sign(1, hash); - address signer = ecrecover(hash, v0, r0, s0); - // Convert the signature components to uint256[] - uint256[] memory signatureAlice = new uint256[](3); - signatureAlice[0] = uint256(r0); - signatureAlice[1] = uint256(s0); - signatureAlice[2] = uint256(v0); SignedContextV1[] memory signedContexts = new SignedContextV1[](2); - signedContexts[0] = SignedContextV1(alice, signatureAlice, context0); - signedContexts[1] = SignedContextV1(alice, signatureAlice, context1); + signedContexts[0] = signContext(1, context0); + signedContexts[1] = signContext(1, context1); - performErc1155Flow( - erc1155Flow, - evaluable, - new ERC20Transfer[](0), - new ERC721Transfer[](0), + uint256[] memory stack = generateFlowERC1155Stack( new ERC1155Transfer[](0), + new ERC721Transfer[](0), + new ERC20Transfer[](0), new ERC1155SupplyChange[](0), new ERC1155SupplyChange[](0) ); + interpreterEval2MockCall(stack, new uint256[](0)); + erc1155Flow.flow(evaluable, new uint256[](0), signedContexts); } }