use mpstthree::binary::struct_trait::{end::End, recv::Recv, send::Send, session::Session}; use mpstthree::meshedchannels::MeshedChannels; use mpstthree::role::broadcast::RoleBroadcast; use mpstthree::{checker_concat, checker_concat_impl}; use petgraph::dot::Dot; // Get roles use mpstthree::role::a::RoleA; use mpstthree::role::b::RoleB; use mpstthree::role::c::RoleC; use mpstthree::role::end::RoleEnd; use mpstthree::name::a::NameA; use mpstthree::name::b::NameB; use mpstthree::name::c::NameC; // Test our usecase // Simple types // Client = B // Authenticator = C // Server = A type CtoBClose = End; type CtoAClose = End; type CtoAVideo = Send>; type CtoBVideo = Recv>; type InitC = Recv>; type AtoCClose = ::Dual; type AtoBClose = End; type AtoCVideo = ::Dual; type RecursCtoB = Recv; type RecursAtoB = Recv; enum Branches0CtoB { End(MeshedChannels), Video(MeshedChannels), } enum Branches0AtoB { End(MeshedChannels), Video(MeshedChannels), } type Choose0fromBtoC = Send; type Choose0fromBtoA = Send; type InitB = Send>; // Stacks type StackCEnd = RoleEnd; type StackCVideo = RoleB>>>>; type StackCInit = RoleB>>; type StackAEnd = RoleEnd; type StackAVideo = RoleC>>; type StackARecurs = RoleB; type StackBRecurs = RoleBroadcast; type StackBFull = RoleC>; // Creating the MP sessions // For B type EndpointBEnd = MeshedChannels; type EndpointBFull = MeshedChannels; // For C type EndpointCFull = MeshedChannels; // For A type EndpointARecurs = MeshedChannels; ///////////////////////////////////////// checker_concat_impl!( [Branches0AtoB, Video, Branches0CtoB, Video], [Branches0AtoB, End, Branches0CtoB, End] ); pub fn main() { let (graphs, kmc) = checker_concat!( "checking_recursion", EndpointARecurs, EndpointCFull, EndpointBFull => [ EndpointBFull, Branches0AtoB, Video, Branches0CtoB, Video ], [ EndpointBEnd, Branches0AtoB, End, Branches0CtoB, End ] ) .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.1\\\"\" ]\n \ 2 [ label = \"\\\"0.1\\\"\" ]\n \ 3 [ label = \"\\\"0.2\\\"\" ]\n \ 0 -> 1 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 2 [ label = \"\\\"RoleA?RoleC: i32\\\"\" ]\n \ 2 -> 3 [ label = \"\\\"RoleA!RoleC: i32\\\"\" ]\n \ 3 -> 0 [ label = \"\\\"µ\\\"\" ]\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 = \"\\\"1\\\"\" ]\n \ 2 [ label = \"\\\"2\\\"\" ]\n \ 3 [ label = \"\\\"2.1\\\"\" ]\n \ 4 [ label = \"\\\"2.1\\\"\" ]\n \ 5 [ label = \"\\\"2.2\\\"\" ]\n \ 0 -> 1 [ label = \"\\\"RoleB!RoleC: i32\\\"\" ]\n \ 1 -> 2 [ label = \"\\\"RoleB?RoleC: i32\\\"\" ]\n \ 2 -> 3 [ label = \"\\\"0\\\"\" ]\n \ 2 -> 4 [ label = \"\\\"RoleB!RoleC: i32\\\"\" ]\n \ 4 -> 5 [ label = \"\\\"RoleB?RoleC: i32\\\"\" ]\n \ 5 -> 2 [ label = \"\\\"µ\\\"\" ]\n\ }\n" ); ////////////// Test graph C let graph_c = &graphs["RoleC"]; assert_eq!( format!("{:?}", Dot::new(&graph_c)), "digraph {\n \ 0 [ label = \"\\\"0\\\"\" ]\n \ 1 [ label = \"\\\"1\\\"\" ]\n \ 2 [ label = \"\\\"2\\\"\" ]\n \ 3 [ label = \"\\\"2.1\\\"\" ]\n \ 4 [ label = \"\\\"2.1\\\"\" ]\n \ 5 [ label = \"\\\"2.2\\\"\" ]\n \ 6 [ label = \"\\\"2.3\\\"\" ]\n \ 7 [ label = \"\\\"2.4\\\"\" ]\n \ 0 -> 1 [ label = \"\\\"RoleC?RoleB: i32\\\"\" ]\n \ 1 -> 2 [ label = \"\\\"RoleC!RoleB: i32\\\"\" ]\n \ 2 -> 3 [ label = \"\\\"0\\\"\" ]\n \ 2 -> 4 [ label = \"\\\"RoleC?RoleB: i32\\\"\" ]\n \ 4 -> 5 [ label = \"\\\"RoleC!RoleA: i32\\\"\" ]\n \ 5 -> 6 [ label = \"\\\"RoleC?RoleA: i32\\\"\" ]\n \ 6 -> 7 [ label = \"\\\"RoleC!RoleB: i32\\\"\" ]\n \ 7 -> 2 [ label = \"\\\"µ\\\"\" ]\n\ }\n" ); ////////////// Test KMC number assert_eq!(kmc, Some(1)); }