diff --git a/crates/bft-json-crdt/bft-crdt-derive/src/lib.rs b/crates/bft-json-crdt/bft-crdt-derive/src/lib.rs index d53acfd..7118722 100644 --- a/crates/bft-json-crdt/bft-crdt-derive/src/lib.rs +++ b/crates/bft-json-crdt/bft-crdt-derive/src/lib.rs @@ -109,6 +109,12 @@ pub fn derive_json_crdt(input: OgTokenStream) -> OgTokenStream { } } + // I'm pulling this out so that we can see actual CRD content in debug output. + // + // The plan is to mostly get rid of the macros anyway, so it's a reasonable first step. + // It could (alternately) be just as good to keep the macros and change this function to + // output actual field content instead of just field names. + // // impl #impl_generics std::fmt::Debug for #ident #ty_generics #where_clause { // fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { // let mut fields = Vec::new(); diff --git a/crates/bft-json-crdt/src/json_crdt.rs b/crates/bft-json-crdt/src/json_crdt.rs index a445efd..638ba71 100644 --- a/crates/bft-json-crdt/src/json_crdt.rs +++ b/crates/bft-json-crdt/src/json_crdt.rs @@ -549,7 +549,7 @@ mod test { #[test] fn test_derive_basic() { #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Player { x: LwwRegisterCrdt, y: LwwRegisterCrdt, @@ -564,14 +564,14 @@ mod test { #[test] fn test_derive_nested() { #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Position { x: LwwRegisterCrdt, y: LwwRegisterCrdt, } #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Player { pos: Position, balance: LwwRegisterCrdt, @@ -589,7 +589,7 @@ mod test { #[test] fn test_lww_ops() { #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Test { a: LwwRegisterCrdt, b: LwwRegisterCrdt, @@ -649,7 +649,7 @@ mod test { #[test] fn test_vec_and_map_ops() { #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Test { a: ListCrdt, } @@ -689,14 +689,14 @@ mod test { #[test] fn test_causal_field_dependency() { #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Item { name: LwwRegisterCrdt, soulbound: LwwRegisterCrdt, } #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Player { inventory: ListCrdt, balance: LwwRegisterCrdt, @@ -755,7 +755,7 @@ mod test { #[test] fn test_2d_grid() { #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Game { grid: ListCrdt>>, } @@ -816,7 +816,7 @@ mod test { #[test] fn test_arb_json() { #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Test { reg: LwwRegisterCrdt, } @@ -852,13 +852,13 @@ mod test { #[test] fn test_wrong_json_types() { #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Nested { list: ListCrdt, } #[add_crdt_fields] - #[derive(Clone, CrdtNode)] + #[derive(Clone, CrdtNode, Debug)] struct Test { reg: LwwRegisterCrdt, strct: ListCrdt, diff --git a/crates/bft-json-crdt/tests/byzantine.rs b/crates/bft-json-crdt/tests/byzantine.rs index f195da1..d2044ec 100644 --- a/crates/bft-json-crdt/tests/byzantine.rs +++ b/crates/bft-json-crdt/tests/byzantine.rs @@ -20,7 +20,7 @@ use serde_json::json; // 5. block actual messages from honest actors (eclipse attack) #[add_crdt_fields] -#[derive(Clone, CrdtNode)] +#[derive(Clone, CrdtNode, Debug)] struct ListExample { list: ListCrdt, } @@ -91,13 +91,13 @@ fn test_forge_update() { } #[add_crdt_fields] -#[derive(Clone, CrdtNode)] +#[derive(Clone, CrdtNode, Debug)] struct Nested { a: Nested2, } #[add_crdt_fields] -#[derive(Clone, CrdtNode)] +#[derive(Clone, CrdtNode, Debug)] struct Nested2 { b: LwwRegisterCrdt, }