-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9911f0
commit 9a3d469
Showing
3 changed files
with
48 additions
and
31 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
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
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,34 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.12; | ||
|
||
import "../src/libraries/ByteSignature.sol"; | ||
import {UserOp} from "./helpers/UserOp.sol"; | ||
|
||
contract ByteSignatureTest is UserOp { | ||
function testExtractSingleSignature() public { | ||
// dummy signature | ||
bytes memory signature = | ||
hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01"; | ||
bytes[] memory extracted = ByteSignature.extractSignatures(signature, 1); | ||
assertEq(extracted[0], signature, "The extracted signature does not match the original signature."); | ||
} | ||
|
||
function testExtractMultipleSignatures() public { | ||
// create 2 dummy signatures | ||
bytes memory signature1 = | ||
hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01"; | ||
bytes memory signature2 = | ||
hex"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb1c"; | ||
bytes memory fullSignature = abi.encodePacked(signature1, signature2); | ||
|
||
bytes[] memory extracted = ByteSignature.extractSignatures(fullSignature, 2); | ||
assertEq(extracted[0], signature1, "The first signature does not match the original signature."); | ||
assertEq(extracted[1], signature2, "The second signature does not match the original signature."); | ||
} | ||
|
||
function testExtract_RevertWhen_InvalidLength() public { | ||
bytes memory invalidSignature = hex"abcd"; | ||
vm.expectRevert("ByteSignature: Invalid signature length"); | ||
ByteSignature.extractSignatures(invalidSignature, 1); | ||
} | ||
} |