Skip to content

Commit

Permalink
fix tag issue for bincode
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Nov 16, 2024
1 parent 18bd9a8 commit 5257ba8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/fiber/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2295,11 +2295,6 @@ enum CommitmentSignedFlags {
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(
rename_all = "SCREAMING_SNAKE_CASE",
tag = "state_name",
content = "state_flags"
)]
pub enum ChannelState {
/// We are negotiating the parameters required for the channel prior to funding it.
NegotiatingFunding(NegotiatingFundingFlags),
Expand Down
16 changes: 16 additions & 0 deletions src/tests/store.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use crate::fiber::channel::AwaitingChannelReadyFlags;
use crate::fiber::channel::ChannelState;
use crate::fiber::channel::SigningCommitmentFlags;
use crate::fiber::config::AnnouncedNodeName;
use crate::fiber::graph::ChannelInfo;
use crate::fiber::graph::NetworkGraphStateStore;
Expand Down Expand Up @@ -224,3 +227,16 @@ fn test_store_wacthtower() {
store.remove_watch_channel(channel_id);
assert_eq!(store.get_watch_channels(), vec![]);
}

#[test]
fn test_channel_state_serialize() {
let state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::CHANNEL_READY);
let bincode_encoded = bincode::serialize(&state).unwrap();
let new_state: ChannelState = bincode::deserialize(&bincode_encoded).unwrap();
assert_eq!(state, new_state);

let flags = SigningCommitmentFlags::COMMITMENT_SIGNED_SENT;
let bincode_encoded = bincode::serialize(&flags).unwrap();
let new_flags: SigningCommitmentFlags = bincode::deserialize(&bincode_encoded).unwrap();
assert_eq!(flags, new_flags);
}

0 comments on commit 5257ba8

Please sign in to comment.