use mpstthree::binary::struct_trait::{end::End, recv::Recv, send::Send, session::Session}; use mpstthree::meshedchannels::MeshedChannels; use mpstthree::role::Role; use mpstthree::checker_concat; use mpstthree::role::a::RoleA; use mpstthree::role::all_to_b::RoleAlltoB; use mpstthree::role::b::RoleB; use mpstthree::role::b_to_all::RoleBtoAll; 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; use mpstthree::functionmpst::ChooseMpst; use mpstthree::functionmpst::OfferMpst; use petgraph::dot::Dot; // Test our usecase // Simple types // Authenticator = C // Server = A // Client = B type CtoBClose = End; type CtoAClose = End; type CtoBVideo = Recv>; type CtoAVideo = Send>; type AtoCClose = ::Dual; type AtoBClose = End; type AtoCVideo = as Session>::Dual; type BtoAClose = ::Dual; type BtoCClose = ::Dual; type BtoCVideo = as Session>::Dual; // Stacks type StackCEnd = RoleEnd; type StackCVideo = RoleB>>>; type StackCVideoDual = ::Dual; type StackCFull = RoleB>>; type StackAEnd = RoleEnd; type StackAVideo = RoleC>; type StackAVideoDual = ::Dual; type StackAFull = RoleAlltoB; type StackBEnd = RoleEnd; type StackBVideo = RoleC>; type StackBChoice = RoleBtoAll; type StackBFull = RoleC>; // Creating the MP sessions // For C type ChooseBtoC = ChooseMpst, BtoCVideo, AtoCClose, BtoCClose, StackCVideoDual, StackCEnd, NameC>; type ChooseBtoA = ChooseMpst, BtoAClose, CtoAClose, StackAVideoDual, StackAEnd, NameA>; type InitB = Send>>; type EndpointBFull = MeshedChannels, InitB, StackBFull, NameB>; // For A type OfferC = OfferMpst, CtoBVideo, CtoAClose, CtoBClose, StackCVideo, StackCEnd, NameC>; type InitC = Recv>>; type EndpointCFull = MeshedChannels, StackCFull, NameC>; // For B type OfferA = OfferMpst, AtoBClose, AtoCClose, StackAVideo, StackAEnd, NameA>; type EndpointAFull = MeshedChannels, End, StackAFull, NameA>; ///////////////////////////////////////// pub fn main() { let (graphs, kmc) = checker_concat!( "checking_choice", EndpointAFull, EndpointCFull, EndpointBFull ) .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.2\\\"\" ]\n \ 3 [ label = \"\\\"0.3\\\"\" ]\n \ 4 [ label = \"\\\"0.1\\\"\" ]\n \ 0 -> 1 [ label = \"\\\"RoleA?RoleC: i32\\\"\" ]\n \ 1 -> 2 [ label = \"\\\"RoleA!RoleC: i32\\\"\" ]\n \ 2 -> 3 [ label = \"\\\"0\\\"\" ]\n \ 0 -> 4 [ 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 = \"\\\"1\\\"\" ]\n \ 2 [ label = \"\\\"2\\\"\" ]\n \ 3 [ label = \"\\\"2.1\\\"\" ]\n \ 4 [ label = \"\\\"2.2\\\"\" ]\n \ 5 [ label = \"\\\"2.3\\\"\" ]\n \ 6 [ label = \"\\\"2.1\\\"\" ]\n \ 0 -> 1 [ label = \"\\\"RoleB!RoleC: i32\\\"\" ]\n \ 1 -> 2 [ label = \"\\\"RoleB?RoleC: i32\\\"\" ]\n \ 2 -> 3 [ label = \"\\\"RoleB!RoleC: i32\\\"\" ]\n \ 3 -> 4 [ label = \"\\\"RoleB?RoleC: i32\\\"\" ]\n \ 4 -> 5 [ label = \"\\\"0\\\"\" ]\n \ 2 -> 6 [ label = \"\\\"0\\\"\" ]\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.2\\\"\" ]\n \ 5 [ label = \"\\\"2.3\\\"\" ]\n \ 6 [ label = \"\\\"2.4\\\"\" ]\n \ 7 [ label = \"\\\"2.5\\\"\" ]\n \ 8 [ label = \"\\\"2.1\\\"\" ]\n \ 0 -> 1 [ label = \"\\\"RoleC?RoleB: i32\\\"\" ]\n \ 1 -> 2 [ label = \"\\\"RoleC!RoleB: i32\\\"\" ]\n \ 2 -> 3 [ label = \"\\\"RoleC?RoleB: i32\\\"\" ]\n \ 3 -> 4 [ label = \"\\\"RoleC!RoleA: i32\\\"\" ]\n \ 4 -> 5 [ label = \"\\\"RoleC?RoleA: i32\\\"\" ]\n \ 5 -> 6 [ label = \"\\\"RoleC!RoleB: i32\\\"\" ]\n \ 6 -> 7 [ label = \"\\\"0\\\"\" ]\n \ 2 -> 8 [ label = \"\\\"0\\\"\" ]\n\ }\n" ); ////////////// Test KMC number assert_eq!(kmc, Some(1)); }