Skip to content

Commit aa13ab5

Browse files
committed
Add tests
1 parent b88837b commit aa13ab5

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

searcher-api-types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
serde = { workspace = true }
8+
serde_json = { workspace = true }
89

910
serde_with = "3.0.0"
1011
alloy-primitives = "0.8"

searcher-api-types/src/beaver.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,33 @@ pub struct BeaverBundle {
3939
#[serde(skip_serializing_if = "Vec::is_empty")]
4040
pub refund_transaction_hashes: Vec<TxHash>,
4141
}
42+
43+
#[cfg(test)]
44+
mod test {
45+
use super::*;
46+
47+
#[test]
48+
fn test_beaver_bundle_default_serialisation() {
49+
assert!(serde_json::to_string(&BeaverBundle::default()).is_ok());
50+
assert_eq!(
51+
serde_json::to_string(&BeaverBundle::default()).unwrap(),
52+
"{\"txs\":[],\"blockNumber\":\"0x0\"}".to_string()
53+
);
54+
55+
assert!(serde_json::to_string(&BeaverBundle {
56+
transactions: vec![],
57+
block_number: 21862873,
58+
..Default::default()
59+
})
60+
.is_ok());
61+
assert_eq!(
62+
serde_json::to_string(&BeaverBundle {
63+
transactions: vec![],
64+
block_number: 21862873,
65+
..Default::default()
66+
})
67+
.unwrap(),
68+
"{\"txs\":[],\"blockNumber\":\"0x14d99d9\"}".to_string()
69+
);
70+
}
71+
}

0 commit comments

Comments
 (0)