diff --git a/tests/bruno/e2e/cross-chain-hub/13-node1-send-shutdown-channel.bru b/tests/bruno/e2e/cross-chain-hub/13-node1-send-shutdown-channel.bru new file mode 100644 index 000000000..7208ddb72 --- /dev/null +++ b/tests/bruno/e2e/cross-chain-hub/13-node1-send-shutdown-channel.bru @@ -0,0 +1,45 @@ +meta { + name: 13-node1-send-shutdown-channel + 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": "shutdown_channel", + "params": [ + { + "channel_id": "{{N1N3_CHANNEL_ID}}", + "close_script": { + "code_hash": "0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a", + "hash_type": "data", + "args": "0x0101010101010101010101010101010101010101" + }, + "fee_rate": "0x3FC" + } + ] + } +} + +assert { + res.body.error: isUndefined + res.body.result: isNull +} + +script:post-response { + // Sleep for sometime to make sure current operation finishes before next request starts. + await new Promise(r => setTimeout(r, 100)); +} diff --git a/tests/bruno/e2e/cross-chain-hub/14-node3-send-shutdown-channel.bru b/tests/bruno/e2e/cross-chain-hub/14-node3-send-shutdown-channel.bru new file mode 100644 index 000000000..b384e9c75 --- /dev/null +++ b/tests/bruno/e2e/cross-chain-hub/14-node3-send-shutdown-channel.bru @@ -0,0 +1,40 @@ +meta { + name: 14-node3-send-shutdown-channel + type: http + seq: 14 +} + +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": "shutdown_channel", + "params": [ + { + "channel_id": "{{N1N3_CHANNEL_ID}}", + "close_script": { + "code_hash": "0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a", + "hash_type": "data", + "args": "0x0303030303030303030303030303030303030303" + }, + "fee_rate": "0x3FC" + } + ] + } +} + +script:post-response { + // Sleep for sometime to make sure current operation finishes before next request starts. + await new Promise(r => setTimeout(r, 100)); +} diff --git a/tests/bruno/e2e/cross-chain-hub/15-node3-list-channel.bru b/tests/bruno/e2e/cross-chain-hub/15-node3-list-channel.bru new file mode 100644 index 000000000..f1d5f91a7 --- /dev/null +++ b/tests/bruno/e2e/cross-chain-hub/15-node3-list-channel.bru @@ -0,0 +1,35 @@ +meta { + name: 15-node3-list-channel + type: http + seq: 15 +} + +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 + res.body.result.channels.map(channel => channel.channel_id): notContains {{N1N3_CHANNEL_ID}} +} \ No newline at end of file diff --git a/tests/bruno/e2e/cross-chain-hub/16-node1-list-ln-channel.bru b/tests/bruno/e2e/cross-chain-hub/16-node1-list-ln-channel.bru new file mode 100644 index 000000000..43c759061 --- /dev/null +++ b/tests/bruno/e2e/cross-chain-hub/16-node1-list-ln-channel.bru @@ -0,0 +1,20 @@ +meta { + name: 16-node1-list-ln-channel + type: http + seq: 16 +} + +get { + url: {{LND_BOB_RPC_URL}}/v1/channels + body: json + auth: none +} + +assert { + res.body.channels: length 1 +} + +script:post-response { + console.log("list ln channel result: ", res.body); + bru.setVar("LN_CHANNEL_ID", res.body.channels[0].channel_point.replace(":", "/")); +} diff --git a/tests/bruno/e2e/cross-chain-hub/17-node1-close-ln-channel.bru b/tests/bruno/e2e/cross-chain-hub/17-node1-close-ln-channel.bru new file mode 100644 index 000000000..46b2201ef --- /dev/null +++ b/tests/bruno/e2e/cross-chain-hub/17-node1-close-ln-channel.bru @@ -0,0 +1,33 @@ +meta { + name: 17-node1-close-ln-channel + type: http + seq: 17 +} + +delete { + url: {{LND_BOB_RPC_URL}}/v1/channels/{{LN_CHANNEL_ID}} + body: json + auth: none +} + +script:pre-request { + const axios = require('axios'); + + const url = bru.getEnvVar("LND_BOB_RPC_URL") + "/v1/channels/" + bru.getVar("LN_CHANNEL_ID"); + console.log(url); + + const resp = await axios({ + method: 'DELETE', + url: url, + responseType: 'stream' + }); + resp.data.destroy(); +} + +assert { + res.status: eq 500 +} + +docs { + This is a server-streaming RPC which will block Bruno. The workaround is sending the request in the pre-script so the Bruno request will return 500 because the channel is already closed. +} diff --git a/tests/bruno/e2e/cross-chain-hub/18-node1-list-ln-channel.bru b/tests/bruno/e2e/cross-chain-hub/18-node1-list-ln-channel.bru new file mode 100644 index 000000000..1228fc990 --- /dev/null +++ b/tests/bruno/e2e/cross-chain-hub/18-node1-list-ln-channel.bru @@ -0,0 +1,19 @@ +meta { + name: 18-node1-list-ln-channel + type: http + seq: 18 +} + +get { + url: {{LND_BOB_RPC_URL}}/v1/channels + body: json + auth: none +} + +assert { + res.body.channels: length 0 +} + +script:post-response { + console.log("list channel result: ", res.body); +} \ No newline at end of file