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

update: ensured when a test fails for proxy node, the route actually … #709

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions dist/src/tests/controllers/invoices.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/src/tests/controllers/invoices.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions dist/src/tests/utils/invoices/payInvoice.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/src/tests/utils/invoices/payInvoice.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions src/tests/controllers/invoices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import test from 'ava'
import { createInvoice, getInvoice, payInvoice } from '../utils/invoices'
import nodes from '../nodes'
import * as helpers from '../utils/helpers'
import { getBalance } from '../utils/get'

/*
npx ava src/tests/controllers/invoices.test.ts --verbose --serial --timeout=2m
Expand Down Expand Up @@ -49,6 +50,18 @@ async function invoices(t, node1, node2) {
`Payment should have been made by ${node2.alias} to ${node1.alias}`
)

if (node2.alias.includes('virtualNode') || node2.alias === 'dave') {
const balance = await getBalance(t, node2)
await helpers.sleep(1000)
const invoice = await createInvoice(t, node1, balance + 100, 'test invoice')
const paymentRequest = invoice.response.invoice
await helpers.sleep(1000)
const pay = await payInvoice(t, node2, paymentRequest)
t.false(
pay.success,
'Response is suppose to be false because we have insufficent balance'
)
}
console.log(`${node2.alias} generating invoice to be paid by ${node1.alias}`)

//Create an Invoice by node 2
Expand All @@ -63,9 +76,6 @@ async function invoices(t, node1, node2) {
//Get Invoice details by node 2
const invoiceDetail3 = await getInvoice(t, node2, paymentRequest2)
const invoicePaymentRequest2 = invoiceDetail3.response.payment_request
if (node1.alias === 'alice' && node2.alias === 'virtualNode0') {
console.log(invoiceDetail3)
}
t.truthy(
invoicePaymentRequest2,
`Payment request should exist for ${node2.alias} when testing with ${node1.alias}`
Expand Down
12 changes: 8 additions & 4 deletions src/tests/utils/invoices/payInvoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import http = require('ava-http')
import { makeArgs } from '../../utils/helpers'

export async function payInvoice(t, node, payment_request) {
const v = { payment_request }
const r = await http.put(node.external_ip + '/invoices', makeArgs(node, v))
try {
const v = { payment_request }
const r = await http.put(node.external_ip + '/invoices', makeArgs(node, v))

t.true(r.success, 'Put method should have succeeded')
t.true(r.success, 'Put method should have succeeded')

return r
return r
} catch (error) {
return error.error
}
}