-
Notifications
You must be signed in to change notification settings - Fork 5
fix: test errors #441
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: test errors #441
Conversation
| .set('Authorization', users[0].token) | ||
| .set('Signeraddress', users[0].payload.address) | ||
| .send(payload_transfer); | ||
| const vault = predicates[5]; |
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.
🔴 CRITICAL: Hardcoded array index without bounds validation
Problem:
Using predicates[5] assumes the array has at least 6 elements, but the test environment is initialized with only 6 predicates (index 0-5). This creates a tight coupling and potential runtime error if the initialization changes.
Suggestion:
Add bounds checking or use a more defensive approach:
const vault = predicates[predicates.length - 1]; // Use last predicate
// or
if (predicates.length < 6) throw new Error('Not enough predicates for test');
const vault = predicates[5];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.
Adjusted on: a3497e0
| assert.equal(res.status, 200); | ||
| assert.ok('ofUser' in res.body); | ||
| assert.ok('transactionsBlocked' in res.body); | ||
| assert.ok('pendingSignature' in res.body); |
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.
🟡 IMPORTANT: Missing validation for incremental counting assumption
Problem:
The test assumes that saveMockTransaction will always create exactly one pending transaction, but there's no validation that the mock transaction was actually created with PENDING status.
Suggestion:
Add validation to ensure the mock transaction is in pending state:
// After saveMockTransaction
const createdTx = await saveMockTransaction({ vault, user }, app);
assert.equal(createdTx.status, TransactionStatus.PENDING_SENDER);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.
Adjusted on: 4658068
guimroque
left a comment
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.
Code Review - Summary
What was done
Fixed two failing API tests:
- GET /transaction/pending: Improved test isolation by using a dedicated vault (predicates[5]) and implementing incremental transaction counting logic
- GET /user/transactions: Fixed query parameter format to properly send status as an array using bracket notation
Positive Points
- Good test isolation approach using a separate vault for pending transactions test
- Smart incremental counting logic (previousCount + 1) makes the test more robust
- Proper query parameter format for array values
- Clean removal of unused import (ZeroBytes32)
- Consistent code formatting and structure
Issues Found
- One critical issue: hardcoded predicate index without bounds checking could cause runtime errors
- One important issue: missing validation for the incremental counting assumption
Total comments: 2 (1 critical, 1 important)
guimroque
left a comment
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.
LGTM! ✅
Previous issues have been fixed. Code approved.
Description
Some API tests had errors:
Summary
previousCount + 1), since the count of pending transactions is per userChecklist