Skip to content

Commit

Permalink
test(lazer): add ser/de tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Riateche committed Dec 10, 2024
1 parent 395ff14 commit 7676668
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions lazer/sdk/rust/protocol/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {
};

/// EVM signature enveope.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct EvmMessage {
pub payload: Vec<u8>,
pub signature: [u8; 64],
Expand Down Expand Up @@ -47,7 +47,7 @@ impl EvmMessage {
}

/// Solana signature envelope.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SolanaMessage {
pub payload: Vec<u8>,
pub signature: [u8; 64],
Expand Down Expand Up @@ -87,3 +87,27 @@ impl SolanaMessage {
})
}
}

#[test]
fn test_evm_serde() {
let m1 = EvmMessage {
payload: vec![1, 2, 4, 3],
signature: [5; 64],
recovery_id: 1,
};
let mut buf = Vec::new();
m1.serialize(&mut buf).unwrap();
assert_eq!(m1, EvmMessage::deserialize_slice(&buf).unwrap());
}

#[test]
fn test_solana_serde() {
let m1 = SolanaMessage {
payload: vec![1, 2, 4, 3],
signature: [5; 64],
public_key: [6; 32],
};
let mut buf = Vec::new();
m1.serialize(&mut buf).unwrap();
assert_eq!(m1, SolanaMessage::deserialize_slice(&buf).unwrap());
}

0 comments on commit 7676668

Please sign in to comment.