#![allow(dead_code)] use mpstthree::binary::struct_trait::end::End; use mpstthree::binary::struct_trait::recv::Recv; use mpstthree::binary::struct_trait::send::Send; use mpstthree::role::broadcast::RoleBroadcast; use mpstthree::role::end::RoleEnd; use mpstthree::{ checker_concat, checker_concat_impl, create_meshedchannels, create_multiple_normal_name, create_multiple_normal_role, }; use petgraph::dot::Dot; // Create new MeshedChannels create_meshedchannels!(MeshedChannels, 2); // Create new roles create_multiple_normal_role!( RoleA, RoleADual | RoleB, RoleBDual | ); // Create new names create_multiple_normal_name!(NameA, NameB); // Types // A type Choose0fromAtoB = Send; type Choose1fromAtoB = Send; type Choose2fromAtoB = Send; type Offer3BfromA = Recv; enum Branches3AfromB { B(MeshedChannels), C(MeshedChannels), D(MeshedChannels), E(MeshedChannels), } // B type Offer0BfromA = Recv; enum Branches0BfromA { A(MeshedChannels, NameB>), B(MeshedChannels, NameB>), } type Offer1BfromA = Recv; enum Branches1BfromA { C(MeshedChannels), E(MeshedChannels), } type Offer2BfromA = Recv; enum Branches2BfromA { F(MeshedChannels), G(MeshedChannels), } type Choose3fromBtoA = Send; // Creating the MP sessions // For A type EndpointAEnd = MeshedChannels; type EndpointAOfferBCDE = MeshedChannels, NameA>; type EndpointAChoiceFG = MeshedChannels; type EndpointAChoiceCE = MeshedChannels; type EndpointAFull = MeshedChannels; // For B type EndpointBEnd = MeshedChannels; type EndpointBFull = MeshedChannels, NameB>; ///////////////////////////////////////// checker_concat_impl!( [Branches0BfromA, A], [Branches0BfromA, B], [Branches1BfromA, C], [Branches1BfromA, E], [Branches2BfromA, F], [Branches2BfromA, G], [Branches3AfromB, B], [Branches3AfromB, C], [Branches3AfromB, D], [Branches3AfromB, E] ); pub fn main() { let (graphs, kmc) = checker_concat!( "two_peers_branchings_sync", EndpointAFull, EndpointBFull => [ EndpointAChoiceFG, Branches0BfromA, A ], [ EndpointAChoiceCE, Branches0BfromA, B ], [ EndpointAEnd, Branches1BfromA, C ], [ EndpointAOfferBCDE, Branches1BfromA, E ], [ EndpointAEnd, Branches2BfromA, F ], [ EndpointAEnd, Branches2BfromA, G ], [ EndpointBEnd, Branches3AfromB, B ], [ EndpointBEnd, Branches3AfromB, C ], [ EndpointBEnd, Branches3AfromB, D ], [ EndpointBEnd, Branches3AfromB, E ] ) .unwrap(); ////////////// Test graph A let graph_a = &graphs["RoleA"]; assert_eq!( format!("{:?}", Dot::new(&graph_a)), "digraph {\n \ 0 [ label = \"\\\"0\\\"\" ]\n \ 1 [ label = \"\\\"0.0.1\\\"\" ]\n \ 2 [ label = \"\\\"0.0.1\\\"\" ]\n \ 3 [ label = \"\\\"0.0.1\\\"\" ]\n \ 4 [ label = \"\\\"0.0.0.1\\\"\" ]\n \ 5 [ label = \"\\\"0.0.0.1\\\"\" ]\n \ 6 [ label = \"\\\"0.0.0.1\\\"\" ]\n \ 7 [ label = \"\\\"0.0.0.1\\\"\" ]\n \ 0 -> 1 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 2 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 3 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 4 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 5 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 6 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 7 [ label = \"\\\"0\\\"\" ]\n\ }\n" ); ////////////// Test graph B let graph_b = &graphs["RoleB"]; assert_eq!( format!("{:?}", Dot::new(&graph_b)), "digraph {\n \ 0 [ label = \"\\\"0\\\"\" ]\n \ 1 [ label = \"\\\"0.0.1\\\"\" ]\n \ 2 [ label = \"\\\"0.0.1\\\"\" ]\n \ 3 [ label = \"\\\"0.0.1\\\"\" ]\n \ 4 [ label = \"\\\"0.0.0.1\\\"\" ]\n \ 5 [ label = \"\\\"0.0.0.1\\\"\" ]\n \ 6 [ label = \"\\\"0.0.0.1\\\"\" ]\n \ 7 [ label = \"\\\"0.0.0.1\\\"\" ]\n \ 0 -> 1 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 2 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 3 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 4 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 5 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 6 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 7 [ label = \"\\\"0\\\"\" ]\n\ }\n" ); ////////////// Test KMC output assert_eq!(kmc, Some(1)); }