-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a482523
commit 8121c9d
Showing
14 changed files
with
451 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/bruno/e2e/router-pay/11-node2-list-graph-channels.bru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
meta { | ||
name: get channels from node2 | ||
type: http | ||
seq: 11 | ||
} | ||
|
||
post { | ||
url: {{NODE2_RPC_URL}} | ||
body: json | ||
auth: none | ||
} | ||
|
||
headers { | ||
Content-Type: application/json | ||
Accept: application/json | ||
} | ||
|
||
body:json { | ||
{ | ||
"id": 42, | ||
"jsonrpc": "2.0", | ||
"method": "graph_channels", | ||
"params": [ | ||
{ } | ||
] | ||
} | ||
} | ||
|
||
|
||
assert { | ||
res.status: eq 200 | ||
} | ||
|
||
script:post-response { | ||
await new Promise(r => setTimeout(r, 1000)); | ||
console.log("step 11 list graph channels: ", res.body.result.channels); | ||
if (res.body.result.channels.length != 2) { | ||
throw new Error("graph channels length is not right"); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
tests/bruno/e2e/router-pay/24-node1-gen-invoice-for-self.bru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
meta { | ||
name: generate a invoice | ||
type: http | ||
seq: 24 | ||
} | ||
|
||
post { | ||
url: {{NODE1_RPC_URL}} | ||
body: json | ||
auth: none | ||
} | ||
|
||
headers { | ||
Content-Type: application/json | ||
Accept: application/json | ||
} | ||
|
||
body:json { | ||
{ | ||
"id": "42", | ||
"jsonrpc": "2.0", | ||
"method": "new_invoice", | ||
"params": [ | ||
{ | ||
"amount": "0x613ae650", | ||
"currency": "Fibd", | ||
"description": "test invoice generated by node1", | ||
"expiry": "0xe10", | ||
"final_expiry_delta": "0x28", | ||
"payment_preimage": "{{payment_preimage}}" | ||
} | ||
] | ||
} | ||
} | ||
|
||
assert { | ||
res.body.error: isUndefined | ||
res.body.result: isDefined | ||
} | ||
|
||
script:pre-request { | ||
// generate random preimage | ||
function generateRandomPreimage() { | ||
let hash = '0x'; | ||
for (let i = 0; i < 64; i++) { | ||
hash += Math.floor(Math.random() * 16).toString(16); | ||
} | ||
return hash; | ||
} | ||
const payment_preimage = generateRandomPreimage(); | ||
bru.setVar("payment_preimage", payment_preimage); | ||
let hash_algorithm = bru.getEnvVar("HASH_ALGORITHM"); | ||
if (hash_algorithm !== null) { | ||
let body = req.getBody(); | ||
body.params[0].hash_algorithm = hash_algorithm; | ||
req.setBody(body); | ||
} | ||
} | ||
|
||
script:post-response { | ||
// Sleep for sometime to make sure current operation finishes before next request starts. | ||
await new Promise(r => setTimeout(r, 100)); | ||
bru.setVar("payment_hash_self", res.body.result.invoice.data.payment_hash); | ||
console.log("generated result: ", res.body.result); | ||
bru.setVar("encoded_invoice_self", res.body.result.invoice_address); | ||
} |
45 changes: 45 additions & 0 deletions
45
tests/bruno/e2e/router-pay/25-node1-pay-self-with-node2-err.bru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
meta { | ||
name: Node1 send payment with router | ||
type: http | ||
seq: 25 | ||
} | ||
|
||
post { | ||
url: {{NODE1_RPC_URL}} | ||
body: json | ||
auth: none | ||
} | ||
|
||
headers { | ||
Content-Type: application/json | ||
Accept: application/json | ||
} | ||
|
||
body:json { | ||
{ | ||
"id": "42", | ||
"jsonrpc": "2.0", | ||
"method": "send_payment", | ||
"params": [ | ||
{ | ||
"invoice": "{{encoded_invoice_self}}", | ||
"allow_self_payment": true | ||
} | ||
] | ||
} | ||
} | ||
|
||
assert { | ||
res.body.error: isDefined | ||
} | ||
|
||
script:post-response { | ||
// Sleep for sometime to make sure current operation finishes before next request starts. | ||
await new Promise(r => setTimeout(r, 100)); | ||
console.log("25 step result: ", res.body); | ||
// for pay self router A -> B -> A, can not use the same channel from A -> B and B -> A | ||
if (!(res.body.error.message.includes("Failed to build route"))) { | ||
throw new Error("Assertion failed: error message is not right"); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
tests/bruno/e2e/router-pay/26-node2-node1-open-channel.bru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
meta { | ||
name: Node2 open a channel to Node1 | ||
type: http | ||
seq: 26 | ||
} | ||
|
||
post { | ||
url: {{NODE2_RPC_URL}} | ||
body: json | ||
auth: none | ||
} | ||
|
||
headers { | ||
Content-Type: application/json | ||
Accept: application/json | ||
} | ||
|
||
body:json { | ||
{ | ||
"id": "42", | ||
"jsonrpc": "2.0", | ||
"method": "open_channel", | ||
"params": [ | ||
{ | ||
"peer_id": "{{NODE1_PEERID}}", | ||
"funding_amount": "0x277aab54d000", | ||
"public": true, | ||
"tlc_fee_proportional_millionths": "0x4B0" | ||
} | ||
] | ||
} | ||
} | ||
|
||
assert { | ||
res.body.error: isUndefined | ||
res.body.result.temporary_channel_id: isDefined | ||
} | ||
|
||
script:pre-request { | ||
await new Promise(r => setTimeout(r, 1000)); | ||
} | ||
|
||
script:post-response { | ||
await new Promise(r => setTimeout(r, 1000)); | ||
console.log("26 step result: ", res.body); | ||
} |
Oops, something went wrong.