Skip to content

Commit

Permalink
[#754] Add regex in test because signatures are sorted by address of …
Browse files Browse the repository at this point in the history
…signer and revert message depends on order of signature type
  • Loading branch information
akshay-ap committed Jul 2, 2024
1 parent 936ec13 commit 36d486f
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions test/core/Safe.Signatures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ describe("Safe", () => {

const signatures2 = buildSignatureBytes([signerSafeSig, await safeSignTypedData(user3, safeAddress, tx)]);

await expect(safe["checkSignatures(bytes32,bytes)"](txHash, signatures2)).to.be.revertedWith("GS021");
await expect(safe["checkSignatures(bytes32,bytes)"](txHash, signatures2)).to.be.revertedWith(new RegExp("GS028|GS021"));
});

it("should be able to mix all signature types", async () => {
Expand Down Expand Up @@ -707,33 +707,25 @@ describe("Safe", () => {

it("should revert if signature contains additional bytes than required", async () => {
const {
signers: [user1, user2, user3],
safe,
signers: [user1],
} = await setupTests();
const compatFallbackHandler = await getCompatFallbackHandler();
const compatFallbackHandlerAddress = await compatFallbackHandler.getAddress();
const signerSafe = await getSafeWithOwners([user2.address], 1, compatFallbackHandlerAddress);
const signerSafeAddress = await signerSafe.getAddress();
const safe = await getSafeWithOwners([user1.address, user3.address, signerSafeAddress], 2);
const safeAddress = await safe.getAddress();
const tx = buildSafeTransaction({ to: safeAddress, nonce: await safe.nonce() });
const txHash = calculateSafeTransactionHash(safeAddress, tx, await chainId());

const safeMessageHash = calculateSafeMessageHash(signerSafeAddress, txHash, await chainId());
const signerSafeOwnerSignature = await signHash(user2, safeMessageHash);
const signerSafeSig = buildContractSignature(signerSafeAddress, signerSafeOwnerSignature.data);

const signatures = buildSignatureBytes([await safeApproveHash(user1, safe, tx, true), signerSafeSig]);
const signatures = buildSignatureBytes([await safeApproveHash(user1, safe, tx, true)]);

await expect(
safe["checkNSignatures(address,bytes32,bytes,uint256)"](user1.address, txHash, signatures.concat("00"), 2),
safe["checkNSignatures(address,bytes32,bytes,uint256)"](user1.address, txHash, signatures.concat("00"), 1),
).to.be.revertedWith("GS028");

await expect(
safe["checkNSignatures(address,bytes32,bytes,uint256)"](
user1.address,
txHash,
signatures.concat(ethers.hexlify(ethers.randomBytes(Math.random() * 100)).slice(2)),
2,
1,
),
).to.be.revertedWith("GS028");
});
Expand Down

0 comments on commit 36d486f

Please sign in to comment.