Skip to content

Commit

Permalink
Fix failed test caused by channel closed status change
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Feb 20, 2025
1 parent a6d6618 commit b8700af
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/fiber/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3504,7 +3504,11 @@ pub enum ChannelState {

impl ChannelState {
fn is_closed(&self) -> bool {
matches!(self, ChannelState::Closed(_))
matches!(
self,
ChannelState::Closed(_)
| ChannelState::ShuttingDown(ShuttingDownFlags::WAITING_COMMITMENT_CONFIRMATION)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
meta {
name: get channels from node1
type: http
seq: 21
}

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}}",
"include_closed": true
}
]
}
}

script:pre-request {
await new Promise(r => setTimeout(r, 2000));
}

assert {
res.status: eq 200
}

script:post-response {
await new Promise(r => setTimeout(r, 1000));
console.log("step 21 list channels: ", res.body.result.channels);
// should list all channels including the closed one
let channel = res.body.result.channels[0];
console.log("channel: ", channel);
let expect_channel_id = bru.getVar("CHANNEL_ID");
console.log("expect_channel_id: ", expect_channel_id);
if (!channel || channel.channel_id != expect_channel_id) {
throw new Error("channel not found");
}
if (channel.state.state_name != "SHUTTING_DOWN" && channel.state.state_flags != "WAITING_COMMITMENT_CONFIRMATION") {
throw new Error("channel state is not right");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
meta {
name: generate a few epochs
type: http
seq: 22
}

post {
url: {{CKB_RPC_URL}}
body: json
auth: none
}

headers {
Content-Type: application/json
Accept: application/json
}

body:json {
{
"id": 42,
"jsonrpc": "2.0",
"method": "generate_epochs",
"params": ["0x2"]
}
}

assert {
res.status: eq 200
}

script:post-response {
await new Promise(r => setTimeout(r, 5000));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
meta {
name: get channels from node1
type: http
seq: 23
}

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}}",
"include_closed": true
}
]
}
}

script:pre-request {
await new Promise(r => setTimeout(r, 2000));
}

assert {
res.status: eq 200
}

script:post-response {
await new Promise(r => setTimeout(r, 1000));
console.log("step 23 list channels: ", res.body.result.channels);
// should list all channels including the closed one
let channel = res.body.result.channels[0];
console.log("channel: ", channel);
let expect_channel_id = bru.getVar("CHANNEL_ID");
console.log("expect_channel_id: ", expect_channel_id);
if (!channel || channel.channel_id != expect_channel_id) {
throw new Error("channel not found");
}
if (channel.state.state_name != "CLOSED" && channel.state.state_flags != "COOPERATIVE") {
throw new Error("channel state is not right");
}
}

0 comments on commit b8700af

Please sign in to comment.