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

chore(core): remove legacy "02" tests #3677

Merged
merged 12 commits into from
Dec 15, 2023
Merged

chore(core): remove legacy "02" tests #3677

merged 12 commits into from
Dec 15, 2023

Conversation

vindard
Copy link
Contributor

@vindard vindard commented Dec 7, 2023

No description provided.

@github-actions github-actions bot added the core label Dec 7, 2023
@vindard vindard marked this pull request as ready for review December 7, 2023 20:55
@vindard vindard marked this pull request as draft December 7, 2023 20:59
@vindard vindard force-pushed the remove-legacy-02-tests branch from a53def1 to b1cdbf8 Compare December 8, 2023 16:05
@vindard vindard marked this pull request as ready for review December 8, 2023 16:15
@vindard vindard force-pushed the remove-legacy-02-tests branch from ee462a0 to bb10581 Compare December 12, 2023 00:27
Copy link
Collaborator

@dolcalmi dolcalmi left a comment

Choose a reason for hiding this comment

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

looks good, just minor comments/changes

paymentRequest,
}

it("persists payment to be deleted in ln-payments collection", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not a test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do you mean? There's a code branch in checkAndDeletePaymentForHash that persists an lnPayment if it didn't previously exist in LnPaymentsRepository that I explicitly wanted to test

Copy link
Collaborator

Choose a reason for hiding this comment

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

I review bottom -> up, there is no need to have 2 tests for this, is just add

const lnPaymentAfter = await lnPayments.findByPaymentHash(paymentHash)
    if (lnPaymentAfter instanceof Error) throw lnPaymentAfter
    expect(lnPaymentAfter.paymentHash).toBe(paymentHash)

in second test but it is up to you

Copy link
Contributor Author

@vindard vindard Dec 14, 2023

Choose a reason for hiding this comment

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

I'd prefer to have them separate because the 2nd test needs to have an explicit step that marks isCompleteRecord as true and I bring that in manually, and if I tried to not do that then the test becomes more complicated because later tests would rely on prior state in the test

Comment on lines +77 to +85
await lnPayments.persistNew({
paymentRequest,
paymentHash,
sentFromPubkey: DEFAULT_PUBKEY,
})
await lnPayments.update({
paymentHash,
isCompleteRecord: true,
} as PersistedLnPaymentLookup)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is what needs to be tested... deleteLnPaymentsBefore should persist it in lnpayment if it does not exists

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I don't understand 😅 ... isn't that what this tests

Copy link
Collaborator

@dolcalmi dolcalmi Dec 14, 2023

Choose a reason for hiding this comment

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

is this not done by await Lightning.deleteLnPaymentsBefore(timestamp2Months) line 89?

Copy link
Contributor Author

@vindard vindard Dec 14, 2023

Choose a reason for hiding this comment

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

Ah nope, it persists it but then it won't get isCompleteRecord property marked as true unless we run updateLnPayments which is a lot more than we need just to test that deletePaymentByHash gets hit under the right conditions

So I just manually setup the lnPayment in the repository so that the use-case can continue on to what we want to test here

bats/core/api/account.bats Show resolved Hide resolved
@@ -104,6 +122,9 @@ describe("onchainBlockEventHandler", () => {
let lastHeight = initialBlock
const subBlocks = subscribeToBlocks({ lnd: lnd1 })
subBlocks.on("block", async ({ height }: { height: number }) => {
// this sleep seems necessary to allow confirmations to propagate for
// 'getChainTransactions' call inside 'listIncomingOnChainTransactions'
await sleep(500)
Copy link
Collaborator

@dolcalmi dolcalmi Dec 14, 2023

Choose a reason for hiding this comment

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

then is something else.... please dont use this inside the handler (we dont have this in trigger handler)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok removed here, will troubleshoot again when we're actually removing 01 folder be614f5

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh actually, we already have this test in bats #3710

@vindard vindard requested a review from dolcalmi December 14, 2023 20:25
dolcalmi
dolcalmi previously approved these changes Dec 14, 2023
@vindard vindard merged commit a30469d into main Dec 15, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants