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

Add unittests for ledger publisher and bug fixes #859

Closed
wants to merge 1 commit into from

Conversation

cindyyan317
Copy link
Collaborator

1 Add unittests to ledger publisher (100%)
2 Inject cache module, remove backend->cache().
3 Bug fix: Use SubscriptionManagerType; maxAttempts calculation

Inject cache
@@ -97,6 +102,7 @@ class LedgerPublisher

if (!range || range->maxSequence < ledgerSequence)
{
++numAttempts;
Copy link
Collaborator Author

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();
Copy link
Collaborator

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?

Copy link
Collaborator Author

@cindyyan317 cindyyan317 Sep 19, 2023

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());
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

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