File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ edition = "2021"
55
66[dependencies ]
77serde = { workspace = true }
8+ serde_json = { workspace = true }
89
910serde_with = " 3.0.0"
1011alloy-primitives = " 0.8"
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments