-
Notifications
You must be signed in to change notification settings - Fork 78
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
Conversation
if ( | ||
!this.isEthSignEnabled && | ||
signature.signatureType === SignatureType.EthSign | ||
) { | ||
throw new HttpExceptionNoLog( | ||
'eth_sign is disabled', | ||
MessageVerifierHelper.StatusCode, | ||
); | ||
} | ||
|
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
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', | ||
}); |
There was a problem hiding this comment.
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.
|
||
const isBlocked = this.blocklist.includes(signature.owner); | ||
const isBlocked = this.blocklist.some((blockedAddress) => { | ||
return isAddressEqual(signature.owner, blockedAddress); |
There was a problem hiding this comment.
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.
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
TransactionVerifier
andMessageVerifier