Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: increase refinement test coverage #2431

Merged
merged 4 commits into from
Mar 7, 2025
Merged

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Mar 6, 2025

Summary

This adds extensive test coverage to refinement of proposal/confirmation and API transactions/messages. It also includes small fixes that we found due to adding test coverage.

Changes

  • Increase test coverage of TransactionVerifier and MessageVerifier
  • Propagate similar test coverage to respective controller tests for transactions/messages

@iamacook iamacook requested a review from a team as a code owner March 6, 2025 19:50
Comment on lines +156 to +165
if (
!this.isEthSignEnabled &&
signature.signatureType === SignatureType.EthSign
) {
throw new HttpExceptionNoLog(
'eth_sign is disabled',
MessageVerifierHelper.StatusCode,
);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the pattern of other methods whereby we log unauthorized addreses as a priority.

@@ -119,6 +119,9 @@ export class TransactionVerifierHelper {
) {
throw new HttpExceptionNoLog(ErrorMessage.InvalidNonce, code);
}

this.verifyApiTransaction(args);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were trusting the API transaction as is whereas it should be verified in a similar manner as we do for the queue.

Comment on lines +3 to +10
function isSignature(value: `0x${string}`): boolean {
// We accept proposals of singular or concatenated signatures
return (value.length - 2) % 130 === 0;
}

export const SignatureSchema = HexSchema.refine(isSignature, {
message: 'Invalid signature',
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By validating signature length, we prevent unnecessary verification from happening. This also has the added benefit that we get more descriptive error messages.

@iamacook iamacook self-assigned this Mar 6, 2025

const isBlocked = this.blocklist.includes(signature.owner);
const isBlocked = this.blocklist.some((blockedAddress) => {
return isAddressEqual(signature.owner, blockedAddress);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was because of mock data but I came across some inconsistencies with non-checksummed addresses. As such, I migrated to using this helper in both verifiers to be safe.

@hectorgomezv hectorgomezv self-requested a review March 7, 2025 14:07
@iamacook iamacook merged commit dd5ee84 into main Mar 7, 2025
16 checks passed
@iamacook iamacook deleted the fix/increase-refinement-tests branch March 7, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants