-
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
Showing
7 changed files
with
240 additions
and
10 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
37 changes: 37 additions & 0 deletions
37
tests/bruno/e2e/cross-chain-hub/03-node1-connect-node3.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,37 @@ | ||
meta { | ||
name: 03-node1-connect-node3 | ||
type: http | ||
seq: 3 | ||
} | ||
|
||
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": "connect_peer", | ||
"params": [ | ||
{"address": "{{NODE3_ADDR}}"} | ||
] | ||
} | ||
} | ||
|
||
assert { | ||
res.body.error: isUndefined | ||
res.body.result: isNull | ||
} | ||
|
||
script:post-response { | ||
// Dialing a peer is async in tentacle. Sleep for some time to make sure | ||
// we're connected to the peer. | ||
await new Promise(r => setTimeout(r, 1000)); | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/bruno/e2e/cross-chain-hub/04-node1-open-channel-to-node3.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,48 @@ | ||
meta { | ||
name: 04-node1-open-channel-to-node3 | ||
type: http | ||
seq: 4 | ||
} | ||
|
||
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": "open_channel", | ||
"params": [ | ||
{ | ||
"peer_id": "{{NODE3_PEERID}}", | ||
"funding_amount": "0x2710", | ||
"funding_udt_type_script": { | ||
"code_hash": "0xe1e354d6d643ad42724d40967e334984534e0367405c5ae42a9d7d63d77df419", | ||
"hash_type": "data1", | ||
"args": "0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
|
||
assert { | ||
res.body.error: isUndefined | ||
res.body.result.temporary_channel_id: isDefined | ||
} | ||
|
||
script:post-response { | ||
await new Promise(r => setTimeout(r, 1000)); | ||
console.log("N1N3 response: ", res.body); | ||
console.log("N1N3 response: ", res.body.result.temporary_channel_id); | ||
bru.setVar("N1N3_TEMP_CHANNEL_ID", res.body.result.temporary_channel_id); | ||
} |
41 changes: 41 additions & 0 deletions
41
tests/bruno/e2e/cross-chain-hub/05-node3-accept-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,41 @@ | ||
meta { | ||
name: 05-node3-accept-channel | ||
type: http | ||
seq: 5 | ||
} | ||
|
||
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": "list_channels", | ||
"params": [ | ||
{ | ||
"peer_id": "{{NODE1_PEERID}}" | ||
} | ||
] | ||
} | ||
} | ||
|
||
assert { | ||
res.body.error: isUndefined | ||
res.body.result.channels: isDefined | ||
} | ||
|
||
script:post-response { | ||
// Sleep for sometime to make sure current operation finishes before next request starts. | ||
await new Promise(r => setTimeout(r, 2000)); | ||
console.log("accept channel result: ", res.body); | ||
bru.setVar("N1N3_CHANNEL_ID", res.body.result.channels[0].channel_id); | ||
} |
55 changes: 55 additions & 0 deletions
55
tests/bruno/e2e/cross-chain-hub/06-ckb-generate-blocks.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,55 @@ | ||
meta { | ||
name: 06-ckb-generate-blocks | ||
type: http | ||
seq: 6 | ||
} | ||
|
||
post { | ||
url: {{CKB_RPC_URL}} | ||
body: json | ||
auth: none | ||
} | ||
|
||
headers { | ||
Content-Type: application/json | ||
Accept: application/json | ||
} | ||
|
||
body:json { | ||
{ | ||
"id": {{iteration}}, | ||
"jsonrpc": "2.0", | ||
"method": "generate_block", | ||
"params": [] | ||
} | ||
} | ||
|
||
vars:post-response { | ||
max_iterations: 10 | ||
} | ||
|
||
assert { | ||
res.status: eq 200 | ||
} | ||
|
||
script:pre-request { | ||
// Script taken from https://github.com/usebruno/bruno/discussions/385#discussioncomment-8015350 | ||
// This does not seem to work. | ||
if(bru.getVar("iteration") === undefined){ | ||
console.log("Started generating blocks for channel 2..."); | ||
bru.setVar("iteration", 0); | ||
} | ||
} | ||
|
||
script:post-response { | ||
if(bru.getVar("iteration") < bru.getVar("max_iterations") -1){ | ||
bru.setVar("iteration", bru.getVar("iteration") + 1); | ||
// This is the name of this bruno file, set this to continue generating blocks. | ||
bru.setNextRequest("06-ckb-generate-blocks"); | ||
} else { | ||
// Don't know why it takes so long for funding transaction to be confirmed. | ||
await new Promise(r => setTimeout(r, 5000)); | ||
} | ||
await new Promise(r => setTimeout(r, 10)); | ||
console.log("Generated the " + bru.getVar("iteration") + "th block"); | ||
} |
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,49 @@ | ||
meta { | ||
name: 07-node1-add-tlc | ||
type: http | ||
seq: 7 | ||
} | ||
|
||
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": "add_tlc", | ||
"params": [ | ||
{ | ||
"channel_id": "{{N1N3_CHANNEL_ID}}", | ||
"amount": "0x1388", | ||
"payment_hash": "{{PAYMENT_HASH}}", | ||
"expiry": 40 | ||
} | ||
] | ||
} | ||
} | ||
|
||
assert { | ||
res.body.error: isUndefined | ||
res.body.result.tlc_id: isDefined | ||
} | ||
|
||
script:pre-request { | ||
console.log("sending node1 AddTlc:", bru.getVar("payment_hash")); | ||
console.log("amount: ", bru.getVar("payment_amount")); | ||
} | ||
|
||
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("response from node1 AddTlc:", res.body); | ||
bru.setVar("N1N3_TLC_ID1", res.body.result.tlc_id); | ||
} |