Skip to content

Commit 5d9ebd7

Browse files
committed
test(lazer): add ser/de tests
1 parent 395ff14 commit 5d9ebd7

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

lazer/contracts/solana/programs/pyth-lazer-solana-contract/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ no-log-ix-name = []
1919
idl-build = ["anchor-lang/idl-build"]
2020

2121
[dependencies]
22-
pyth-lazer-protocol = { version = "0.1.0", path = "../../../../sdk/rust/protocol" }
22+
pyth-lazer-protocol = { version = "0.1.2", path = "../../../../sdk/rust/protocol" }
2323

2424
anchor-lang = "0.30.1"
2525
bytemuck = "1.20.0"

lazer/sdk/rust/protocol/src/message.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use {
66
};
77

88
/// EVM signature enveope.
9-
#[derive(Debug, Clone)]
9+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1010
pub struct EvmMessage {
1111
pub payload: Vec<u8>,
1212
pub signature: [u8; 64],
@@ -47,7 +47,7 @@ impl EvmMessage {
4747
}
4848

4949
/// Solana signature envelope.
50-
#[derive(Debug, Clone)]
50+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5151
pub struct SolanaMessage {
5252
pub payload: Vec<u8>,
5353
pub signature: [u8; 64],
@@ -87,3 +87,27 @@ impl SolanaMessage {
8787
})
8888
}
8989
}
90+
91+
#[test]
92+
fn test_evm_serde() {
93+
let m1 = EvmMessage {
94+
payload: vec![1, 2, 4, 3],
95+
signature: [5; 64],
96+
recovery_id: 1,
97+
};
98+
let mut buf = Vec::new();
99+
m1.serialize(&mut buf).unwrap();
100+
assert_eq!(m1, EvmMessage::deserialize_slice(&buf).unwrap());
101+
}
102+
103+
#[test]
104+
fn test_solana_serde() {
105+
let m1 = SolanaMessage {
106+
payload: vec![1, 2, 4, 3],
107+
signature: [5; 64],
108+
public_key: [6; 32],
109+
};
110+
let mut buf = Vec::new();
111+
m1.serialize(&mut buf).unwrap();
112+
assert_eq!(m1, SolanaMessage::deserialize_slice(&buf).unwrap());
113+
}

0 commit comments

Comments
 (0)