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

Issue 579 fix unit testing #593

Merged
merged 10 commits into from
Oct 18, 2024
Merged

Conversation

danfercf1
Copy link
Contributor

@danfercf1 danfercf1 commented Sep 25, 2024

  • The bot tests were modified to use Mocked connection for MongoDB and mocked connection for the Telegram API test. (I think the dependency "telegram-test-api" could be removed, this dependency could be keept if there is the chance to add integration tests).
  • The Lightning test was modified with small changes.
  • Added a bunch of test for bot validations.
  • The files are using the .spec in the names in order to have better organization in the folders and files structure.
  • Added some observations into the validation.js file and fixed some bugs that were found by the tests.
  • The method isOrderCreator was moved to utils in order to have a better test structure.

Fixes #579

@@ -345,15 +340,13 @@ const validateInvoice = async (ctx: MainContext, lnInvoice: string) => {
const latestDate = new Date(
Date.now() + Number(process.env.INVOICE_EXPIRATION_WINDOW)
);
if (!("MAIN_PAYMENT_AMT" in process.env)) throw Error("MIN_PAYMENT_AMT not found, please check .env file");
if (!("MIN_PAYMENT_AMT" in process.env)) throw Error("MIN_PAYMENT_AMT not found, please check .env file");
Copy link
Contributor

Choose a reason for hiding this comment

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

@danfercf1 this looks like an unrelated change that should go in a separate PR?

Copy link
Contributor Author

@danfercf1 danfercf1 Oct 3, 2024

Choose a reason for hiding this comment

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

Yes, you are right the problem is that the test related to this implementation will not work. I've reported that problem in this issue #594

Copy link
Member

@grunch grunch left a comment

Choose a reason for hiding this comment

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

thank you for this great contribution, this PR is really important the the bot, please add a lightning invoice with the amount we set on the board as a comment.

@grunch grunch merged commit c02f051 into lnp2pBot:main Oct 18, 2024
4 checks passed
@danfercf1
Copy link
Contributor Author

Hi @grunch , just to be sure which is the amount to create the invoice?

@grunch
Copy link
Member

grunch commented Oct 18, 2024

Hi @grunch , just to be sure which is the amount to create the invoice?

300000 sats

here the board https://github.com/orgs/lnp2pBot/projects/2/views/1

@danfercf1
Copy link
Contributor Author

Here is the invoice, thank you too

lnbc3m1pn39npnpp55jl8px9ldyphqp43yvdetr7834d5yzfene2kxmpu3y39f35xmf4qcqpjsp5clyfvyeapm0kn3y9uggvlgsye4lrjfrgl9jsqfnddjhag0yxfsjq9q7sqqqqqqqqqqqqqqqqqqqsqqqqqysgqdqqmqz9gxqyjw5qrzjqwryaup9lh50kkranzgcdnn2fgvx390wgj5jd07rwr3vxeje0glcllesp7j2jvfdcsqqqqlgqqqqqeqqjqspa9pne2w90qjx96sjr7r45spvqlcsr6mzxcsflkjcjwgfqh2ldr4nyueurv8d79e3qhlumfqk3gtq6n9jjdns33kpkkfdmt6lhrr8sql5e2m9

@grunch
Copy link
Member

grunch commented Oct 18, 2024

lnbc3m1pn39npnpp55jl8px9ldyphqp43yvdetr7834d5yzfene2kxmpu3y39f35xmf4qcqpjsp5clyfvyeapm0kn3y9uggvlgsye4lrjfrgl9jsqfnddjhag0yxfsjq9q7sqqqqqqqqqqqqqqqqqqqsqqqqqysgqdqqmqz9gxqyjw5qrzjqwryaup9lh50kkranzgcdnn2fgvx390wgj5jd07rwr3vxeje0glcllesp7j2jvfdcsqqqqlgqqqqqeqqjqspa9pne2w90qjx96sjr7r45spvqlcsr6mzxcsflkjcjwgfqh2ldr4nyueurv8d79e3qhlumfqk3gtq6n9jjdns33kpkkfdmt6lhrr8sql5e2m9

Payment hash: a4be7098bf69037006b1231b958fc78d5b4209399e55636c3c892254c686da6a
Payment status: FAILED, reason: FAILURE_REASON_NO_ROUTE

@danfercf1
Copy link
Contributor Author

Could it be an error related to liquidity? I'm using a phoenix wallet

@grunch
Copy link
Member

grunch commented Oct 19, 2024

Could it be an error related to liquidity? I'm using a phoenix wallet

Sometimes it happens, some mobiles send to halt the apps to save battery and if Phoenix is not online it can't receive the payment, let's try again

@danfercf1
Copy link
Contributor Author

Could it be an error related to liquidity? I'm using a phoenix wallet

Sometimes it happens, some mobiles send to halt the apps to save battery and if Phoenix is not online it can't receive the payment, let's try again

Hi @grunch, I received a notification from my wallet related to the fee amount that is not enough, do I need to have the amount of the fee in the wallet?

@grunch
Copy link
Member

grunch commented Oct 21, 2024

Could it be an error related to liquidity? I'm using a phoenix wallet

Sometimes it happens, some mobiles send to halt the apps to save battery and if Phoenix is not online it can't receive the payment, let's try again

Hi @grunch, I received a notification from my wallet related to the fee amount that is not enough, do I need to have the amount of the fee in the wallet?

probably, go to settings / general / channel management and change the max fee, I have 5000 sats

@danfercf1
Copy link
Contributor Author

Hi @grunch, yesterday I increased the value to 8000, but I received the same error again, it was rejected due the amount is low and I need 13400 sat, please, I will send you another invoice from another wallet

@danfercf1
Copy link
Contributor Author

lnbc3m1pn3vn4gpp5pj9ykp6puhc365mc2dshjvu8srmryf33lyhycrhlwaz45w633c3sdqqcqzysxqrrsssp59vzj8d3qhyg5zt2dz7vgpcqhhv3wjyx363ct5v35qac965mzsm4s9qxpqysgqjmtp9dxg5mdhfz2c6h9gwqlltaxrtle393zdkvw8swpw6aa5dvpsde02drkd8jyufzavpzxwmpe682a655cz42t4gsdlrs52fzq3ftqpku6wa3

@grunch
Copy link
Member

grunch commented Oct 21, 2024

lnbc3m1pn3vn4gpp5pj9ykp6puhc365mc2dshjvu8srmryf33lyhycrhlwaz45w633c3sdqqcqzysxqrrsssp59vzj8d3qhyg5zt2dz7vgpcqhhv3wjyx363ct5v35qac965mzsm4s9qxpqysgqjmtp9dxg5mdhfz2c6h9gwqlltaxrtle393zdkvw8swpw6aa5dvpsde02drkd8jyufzavpzxwmpe682a655cz42t4gsdlrs52fzq3ftqpku6wa3

Payment hash: 0c8a4b0741e5f11d5378536179338780f6322631f92e4c0eff77455a3b518e23
Payment status: SUCCEEDED, preimage: 4aaaf760a58162ae995ab861860565c4d25e566664eb4f9c0aabd017095ea3e4

@danfercf1
Copy link
Contributor Author

lnbc3m1pn3vn4gpp5pj9ykp6puhc365mc2dshjvu8srmryf33lyhycrhlwaz45w633c3sdqqcqzysxqrrsssp59vzj8d3qhyg5zt2dz7vgpcqhhv3wjyx363ct5v35qac965mzsm4s9qxpqysgqjmtp9dxg5mdhfz2c6h9gwqlltaxrtle393zdkvw8swpw6aa5dvpsde02drkd8jyufzavpzxwmpe682a655cz42t4gsdlrs52fzq3ftqpku6wa3

Payment hash: 0c8a4b0741e5f11d5378536179338780f6322631f92e4c0eff77455a3b518e23
Payment status: SUCCEEDED, preimage: 4aaaf760a58162ae995ab861860565c4d25e566664eb4f9c0aabd017095ea3e4

Received, thank you so much, it will be helpful to me

@grunch grunch mentioned this pull request Oct 24, 2024
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.

Fix unit testing
3 participants