| 1 | /* |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | pub(crate) struct TestFixture { |
| 9 | pub(crate) dag: &'static str, |
| 10 | pub(crate) messages: &'static [(&'static str, &'static str)], |
| 11 | pub(crate) heads: &'static [&'static str], |
| 12 | pub(crate) reserve: &'static [&'static str], |
| 13 | pub(crate) ancestors: &'static [(&'static str, &'static str)], |
| 14 | pub(crate) missing: &'static [&'static str], |
| 15 | } |
| 16 | |
| 17 | pub(crate) const BASIC: TestFixture = TestFixture { |
| 18 | dag: "A-B-C", |
| 19 | messages: &[], |
| 20 | heads: &["C"], |
| 21 | reserve: &[], |
| 22 | ancestors: &[], |
| 23 | missing: &[], |
| 24 | }; |
| 25 | |
| 26 | pub(crate) const BRANCHES_AND_MERGES: TestFixture = TestFixture { |
| 27 | dag: r#" |
| 28 | T /---------------N--O---\ T |
| 29 | / / \ \ |
| 30 | /----E-F-\ /-------L--M--------P--\ S--U---\ |
| 31 | A-B-C-D------G--H--I--J--K---------------Q--R---------V--W |
| 32 | \--N |
| 33 | "#, |
| 34 | messages: &[], |
| 35 | heads: &["W"], |
| 36 | reserve: &[], |
| 37 | ancestors: &[], |
| 38 | missing: &[], |
| 39 | }; |
| 40 | |
| 41 | pub(crate) const OCTOPUS_BRANCH_AND_MERGE: TestFixture = TestFixture { |
| 42 | dag: r#" |
| 43 | /-----\ |
| 44 | / \ |
| 45 | D /--C--\ I |
| 46 | / /---D---\ \ |
| 47 | A-B----E----H-J |
| 48 | \---F---/ / |
| 49 | \--G--/ F |
| 50 | "#, |
| 51 | messages: &[], |
| 52 | heads: &["J"], |
| 53 | reserve: &[], |
| 54 | ancestors: &[], |
| 55 | missing: &[], |
| 56 | }; |
| 57 | |
| 58 | pub(crate) const RESERVED_COLUMN: TestFixture = TestFixture { |
| 59 | dag: r#" |
| 60 | A-B-C-F-G----\ |
| 61 | D-E-/ \-W \-X-Y-Z |
| 62 | "#, |
| 63 | messages: &[], |
| 64 | heads: &["W", "Z"], |
| 65 | reserve: &["G"], |
| 66 | ancestors: &[], |
| 67 | missing: &[], |
| 68 | }; |
| 69 | |
| 70 | pub(crate) const ANCESTORS: TestFixture = TestFixture { |
| 71 | dag: r#" |
| 72 | A----B-D-----E----------F-\ |
| 73 | \-C--/ \-W \-X \-Y-Z |
| 74 | "#, |
| 75 | messages: &[], |
| 76 | heads: &["W", "X", "Z"], |
| 77 | reserve: &["F"], |
| 78 | ancestors: &[("C", "A"), ("D", "C"), ("E", "D"), ("F", "E")], |
| 79 | missing: &[], |
| 80 | }; |
| 81 | |
| 82 | pub(crate) const SPLIT_PARENTS: TestFixture = TestFixture { |
| 83 | dag: r#" |
| 84 | /-B-\ A-\ |
| 85 | A D-E B--E |
| 86 | \-C-/ C-/ |
| 87 | "#, |
| 88 | messages: &[], |
| 89 | heads: &["E"], |
| 90 | reserve: &["B", "D", "C"], |
| 91 | ancestors: &[("E", "A"), ("E", "B")], |
| 92 | missing: &[], |
| 93 | }; |
| 94 | |
| 95 | pub(crate) const TERMINATIONS: TestFixture = TestFixture { |
| 96 | dag: r#" |
| 97 | A-B-C D-E-\ |
| 98 | F---I--J |
| 99 | X-D-H-/ \-K |
| 100 | "#, |
| 101 | messages: &[], |
| 102 | heads: &["C", "J", "K"], |
| 103 | reserve: &["E"], |
| 104 | ancestors: &[("B", "A")], |
| 105 | missing: &["A", "F", "X"], |
| 106 | }; |
| 107 | |
| 108 | const LONG_MESSAGE: &str = "long message 1\nlong message 2\nlong message 3\n\n"; |
| 109 | const VERY_LONG_MESSAGE: &str = "very long message 1\nvery long message 2\nvery long message 3\n\n\ |
| 110 | very long message 4\nvery long message 5\nvery long message 6\n\n"; |
| 111 | |
| 112 | pub(crate) const LONG_MESSAGES: TestFixture = TestFixture { |
| 113 | dag: r#" |
| 114 | Y-\ |
| 115 | Z-A-B-D-E-F |
| 116 | \-C-/ |
| 117 | "#, |
| 118 | messages: &[ |
| 119 | ("A", LONG_MESSAGE), |
| 120 | ("C", LONG_MESSAGE), |
| 121 | ("F", VERY_LONG_MESSAGE), |
| 122 | ], |
| 123 | heads: &["F"], |
| 124 | |
| 125 | reserve: &[], |
| 126 | ancestors: &[], |
| 127 | missing: &["Y", "Z"], |
| 128 | }; |
| 129 | |
| 130 | pub(crate) const ORDERS1: TestFixture = TestFixture { |
| 131 | dag: r#" |
| 132 | K |
| 133 | /| |
| 134 | F J |
| 135 | / /| |
| 136 | | E I |
| 137 | |/ /| |
| 138 | | D H |
| 139 | |/ /| |
| 140 | | C G |
| 141 | |/ /| |
| 142 | | B Z |
| 143 | |/ |
| 144 | A |
| 145 | "#, |
| 146 | messages: &[], |
| 147 | heads: &["K"], |
| 148 | reserve: &[], |
| 149 | ancestors: &[], |
| 150 | missing: &[], |
| 151 | }; |
| 152 | |
| 153 | // Unlike ORDERS1, the first-parent branch (KFEDCBA) is the longest path. |
| 154 | pub(crate) const ORDERS2: TestFixture = TestFixture { |
| 155 | dag: r#" |
| 156 | K |
| 157 | /| |
| 158 | J F |
| 159 | / /| |
| 160 | | I E |
| 161 | |/ /| |
| 162 | | H D |
| 163 | |/ /| |
| 164 | | G C |
| 165 | |/ /| |
| 166 | | B Z |
| 167 | |/ |
| 168 | A |
| 169 | "#, |
| 170 | messages: &[], |
| 171 | heads: &["K"], |
| 172 | reserve: &[], |
| 173 | ancestors: &[], |
| 174 | missing: &[], |
| 175 | }; |