forked from nervosnetwork/fiber
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
10 changed files
with
165 additions
and
251 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
tests/bruno/e2e/cross-chain-hub/09-create-fiber-invoice.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,52 @@ | ||
meta { | ||
name: 09-create-fiber-invoice | ||
type: http | ||
seq: 9 | ||
} | ||
|
||
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": "0x1", | ||
"currency": "Fibd", | ||
"description": "test invoice", | ||
"udt_type_script": { | ||
"args": "0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947", | ||
"code_hash": "0xe1e354d6d643ad42724d40967e334984534e0367405c5ae42a9d7d63d77df419", | ||
"hash_type": "data1" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
|
||
assert { | ||
res.status: eq 200 | ||
res.body.error: isUndefined | ||
res.body.result.invoice_address: isDefined | ||
res.body.result.invoice.data.payment_hash: isDefined | ||
} | ||
|
||
script:post-response { | ||
bru.setVar("FIBER_PAY_REQ", res.body.result.invoice_address); | ||
bru.setVar("PAYMENT_HASH", res.body.result.invoice.data.payment_hash); | ||
} | ||
|
||
docs { | ||
Create a fiber invoice to receive money | ||
} |
61 changes: 0 additions & 61 deletions
61
tests/bruno/e2e/cross-chain-hub/09-create-receive-btc-order.bru
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
tests/bruno/e2e/cross-chain-hub/10-create-receive-btc-order.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,44 @@ | ||
meta { | ||
name: 10-create-receive-btc-order | ||
type: http | ||
seq: 10 | ||
} | ||
|
||
post { | ||
url: {{NODE3_RPC_URL}} | ||
body: json | ||
auth: none | ||
} | ||
|
||
headers { | ||
Content-Type: application/json | ||
Accept: application/json | ||
} | ||
|
||
body:json { | ||
{ | ||
"id": "42", | ||
"jsonrpc": "2.0", | ||
"method": "receive_btc", | ||
"params": [ | ||
{ | ||
"fiber_pay_req": "{{FIBER_PAY_REQ}}" | ||
} | ||
] | ||
} | ||
} | ||
|
||
assert { | ||
res.status: eq 200 | ||
res.body.error: isUndefined | ||
res.body.result.btc_pay_req: isDefined | ||
} | ||
|
||
script:post-response { | ||
bru.setVar("BTC_PAY_REQ", res.body.result.btc_pay_req); | ||
console.log(res.body.result.btc_pay_req); | ||
} | ||
|
||
docs { | ||
CKB user requests a BTC invoice to receive BTC from Bitcoin user. | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...2e/cross-chain-hub/10-pay-btc-invoice.bru → ...2e/cross-chain-hub/12-pay-btc-invoice.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
meta { | ||
name: 10-pay-btc-invoice | ||
name: 12-pay-btc-invoice | ||
type: http | ||
seq: 10 | ||
seq: 12 | ||
} | ||
|
||
post { | ||
|
38 changes: 0 additions & 38 deletions
38
tests/bruno/e2e/cross-chain-hub/12-remove-tlc-for-receive-btc-order.bru
This file was deleted.
Oops, something went wrong.
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: 13-get-invoice-status | ||
type: http | ||
seq: 13 | ||
} | ||
|
||
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": "get_invoice", | ||
"params": [ | ||
{ | ||
"payment_hash": "{{PAYMENT_HASH}}" | ||
} | ||
] | ||
} | ||
} | ||
|
||
assert { | ||
res.body.error: isUndefined | ||
res.body.result.status: isDefined | ||
} | ||
|
||
|
||
script:pre-request { | ||
if(bru.getVar("iteration") === undefined){ | ||
bru.setVar("iteration", 0); | ||
} | ||
} | ||
|
||
vars:post-response { | ||
max_iterations: 20 | ||
} | ||
|
||
script:post-response { | ||
const i = bru.getVar("iteration"); | ||
const n = bru.getVar("max_iterations"); | ||
if (i < n) { | ||
console.log(`Try ${i+1}/${n}`); | ||
console.log(res.body) | ||
} | ||
|
||
if (res.body.result.status != "Paid") { | ||
console.log("Invoicee is paid"); | ||
bru.setVar("iteration", 0); | ||
} else if (i+1 < n) { | ||
await new Promise(r => setTimeout(r, 100)); | ||
bru.setVar("iteration", i + 1); | ||
bru.setNextRequest("12-get-invoice-status"); | ||
} else { | ||
bru.setVar("iteration", 0); | ||
throw new Error("Bob has not received the payment"); | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
tests/bruno/e2e/cross-chain-hub/13-node1-send-shutdown-channel.bru
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.