Skip to content

Commit

Permalink
Update testValidateMultipleSignedContexts, remove unused imports and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ninokeldishvili committed Aug 7, 2024
1 parent 91ce935 commit 9d16a2e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 35 deletions.
2 changes: 1 addition & 1 deletion test/abstract/FlowUtilsAbstractTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ abstract contract FlowUtilsAbstractTest is Test {
}
revert("Event not found!");
}
}
}
2 changes: 1 addition & 1 deletion test/abstract/SignContextAbstractTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ abstract contract SignContextAbstractTest is Test {

return signedContext;
}
}
}
46 changes: 13 additions & 33 deletions test/concrete/flow1155/FlowSignedContextTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 9d16a2e

Please sign in to comment.