-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add unittests for ledger publisher and bug fixes #859
Conversation
Inject cache
@@ -97,6 +102,7 @@ class LedgerPublisher | |||
|
|||
if (!range || range->maxSequence < ledgerSequence) | |||
{ | |||
++numAttempts; |
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.
Fix bug, when numAttemps is x, we actually accessed db x+1 times.
void | ||
SetUp() override | ||
{ | ||
MockBackendTest::SetUp(); |
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.
Do you actually need to do this manually? Or do you need specific sequence?
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.
1 We do need to call these manually. It inherits multiple classes.
2 Keeping the setup and teardown order does not matter for this usercase. Just my preference to keep such construction/ destruction actions symmetrical.
dummyState.isWriting = true; | ||
// age is -10 | ||
ripple::LedgerInfo dummyLedgerInfo = CreateLedgerInfo(LEDGERHASH, SEQ, 0); | ||
auto const now = duration_cast<seconds>(system_clock::now().time_since_epoch()); |
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.
It would be better to fix the time point here. Tests shouldn't depend on time.
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 is deliberately create a ledger with the future timestamp to trigger the error handling in lastCloseAgeSeconds function.
1 Add unittests to ledger publisher (100%)
2 Inject cache module, remove backend->cache().
3 Bug fix: Use SubscriptionManagerType; maxAttempts calculation