Skip to content

Commit

Permalink
Fix testValidateSignedContexts test
Browse files Browse the repository at this point in the history
  • Loading branch information
ninokeldishvili committed Aug 7, 2024
1 parent e2b62a8 commit 23babed
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions test/concrete/flow1155/FlowSignedContextTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,18 @@ contract FlowSignedContextTest is SignContextAbstractTest, FlowUtilsAbstractTest
function testValidateSignedContexts(
string memory uri,
uint256[] memory context0,
uint256[] memory context1,
uint256[] memory callerContext,
uint256[] memory writes,
uint256 fuzzedKeyAlice,
uint256 fuzzedKeyBob
) public {
vm.assume(callerContext.length <= type(uint256).max);
vm.assume(writes.length <= type(uint256).max);

vm.assume(fuzzedKeyBob != fuzzedKeyAlice);
(IFlowERC1155V5 erc1155Flow, EvaluableV2 memory evaluable) = deployIFlowERC1155V5(uri);

// Ensure the fuzzed key is within the valid range for secp256k1
uint256 aliceKey = (fuzzedKeyAlice % (SECP256K1_ORDER - 1)) + 1;
uint256 bobKey = (fuzzedKeyBob % (SECP256K1_ORDER - 1)) + 1;

SignedContextV1[] memory signedContexts = new SignedContextV1[](2);
SignedContextV1[] memory signedContexts = new SignedContextV1[](1);
signedContexts[0] = signContext(aliceKey, context0);
signedContexts[1] = signContext(aliceKey, context1);

uint256[] memory stack = generateFlowERC1155Stack(
new ERC1155Transfer[](0),
Expand All @@ -95,13 +88,12 @@ contract FlowSignedContextTest is SignContextAbstractTest, FlowUtilsAbstractTest
new ERC1155SupplyChange[](0),
new ERC1155SupplyChange[](0)
);
interpreterEval2MockCall(stack, writes);
erc1155Flow.flow(evaluable, callerContext, signedContexts);
interpreterEval2MockCall(stack, new uint256[](0));
erc1155Flow.flow(evaluable, new uint256[](0), signedContexts);

// With bad signature in second signed context
SignedContextV1[] memory signedContexts1 = new SignedContextV1[](2);
signedContexts[0] = signContext(aliceKey, context0);
signedContexts[1] = signContext(bobKey, context1);
SignedContextV1[] memory signedContexts1 = new SignedContextV1[](1);
signedContexts[0] = signContext(bobKey, context0);

uint256[] memory stack1 = generateFlowERC1155Stack(
new ERC1155Transfer[](0),
Expand All @@ -110,9 +102,9 @@ contract FlowSignedContextTest is SignContextAbstractTest, FlowUtilsAbstractTest
new ERC1155SupplyChange[](0),
new ERC1155SupplyChange[](0)
);
interpreterEval2MockCall(stack1, writes);
interpreterEval2MockCall(stack1, new uint256[](0));

vm.expectRevert(abi.encodeWithSelector(InvalidSignature.selector, 0));
erc1155Flow.flow(evaluable, callerContext, signedContexts1);
erc1155Flow.flow(evaluable, new uint256[](0), signedContexts1);
}
}

0 comments on commit 23babed

Please sign in to comment.