[test] add tests for lnbits funding source (#2460)

This commit is contained in:
Vlad Stan 2024-04-24 09:31:23 +03:00 committed by GitHub
parent 8d3b156738
commit b2ff2d8cee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 501 additions and 66 deletions

View file

@ -32,6 +32,14 @@
"eclair_pass": "secret",
"user_agent": "LNbits/Tests"
}
},
"lnbits": {
"wallet_class": "LNbitsWallet",
"settings": {
"lnbits_endpoint": "http://127.0.0.1:8555",
"lnbits_admin_key": "f171ba022a764e679eef950b21fb1c04",
"user_agent": "LNbits/Tests"
}
}
},
"functions": {
@ -78,6 +86,16 @@
},
"method": "POST"
}
},
"lnbits": {
"status_endpoint": {
"uri": "/api/v1/wallet",
"headers": {
"X-Api-Key": "f171ba022a764e679eef950b21fb1c04",
"User-Agent": "LNbits/Tests"
},
"method": "GET"
}
}
},
"tests": [
@ -129,6 +147,16 @@
}
}
]
},
"lnbits": {
"status_endpoint": [
{
"response_type": "json",
"response": {
"balance": 55000
}
}
]
}
}
},
@ -178,6 +206,14 @@
}
}
]
},
"lnbits": {
"status_endpoint": [
{
"response_type": "json",
"response": "test-error"
}
]
}
}
},
@ -220,6 +256,14 @@
"response": {}
}
]
},
"lnbits": {
"status_endpoint": [
{
"response_type": "json",
"response": {}
}
]
}
}
},
@ -262,6 +306,14 @@
"response": "data-not-json"
}
]
},
"lnbits": {
"status_endpoint": [
{
"response_type": "data",
"response": "data-not-json"
}
]
}
}
},
@ -316,6 +368,17 @@
}
}
]
},
"lnbits": {
"status_endpoint": [
{
"response_type": "response",
"response": {
"response": "Not Found",
"status": 404
}
}
]
}
}
},
@ -372,6 +435,16 @@
},
"method": "POST"
}
},
"lnbits": {
"create_invoice_endpoint": {
"uri": "/api/v1/payments",
"headers": {
"X-Api-Key": "f171ba022a764e679eef950b21fb1c04",
"User-Agent": "LNbits/Tests"
},
"method": "POST"
}
}
},
"tests": [
@ -383,10 +456,10 @@
"label": "test-label"
},
"expect": {
"error_message": null,
"success": true,
"checking_id": "e35526a43d04e985594c0dfab848814f524b1c786598ec9a63beddb2d726ac96",
"payment_request": "lnbc5550n1pnq9jg3sp52rvwstvjcypjsaenzdh0h30jazvzsf8aaye0julprtth9kysxtuspp5e5s3z7felv4t9zrcc6wpn7ehvjl5yzewanzl5crljdl3jgeffyhqdq2f38xy6t5wvxqzjccqpjrzjq0yzeq76ney45hmjlnlpvu0nakzy2g35hqh0dujq8ujdpr2e42pf2rrs6vqpgcsqqqqqqqqqqqqqqeqqyg9qxpqysgqwftcx89k5pp28435pgxfl2vx3ksemzxccppw2j9yjn0ngr6ed7wj8ztc0d5kmt2mvzdlcgrludhz7jncd5l5l9w820hc4clpwhtqj3gq62g66n",
"error_message": null
"payment_request": "lnbc5550n1pnq9jg3sp52rvwstvjcypjsaenzdh0h30jazvzsf8aaye0julprtth9kysxtuspp5e5s3z7felv4t9zrcc6wpn7ehvjl5yzewanzl5crljdl3jgeffyhqdq2f38xy6t5wvxqzjccqpjrzjq0yzeq76ney45hmjlnlpvu0nakzy2g35hqh0dujq8ujdpr2e42pf2rrs6vqpgcsqqqqqqqqqqqqqqeqqyg9qxpqysgqwftcx89k5pp28435pgxfl2vx3ksemzxccppw2j9yjn0ngr6ed7wj8ztc0d5kmt2mvzdlcgrludhz7jncd5l5l9w820hc4clpwhtqj3gq62g66n"
},
"mocks": {
"corelightningrest": {
@ -453,6 +526,23 @@
}
}
]
},
"lnbits": {
"create_invoice_endpoint": [
{
"request_type": "json",
"request_body": {
"out": false,
"amount": 555000,
"memo": "Test Invoice"
},
"response_type": "json",
"response": {
"checking_id": "e35526a43d04e985594c0dfab848814f524b1c786598ec9a63beddb2d726ac96",
"payment_request": "lnbc5550n1pnq9jg3sp52rvwstvjcypjsaenzdh0h30jazvzsf8aaye0julprtth9kysxtuspp5e5s3z7felv4t9zrcc6wpn7ehvjl5yzewanzl5crljdl3jgeffyhqdq2f38xy6t5wvxqzjccqpjrzjq0yzeq76ney45hmjlnlpvu0nakzy2g35hqh0dujq8ujdpr2e42pf2rrs6vqpgcsqqqqqqqqqqqqqqeqqyg9qxpqysgqwftcx89k5pp28435pgxfl2vx3ksemzxccppw2j9yjn0ngr6ed7wj8ztc0d5kmt2mvzdlcgrludhz7jncd5l5l9w820hc4clpwhtqj3gq62g66n"
}
}
]
}
}
},
@ -464,10 +554,10 @@
"label": "test-label"
},
"expect": {
"error_message": "Server error: 'Test Error'",
"success": false,
"checking_id": null,
"payment_request": null,
"error_message": "Server error: 'Test Error'"
"payment_request": null
},
"mocks": {
"corelightningrest": {
@ -518,6 +608,22 @@
}
}
]
},
"lnbits": {
"create_invoice_endpoint": [
{
"request_type": "json",
"request_body": {
"out": false,
"amount": 555000,
"memo": "Test Invoice"
},
"response_type": "json",
"response": {
"detail": "Test Error"
}
}
]
}
}
},
@ -529,10 +635,10 @@
"label": "test-label"
},
"expect": {
"error_message": "Server error: 'missing required fields'",
"success": false,
"checking_id": null,
"payment_request": null,
"error_message": "Server error: 'missing required fields'"
"payment_request": null
},
"mocks": {
"corelightningrest": {
@ -596,6 +702,22 @@
}
}
]
},
"lnbits": {
"create_invoice_endpoint": [
{
"request_type": "json",
"request_body": {
"out": false,
"amount": 555000,
"memo": "Test Invoice"
},
"response_type": "json",
"response": {
"payment_request": "lnbc5550n1pnq9jg3sp52rvwstvjcypjsaenzdh0h30jazvzsf8aaye0julprtth9kysxtuspp5e5s3z7felv4t9zrcc6wpn7ehvjl5yzewanzl5crljdl3jgeffyhqdq2f38xy6t5wvxqzjccqpjrzjq0yzeq76ney45hmjlnlpvu0nakzy2g35hqh0dujq8ujdpr2e42pf2rrs6vqpgcsqqqqqqqqqqqqqqeqqyg9qxpqysgqwftcx89k5pp28435pgxfl2vx3ksemzxccppw2j9yjn0ngr6ed7wj8ztc0d5kmt2mvzdlcgrludhz7jncd5l5l9w820hc4clpwhtqj3gq62g66n"
}
}
]
}
}
},
@ -665,6 +787,20 @@
"response": "data-not-json"
}
]
},
"lnbits": {
"create_invoice_endpoint": [
{
"request_type": "json",
"request_body": {
"out": false,
"amount": 555000,
"memo": "Test Invoice"
},
"response_type": "data",
"response": "data-not-json"
}
]
}
}
},
@ -746,6 +882,23 @@
}
}
]
},
"lnbits": {
"create_invoice_endpoint": [
{
"request_type": "json",
"request_body": {
"out": false,
"amount": 555000,
"memo": "Test Invoice"
},
"response_type": "response",
"response": {
"response": "Not Found",
"status": 404
}
}
]
}
}
},
@ -816,6 +969,24 @@
},
"method": "POST"
}
},
"lnbits": {
"pay_invoice_endpoint": {
"uri": "/api/v1/payments",
"headers": {
"X-Api-Key": "f171ba022a764e679eef950b21fb1c04",
"User-Agent": "LNbits/Tests"
},
"method": "POST"
},
"get_payment_status_endpoint": {
"uri": "/api/v1/payments/e35526a43d04e985594c0dfab848814f524b1c786598ec9a63beddb2d726ac96",
"headers": {
"X-Api-Key": "f171ba022a764e679eef950b21fb1c04",
"User-Agent": "LNbits/Tests"
},
"method": "GET"
}
}
},
"tests": [
@ -925,6 +1096,34 @@
]
}
]
},
"lnbits": {
"pay_invoice_endpoint": [
{
"request_type": "json",
"request_body": {
"out": true,
"blt11": "lnbc5550n1pnq9jg3sp52rvwstvjcypjsaenzdh0h30jazvzsf8aaye0julprtth9kysxtuspp5e5s3z7felv4t9zrcc6wpn7ehvjl5yzewanzl5crljdl3jgeffyhqdq2f38xy6t5wvxqzjccqpjrzjq0yzeq76ney45hmjlnlpvu0nakzy2g35hqh0dujq8ujdpr2e42pf2rrs6vqpgcsqqqqqqqqqqqqqqeqqyg9qxpqysgqwftcx89k5pp28435pgxfl2vx3ksemzxccppw2j9yjn0ngr6ed7wj8ztc0d5kmt2mvzdlcgrludhz7jncd5l5l9w820hc4clpwhtqj3gq62g66n"
},
"response_type": "json",
"response": {
"payment_hash": "e35526a43d04e985594c0dfab848814f524b1c786598ec9a63beddb2d726ac96",
"checking_id": "e35526a43d04e985594c0dfab848814f524b1c786598ec9a63beddb2d726ac96"
}
}
],
"get_payment_status_endpoint": [
{
"response_type": "json",
"response": {
"paid": true,
"preimage": "0000000000000000000000000000000000000000000000000000000000000000",
"details": {
"fee": 50
}
}
}
]
}
}
},
@ -1067,7 +1266,8 @@
}
]
}
]
],
"lnbits": []
}
},
{
@ -1144,6 +1344,33 @@
"response": []
}
]
},
"lnbits": {
"pay_invoice_endpoint": [
{
"request_type": "json",
"request_body": {
"out": true,
"blt11": "lnbc5550n1pnq9jg3sp52rvwstvjcypjsaenzdh0h30jazvzsf8aaye0julprtth9kysxtuspp5e5s3z7felv4t9zrcc6wpn7ehvjl5yzewanzl5crljdl3jgeffyhqdq2f38xy6t5wvxqzjccqpjrzjq0yzeq76ney45hmjlnlpvu0nakzy2g35hqh0dujq8ujdpr2e42pf2rrs6vqpgcsqqqqqqqqqqqqqqeqqyg9qxpqysgqwftcx89k5pp28435pgxfl2vx3ksemzxccppw2j9yjn0ngr6ed7wj8ztc0d5kmt2mvzdlcgrludhz7jncd5l5l9w820hc4clpwhtqj3gq62g66n"
},
"response_type": "json",
"response": {
"detail": "Test Error"
}
}
],
"get_payment_status_endpoint": [
{
"response_type": "json",
"response": {
"paid": true,
"preimage": "0000000000000000000000000000000000000000000000000000000000000000",
"details": {
"fee": 50
}
}
}
]
}
}
},
@ -1225,7 +1452,8 @@
"response": []
}
]
}
},
"lnbits": {}
}
},
{
@ -1306,6 +1534,31 @@
"response": []
}
]
},
"lnbits": {
"pay_invoice_endpoint": [
{
"request_type": "json",
"request_body": {
"out": true,
"blt11": "lnbc5550n1pnq9jg3sp52rvwstvjcypjsaenzdh0h30jazvzsf8aaye0julprtth9kysxtuspp5e5s3z7felv4t9zrcc6wpn7ehvjl5yzewanzl5crljdl3jgeffyhqdq2f38xy6t5wvxqzjccqpjrzjq0yzeq76ney45hmjlnlpvu0nakzy2g35hqh0dujq8ujdpr2e42pf2rrs6vqpgcsqqqqqqqqqqqqqqeqqyg9qxpqysgqwftcx89k5pp28435pgxfl2vx3ksemzxccppw2j9yjn0ngr6ed7wj8ztc0d5kmt2mvzdlcgrludhz7jncd5l5l9w820hc4clpwhtqj3gq62g66n"
},
"response_type": "data",
"response": "data-not-json"
}
],
"get_payment_status_endpoint": [
{
"response_type": "json",
"response": {
"paid": true,
"preimage": "0000000000000000000000000000000000000000000000000000000000000000",
"details": {
"fee": 50
}
}
}
]
}
}
},
@ -1399,6 +1652,28 @@
"response": []
}
]
},
"lnbits": {
"pay_invoice_endpoint": [
{
"request_type": "json",
"request_body": {
"out": true,
"blt11": "lnbc5550n1pnq9jg3sp52rvwstvjcypjsaenzdh0h30jazvzsf8aaye0julprtth9kysxtuspp5e5s3z7felv4t9zrcc6wpn7ehvjl5yzewanzl5crljdl3jgeffyhqdq2f38xy6t5wvxqzjccqpjrzjq0yzeq76ney45hmjlnlpvu0nakzy2g35hqh0dujq8ujdpr2e42pf2rrs6vqpgcsqqqqqqqqqqqqqqeqqyg9qxpqysgqwftcx89k5pp28435pgxfl2vx3ksemzxccppw2j9yjn0ngr6ed7wj8ztc0d5kmt2mvzdlcgrludhz7jncd5l5l9w820hc4clpwhtqj3gq62g66n"
},
"response_type": "response",
"response": {
"response": "Not Found",
"status": 404
}
}
],
"get_payment_status_endpoint": [
{
"response_type": "json",
"response": {}
}
]
}
}
},
@ -1466,6 +1741,16 @@
},
"method": "POST"
}
},
"lnbits": {
"get_invoice_status_endpoint": {
"uri": "/api/v1/payments/e35526a43d04e985594c0dfab848814f524b1c786598ec9a63beddb2d726ac96",
"headers": {
"X-Api-Key": "f171ba022a764e679eef950b21fb1c04",
"User-Agent": "LNbits/Tests"
},
"method": "GET"
}
}
},
"tests": [
@ -1539,6 +1824,16 @@
}
}
]
},
"lnbits": {
"get_invoice_status_endpoint": [
{
"response_type": "json",
"response": {
"paid": true
}
}
]
}
}
},
@ -1591,6 +1886,10 @@
}
}
]
},
"lnbits": {
"description": "lnbits.py doesn't handle the 'failed' status for `get_invoice_status`",
"get_invoice_status_endpoint": []
}
}
},
@ -1738,6 +2037,38 @@
}
}
]
},
"lnbits": {
"get_invoice_status_endpoint": [
{
"description": "no data",
"response_type": "json",
"response": {}
},
{
"description": "pending true",
"response_type": "json",
"response": {
"paid": false,
"details": {
"pending": true
}
}
},
{
"description": "bad json",
"response_type": "data",
"response": "data-not-json"
},
{
"description": "http 404",
"response_type": "response",
"response": {
"response": "Not Found",
"status": 404
}
}
]
}
}
},
@ -1800,6 +2131,16 @@
},
"method": "POST"
}
},
"lnbits": {
"get_payment_status_endpoint": {
"uri": "/api/v1/payments/e35526a43d04e985594c0dfab848814f524b1c786598ec9a63beddb2d726ac96",
"headers": {
"X-Api-Key": "f171ba022a764e679eef950b21fb1c04",
"User-Agent": "LNbits/Tests"
},
"method": "GET"
}
}
},
"tests": [
@ -1879,6 +2220,20 @@
]
}
]
},
"lnbits": {
"get_payment_status_endpoint": [
{
"response_type": "json",
"response": {
"paid": true,
"preimage": "0000000000000000000000000000000000000000000000000000000000000000",
"details": {
"fee": 1000
}
}
}
]
}
}
},
@ -1952,6 +2307,9 @@
]
}
]
},
"lnbits": {
"get_payment_status_endpoint": []
}
}
},
@ -2134,6 +2492,54 @@
}
}
]
},
"lnbits": {
"get_payment_status_endpoint": [
{
"description": "pending true",
"response_type": "json",
"response": {
"paid": false,
"details": {
"pending": true
}
}
},
{
"description": "no data",
"response_type": "json",
"response": {}
},
{
"description": "missing 'paid' field",
"response_type": "json",
"response": {
"details": {
"pending": true
}
}
},
{
"description": "missing 'details' field",
"response_type": "json",
"response": {
"paid": true
}
},
{
"description": "bad json",
"response_type": "data",
"response": "data-not-json"
},
{
"description": "http 404",
"response_type": "response",
"response": {
"response": "Not Found",
"status": 404
}
}
]
}
}
},