/__w/smoldot/smoldot/repo/lib/src/chain/blocks_tree/tests.rs
Line | Count | Source (jump to first uncovered line) |
1 | | // Smoldot |
2 | | // Copyright (C) 2023 Pierre Krieger |
3 | | // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 |
4 | | |
5 | | // This program is free software: you can redistribute it and/or modify |
6 | | // it under the terms of the GNU General Public License as published by |
7 | | // the Free Software Foundation, either version 3 of the License, or |
8 | | // (at your option) any later version. |
9 | | |
10 | | // This program is distributed in the hope that it will be useful, |
11 | | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | | // GNU General Public License for more details. |
14 | | |
15 | | // You should have received a copy of the GNU General Public License |
16 | | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | | |
18 | | // TODO: add more tests |
19 | | |
20 | | #![cfg(test)] |
21 | | |
22 | | use core::{num::NonZeroU64, time::Duration}; |
23 | | |
24 | | use super::{Config, HeaderVerifySuccess, NonFinalizedTree}; |
25 | | use crate::{chain::chain_information, header}; |
26 | | |
27 | | #[test] |
28 | 1 | fn polkadot_blocks_0_to_2() { |
29 | 1 | let mut tree = NonFinalizedTree::new(Config { |
30 | 1 | chain_information: chain_information::ChainInformation { |
31 | 1 | finalized_block_header: Box::new(header::Header { |
32 | 1 | parent_hash: [ |
33 | 1 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
34 | 1 | 0, 0, 0, 0, 0, 0, |
35 | 1 | ], |
36 | 1 | number: 0, |
37 | 1 | state_root: [ |
38 | 1 | 41, 208, 217, 114, 205, 39, 203, 197, 17, 233, 88, 159, 203, 122, 69, 6, 213, |
39 | 1 | 235, 106, 158, 141, 242, 5, 240, 4, 114, 229, 171, 53, 74, 78, 23, |
40 | 1 | ], |
41 | 1 | extrinsics_root: [ |
42 | 1 | 3, 23, 10, 46, 117, 151, 183, 183, 227, 216, 76, 5, 57, 29, 19, 154, 98, 177, |
43 | 1 | 87, 231, 135, 134, 216, 192, 130, 242, 157, 207, 76, 17, 19, 20, |
44 | 1 | ], |
45 | 1 | digest: header::Digest::from(header::DigestRef::empty()), |
46 | 1 | }), |
47 | 1 | consensus: chain_information::ChainInformationConsensus::Babe { |
48 | 1 | slots_per_epoch: NonZeroU64::new(2400).unwrap(), |
49 | 1 | finalized_block_epoch_information: None, |
50 | 1 | finalized_next_epoch_transition: Box::new( |
51 | 1 | chain_information::BabeEpochInformation { |
52 | 1 | epoch_index: 0, |
53 | 1 | start_slot_number: None, |
54 | 1 | authorities: vec![ |
55 | 1 | header::BabeAuthority { |
56 | 1 | public_key: [ |
57 | 1 | 250, 52, 55, 177, 15, 110, 122, 248, 243, 19, 98, 223, 58, 23, |
58 | 1 | 155, 153, 26, 140, 86, 49, 61, 27, 205, 99, 7, 164, 208, 199, |
59 | 1 | 52, 193, 174, 49, |
60 | 1 | ], |
61 | 1 | weight: 1, |
62 | 1 | }, |
63 | 1 | header::BabeAuthority { |
64 | 1 | public_key: [ |
65 | 1 | 210, 65, 155, 200, 131, 84, 147, 172, 137, 235, 9, 213, 152, |
66 | 1 | 82, 129, 245, 223, 244, 188, 108, 122, 126, 169, 136, 253, 35, |
67 | 1 | 175, 5, 243, 1, 88, 10, |
68 | 1 | ], |
69 | 1 | weight: 1, |
70 | 1 | }, |
71 | 1 | header::BabeAuthority { |
72 | 1 | public_key: [ |
73 | 1 | 204, 182, 190, 246, 13, 239, 195, 7, 36, 84, 93, 87, 68, 3, |
74 | 1 | 148, 237, 28, 113, 234, 126, 230, 216, 128, 237, 14, 121, 135, |
75 | 1 | 26, 5, 181, 228, 6, |
76 | 1 | ], |
77 | 1 | weight: 1, |
78 | 1 | }, |
79 | 1 | header::BabeAuthority { |
80 | 1 | public_key: [ |
81 | 1 | 94, 103, 182, 76, 240, 125, 77, 37, 138, 71, 223, 99, 131, 81, |
82 | 1 | 33, 66, 53, 81, 113, 40, 68, 245, 182, 125, 230, 142, 54, 187, |
83 | 1 | 154, 33, 225, 39, |
84 | 1 | ], |
85 | 1 | weight: 1, |
86 | 1 | }, |
87 | 1 | header::BabeAuthority { |
88 | 1 | public_key: [ |
89 | 1 | 98, 54, 135, 123, 5, 55, 2, 101, 100, 12, 19, 63, 236, 7, 230, |
90 | 1 | 77, 124, 168, 35, 219, 29, 197, 111, 45, 53, 132, 179, 215, |
91 | 1 | 192, 241, 97, 88, |
92 | 1 | ], |
93 | 1 | weight: 1, |
94 | 1 | }, |
95 | 1 | header::BabeAuthority { |
96 | 1 | public_key: [ |
97 | 1 | 108, 82, 208, 45, 149, 195, 10, 165, 103, 253, 162, 132, 172, |
98 | 1 | 242, 80, 37, 202, 116, 112, 240, 176, 197, 22, 221, 249, 68, |
99 | 1 | 117, 161, 128, 124, 77, 37, |
100 | 1 | ], |
101 | 1 | weight: 1, |
102 | 1 | }, |
103 | 1 | ], |
104 | 1 | randomness: [ |
105 | 1 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
106 | 1 | 0, 0, 0, 0, 0, 0, 0, 0, |
107 | 1 | ], |
108 | 1 | c: (1, 4), |
109 | 1 | allowed_slots: header::BabeAllowedSlots::PrimaryAndSecondaryVrfSlots, |
110 | 1 | }, |
111 | 1 | ), |
112 | 1 | }, |
113 | 1 | finality: chain_information::ChainInformationFinality::Grandpa { |
114 | 1 | after_finalized_block_authorities_set_id: 0, |
115 | 1 | finalized_triggered_authorities: vec![ |
116 | 1 | header::GrandpaAuthority { |
117 | 1 | public_key: [ |
118 | 1 | 222, 166, 244, 167, 39, 211, 178, 57, 146, 117, 214, 238, 136, 23, 136, |
119 | 1 | 31, 16, 89, 116, 113, 220, 29, 39, 241, 68, 41, 90, 214, 251, 147, 60, |
120 | 1 | 122, |
121 | 1 | ], |
122 | 1 | weight: NonZeroU64::new(1).unwrap(), |
123 | 1 | }, |
124 | 1 | header::GrandpaAuthority { |
125 | 1 | public_key: [ |
126 | 1 | 72, 182, 35, 148, 28, 42, 77, 65, 207, 37, 239, 73, 84, 8, 105, 15, |
127 | 1 | 200, 83, 247, 119, 25, 36, 152, 192, 146, 46, 171, 30, 157, 244, 240, |
128 | 1 | 97, |
129 | 1 | ], |
130 | 1 | weight: NonZeroU64::new(1).unwrap(), |
131 | 1 | }, |
132 | 1 | header::GrandpaAuthority { |
133 | 1 | public_key: [ |
134 | 1 | 247, 45, 175, 46, 86, 14, 79, 15, 34, 251, 92, 187, 4, 173, 29, 127, |
135 | 1 | 238, 133, 10, 171, 35, 143, 208, 20, 193, 120, 118, 158, 126, 58, 155, |
136 | 1 | 132, |
137 | 1 | ], |
138 | 1 | weight: NonZeroU64::new(1).unwrap(), |
139 | 1 | }, |
140 | 1 | header::GrandpaAuthority { |
141 | 1 | public_key: [ |
142 | 1 | 28, 21, 28, 17, 203, 114, 51, 77, 38, 215, 7, 105, 227, 175, 123, 191, |
143 | 1 | 243, 128, 26, 78, 45, 202, 43, 9, 183, 204, 224, 175, 141, 216, 19, 7, |
144 | 1 | ], |
145 | 1 | weight: NonZeroU64::new(1).unwrap(), |
146 | 1 | }, |
147 | 1 | header::GrandpaAuthority { |
148 | 1 | public_key: [ |
149 | 1 | 104, 13, 39, 130, 19, 249, 8, 101, 138, 73, 161, 2, 90, 127, 70, 108, |
150 | 1 | 25, 126, 143, 182, 250, 187, 94, 98, 34, 10, 123, 215, 95, 134, 12, |
151 | 1 | 171, |
152 | 1 | ], |
153 | 1 | weight: NonZeroU64::new(1).unwrap(), |
154 | 1 | }, |
155 | 1 | header::GrandpaAuthority { |
156 | 1 | public_key: [ |
157 | 1 | 142, 89, 54, 135, 0, 234, 137, 226, 191, 137, 34, 204, 158, 75, 134, |
158 | 1 | 214, 101, 29, 28, 104, 154, 13, 87, 129, 63, 151, 104, 219, 170, 222, |
159 | 1 | 207, 113, |
160 | 1 | ], |
161 | 1 | weight: NonZeroU64::new(1).unwrap(), |
162 | 1 | }, |
163 | 1 | ], |
164 | 1 | finalized_scheduled_change: None, |
165 | 1 | }, |
166 | 1 | } |
167 | 1 | .try_into() |
168 | 1 | .unwrap(), |
169 | 1 | blocks_capacity: 8, |
170 | 1 | block_number_bytes: 4, |
171 | 1 | allow_unknown_consensus_engines: false, |
172 | 1 | }); |
173 | 1 | |
174 | 1 | let block1 = vec![ |
175 | 1 | 145, 177, 113, 187, 21, 142, 45, 56, 72, 250, 35, 169, 241, 194, 81, 130, 251, 142, 32, 49, |
176 | 1 | 59, 44, 30, 180, 146, 25, 218, 122, 112, 206, 144, 195, 4, 197, 111, 205, 110, 122, 117, |
177 | 1 | 121, 38, 172, 227, 225, 236, 255, 155, 64, 16, 252, 120, 185, 13, 69, 146, 2, 163, 57, 38, |
178 | 1 | 106, 127, 99, 96, 0, 47, 154, 135, 246, 175, 100, 239, 151, 175, 242, 211, 27, 235, 253, |
179 | 1 | 213, 159, 143, 226, 239, 96, 25, 39, 139, 99, 75, 37, 21, 163, 143, 28, 76, 36, 32, 12, 6, |
180 | 1 | 66, 65, 66, 69, 181, 1, 1, 0, 0, 0, 0, 147, 222, 204, 15, 0, 0, 0, 0, 54, 46, 216, 214, 5, |
181 | 1 | 86, 69, 72, 127, 228, 46, 156, 134, 64, 190, 101, 31, 112, 163, 162, 160, 54, 88, 4, 107, |
182 | 1 | 43, 67, 240, 33, 102, 87, 4, 80, 26, 249, 177, 202, 110, 151, 76, 37, 126, 61, 38, 96, 155, |
183 | 1 | 95, 104, 181, 176, 161, 218, 83, 247, 242, 82, 187, 229, 217, 73, 72, 195, 151, 5, 201, |
184 | 1 | 143, 250, 75, 134, 157, 212, 74, 194, 149, 40, 227, 114, 61, 97, 156, 199, 237, 241, 211, |
185 | 1 | 247, 183, 165, 122, 149, 127, 106, 126, 155, 219, 39, 10, 4, 66, 65, 66, 69, 73, 4, 1, 24, |
186 | 1 | 250, 52, 55, 177, 15, 110, 122, 248, 243, 19, 98, 223, 58, 23, 155, 153, 26, 140, 86, 49, |
187 | 1 | 61, 27, 205, 99, 7, 164, 208, 199, 52, 193, 174, 49, 1, 0, 0, 0, 0, 0, 0, 0, 210, 65, 155, |
188 | 1 | 200, 131, 84, 147, 172, 137, 235, 9, 213, 152, 82, 129, 245, 223, 244, 188, 108, 122, 126, |
189 | 1 | 169, 136, 253, 35, 175, 5, 243, 1, 88, 10, 1, 0, 0, 0, 0, 0, 0, 0, 204, 182, 190, 246, 13, |
190 | 1 | 239, 195, 7, 36, 84, 93, 87, 68, 3, 148, 237, 28, 113, 234, 126, 230, 216, 128, 237, 14, |
191 | 1 | 121, 135, 26, 5, 181, 228, 6, 1, 0, 0, 0, 0, 0, 0, 0, 94, 103, 182, 76, 240, 125, 77, 37, |
192 | 1 | 138, 71, 223, 99, 131, 81, 33, 66, 53, 81, 113, 40, 68, 245, 182, 125, 230, 142, 54, 187, |
193 | 1 | 154, 33, 225, 39, 1, 0, 0, 0, 0, 0, 0, 0, 98, 54, 135, 123, 5, 55, 2, 101, 100, 12, 19, 63, |
194 | 1 | 236, 7, 230, 77, 124, 168, 35, 219, 29, 197, 111, 45, 53, 132, 179, 215, 192, 241, 97, 88, |
195 | 1 | 1, 0, 0, 0, 0, 0, 0, 0, 108, 82, 208, 45, 149, 195, 10, 165, 103, 253, 162, 132, 172, 242, |
196 | 1 | 80, 37, 202, 116, 112, 240, 176, 197, 22, 221, 249, 68, 117, 161, 128, 124, 77, 37, 1, 0, |
197 | 1 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
198 | 1 | 0, 0, 0, 0, 0, 0, 0, 0, 5, 66, 65, 66, 69, 1, 1, 212, 104, 104, 12, 132, 75, 25, 25, 77, |
199 | 1 | 77, 251, 220, 102, 151, 163, 91, 242, 180, 148, 189, 162, 197, 166, 150, 29, 77, 78, 172, |
200 | 1 | 251, 247, 69, 116, 55, 155, 160, 217, 123, 91, 182, 80, 194, 232, 103, 10, 99, 121, 26, |
201 | 1 | 114, 121, 67, 188, 182, 153, 220, 122, 34, 139, 219, 158, 10, 152, 201, 208, 137, |
202 | 1 | ]; |
203 | 1 | |
204 | 1 | let block2 = vec![ |
205 | 1 | 192, 9, 99, 88, 83, 78, 200, 210, 29, 1, 211, 75, 131, 110, 237, 71, 106, 28, 52, 63, 135, |
206 | 1 | 36, 250, 33, 83, 220, 7, 37, 173, 121, 122, 144, 8, 85, 55, 218, 60, 103, 78, 2, 10, 176, |
207 | 1 | 179, 225, 183, 0, 154, 97, 43, 138, 222, 224, 104, 10, 126, 97, 3, 44, 219, 227, 236, 94, |
208 | 1 | 34, 17, 190, 156, 234, 173, 148, 161, 214, 207, 170, 62, 116, 246, 169, 244, 255, 178, 243, |
209 | 1 | 150, 24, 78, 13, 56, 242, 6, 44, 174, 255, 65, 103, 51, 114, 121, 43, 8, 6, 66, 65, 66, 69, |
210 | 1 | 181, 1, 1, 1, 0, 0, 0, 152, 222, 204, 15, 0, 0, 0, 0, 68, 63, 119, 185, 238, 85, 22, 152, |
211 | 1 | 35, 197, 11, 218, 203, 234, 24, 167, 79, 160, 103, 58, 175, 151, 224, 30, 122, 217, 103, |
212 | 1 | 94, 252, 171, 54, 118, 80, 124, 210, 23, 130, 125, 198, 216, 66, 26, 245, 1, 43, 239, 186, |
213 | 1 | 217, 142, 38, 119, 133, 215, 6, 130, 115, 135, 48, 106, 35, 164, 135, 213, 1, 53, 129, 112, |
214 | 1 | 83, 84, 15, 67, 161, 176, 248, 239, 145, 115, 80, 47, 215, 100, 243, 17, 106, 176, 133, 91, |
215 | 1 | 183, 94, 158, 31, 42, 136, 128, 98, 12, 5, 66, 65, 66, 69, 1, 1, 48, 255, 112, 94, 54, 208, |
216 | 1 | 26, 138, 9, 200, 2, 10, 46, 98, 24, 167, 215, 23, 117, 157, 130, 206, 250, 124, 193, 231, |
217 | 1 | 26, 77, 147, 33, 218, 103, 174, 2, 6, 143, 29, 1, 175, 29, 29, 124, 133, 17, 32, 124, 4, |
218 | 1 | 148, 131, 74, 156, 58, 185, 152, 11, 51, 226, 55, 115, 244, 139, 198, 207, 133, |
219 | 1 | ]; |
220 | | |
221 | 1 | let verified_header1 = match tree.verify_header(block1, Duration::new(0, 0)).unwrap() { |
222 | | HeaderVerifySuccess::Verified { |
223 | 1 | verified_header, .. |
224 | 1 | } => verified_header, |
225 | 0 | _ => panic!(), |
226 | | }; |
227 | | |
228 | 1 | tree.insert_verified_header(verified_header1, ()); |
229 | | |
230 | 1 | let verified_header2 = match tree.verify_header(block2, Duration::new(0, 0)).unwrap() { |
231 | | HeaderVerifySuccess::Verified { |
232 | 1 | verified_header, .. |
233 | 1 | } => verified_header, |
234 | 0 | _ => panic!(), |
235 | | }; |
236 | | |
237 | 1 | tree.insert_verified_header(verified_header2, ()); |
238 | 1 | } |
239 | | |
240 | | #[test] |
241 | 1 | fn kusama_blocks_0_to_2() { |
242 | 1 | let mut tree = NonFinalizedTree::new(Config { |
243 | 1 | chain_information: chain_information::ChainInformation { |
244 | 1 | finalized_block_header: Box::new(header::Header { |
245 | 1 | parent_hash: [ |
246 | 1 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
247 | 1 | 0, 0, 0, 0, 0, 0, |
248 | 1 | ], |
249 | 1 | number: 0, |
250 | 1 | state_root: [ |
251 | 1 | 176, 0, 98, 3, 195, 166, 230, 189, 44, 106, 23, 177, 212, 174, 140, 164, 154, |
252 | 1 | 49, 218, 15, 69, 121, 218, 149, 11, 18, 119, 116, 180, 74, 239, 107, |
253 | 1 | ], |
254 | 1 | extrinsics_root: [ |
255 | 1 | 3, 23, 10, 46, 117, 151, 183, 183, 227, 216, 76, 5, 57, 29, 19, 154, 98, 177, |
256 | 1 | 87, 231, 135, 134, 216, 192, 130, 242, 157, 207, 76, 17, 19, 20, |
257 | 1 | ], |
258 | 1 | digest: header::Digest::from(header::DigestRef::empty()), |
259 | 1 | }), |
260 | 1 | consensus: chain_information::ChainInformationConsensus::Babe { |
261 | 1 | slots_per_epoch: NonZeroU64::new(600).unwrap(), |
262 | 1 | finalized_block_epoch_information: None, |
263 | 1 | finalized_next_epoch_transition: Box::new( |
264 | 1 | chain_information::BabeEpochInformation { |
265 | 1 | epoch_index: 0, |
266 | 1 | start_slot_number: None, |
267 | 1 | authorities: vec![ |
268 | 1 | header::BabeAuthority { |
269 | 1 | public_key: [ |
270 | 1 | 202, 35, 147, 146, 150, 4, 115, 254, 27, 198, 95, 148, 238, 39, |
271 | 1 | 216, 144, 164, 156, 27, 32, 12, 0, 111, 245, 220, 197, 37, 51, |
272 | 1 | 14, 204, 22, 119, |
273 | 1 | ], |
274 | 1 | weight: 1, |
275 | 1 | }, |
276 | 1 | header::BabeAuthority { |
277 | 1 | public_key: [ |
278 | 1 | 180, 111, 1, 135, 76, 231, 171, 187, 82, 32, 232, 253, 137, |
279 | 1 | 190, 222, 10, 218, 209, 76, 115, 3, 157, 145, 226, 142, 136, |
280 | 1 | 24, 35, 67, 62, 114, 63, |
281 | 1 | ], |
282 | 1 | weight: 1, |
283 | 1 | }, |
284 | 1 | header::BabeAuthority { |
285 | 1 | public_key: [ |
286 | 1 | 214, 132, 217, 23, 109, 110, 182, 152, 135, 84, 12, 154, 137, |
287 | 1 | 250, 96, 151, 173, 234, 130, 252, 75, 15, 242, 109, 16, 98, |
288 | 1 | 180, 136, 243, 82, 225, 121, |
289 | 1 | ], |
290 | 1 | weight: 1, |
291 | 1 | }, |
292 | 1 | header::BabeAuthority { |
293 | 1 | public_key: [ |
294 | 1 | 104, 25, 90, 113, 189, 222, 73, 17, 122, 97, 100, 36, 189, 198, |
295 | 1 | 10, 23, 51, 233, 106, 203, 29, 165, 174, 171, 93, 38, 140, 242, |
296 | 1 | 165, 114, 233, 65, |
297 | 1 | ], |
298 | 1 | weight: 1, |
299 | 1 | }, |
300 | 1 | header::BabeAuthority { |
301 | 1 | public_key: [ |
302 | 1 | 26, 5, 117, 239, 74, 226, 75, 223, 211, 31, 76, 181, 189, 97, |
303 | 1 | 35, 154, 230, 124, 18, 212, 230, 74, 229, 26, 199, 86, 4, 74, |
304 | 1 | 166, 173, 130, 0, |
305 | 1 | ], |
306 | 1 | weight: 1, |
307 | 1 | }, |
308 | 1 | header::BabeAuthority { |
309 | 1 | public_key: [ |
310 | 1 | 24, 22, 143, 42, 173, 0, 129, 162, 87, 40, 150, 30, 224, 6, 39, |
311 | 1 | 207, 227, 94, 57, 131, 60, 128, 80, 22, 99, 43, 247, 193, 77, |
312 | 1 | 165, 128, 9, |
313 | 1 | ], |
314 | 1 | weight: 1, |
315 | 1 | }, |
316 | 1 | ], |
317 | 1 | randomness: [ |
318 | 1 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
319 | 1 | 0, 0, 0, 0, 0, 0, 0, 0, |
320 | 1 | ], |
321 | 1 | c: (1, 4), |
322 | 1 | allowed_slots: header::BabeAllowedSlots::PrimaryAndSecondaryPlainSlots, |
323 | 1 | }, |
324 | 1 | ), |
325 | 1 | }, |
326 | 1 | finality: chain_information::ChainInformationFinality::Grandpa { |
327 | 1 | after_finalized_block_authorities_set_id: 0, |
328 | 1 | finalized_triggered_authorities: vec![ |
329 | 1 | header::GrandpaAuthority { |
330 | 1 | public_key: [ |
331 | 1 | 49, 110, 204, 43, 155, 120, 0, 132, 237, 16, 186, 123, 64, 22, 150, |
332 | 1 | 175, 210, 16, 101, 97, 184, 25, 44, 61, 130, 24, 17, 237, 220, 133, |
333 | 1 | 190, 18, |
334 | 1 | ], |
335 | 1 | weight: NonZeroU64::new(1).unwrap(), |
336 | 1 | }, |
337 | 1 | header::GrandpaAuthority { |
338 | 1 | public_key: [ |
339 | 1 | 65, 31, 193, 165, 200, 138, 178, 187, 127, 99, 178, 59, 21, 195, 153, |
340 | 1 | 131, 207, 56, 243, 172, 45, 253, 156, 81, 104, 213, 215, 235, 186, 216, |
341 | 1 | 53, 68, |
342 | 1 | ], |
343 | 1 | weight: NonZeroU64::new(1).unwrap(), |
344 | 1 | }, |
345 | 1 | header::GrandpaAuthority { |
346 | 1 | public_key: [ |
347 | 1 | 213, 72, 196, 144, 255, 110, 114, 142, 208, 147, 167, 64, 103, 17, 215, |
348 | 1 | 107, 44, 125, 4, 199, 114, 119, 251, 136, 177, 195, 199, 137, 250, 100, |
349 | 1 | 23, 55, |
350 | 1 | ], |
351 | 1 | weight: NonZeroU64::new(1).unwrap(), |
352 | 1 | }, |
353 | 1 | header::GrandpaAuthority { |
354 | 1 | public_key: [ |
355 | 1 | 185, 140, 147, 11, 155, 74, 120, 44, 163, 146, 88, 13, 2, 237, 17, 133, |
356 | 1 | 250, 50, 20, 190, 158, 118, 105, 255, 125, 192, 150, 209, 125, 40, 107, |
357 | 1 | 210, |
358 | 1 | ], |
359 | 1 | weight: NonZeroU64::new(1).unwrap(), |
360 | 1 | }, |
361 | 1 | header::GrandpaAuthority { |
362 | 1 | public_key: [ |
363 | 1 | 92, 227, 13, 140, 0, 125, 10, 67, 140, 146, 195, 122, 102, 11, 119, 9, |
364 | 1 | 253, 31, 243, 187, 167, 156, 108, 72, 50, 234, 65, 7, 210, 102, 224, 1, |
365 | 1 | ], |
366 | 1 | weight: NonZeroU64::new(1).unwrap(), |
367 | 1 | }, |
368 | 1 | header::GrandpaAuthority { |
369 | 1 | public_key: [ |
370 | 1 | 244, 84, 117, 193, 93, 68, 115, 23, 183, 222, 56, 151, 38, 86, 210, 7, |
371 | 1 | 227, 98, 247, 250, 68, 41, 214, 101, 206, 16, 169, 218, 42, 206, 37, |
372 | 1 | 76, |
373 | 1 | ], |
374 | 1 | weight: NonZeroU64::new(1).unwrap(), |
375 | 1 | }, |
376 | 1 | ], |
377 | 1 | finalized_scheduled_change: None, |
378 | 1 | }, |
379 | 1 | } |
380 | 1 | .try_into() |
381 | 1 | .unwrap(), |
382 | 1 | blocks_capacity: 8, |
383 | 1 | block_number_bytes: 4, |
384 | 1 | allow_unknown_consensus_engines: false, |
385 | 1 | }); |
386 | 1 | |
387 | 1 | let block1 = vec![ |
388 | 1 | 176, 168, 212, 147, 40, 92, 45, 247, 50, 144, 223, 183, 230, 31, 135, 15, 23, 180, 24, 1, |
389 | 1 | 25, 122, 20, 156, 169, 54, 84, 73, 158, 163, 218, 254, 4, 250, 187, 12, 110, 146, 210, 158, |
390 | 1 | 139, 178, 22, 127, 60, 111, 176, 221, 235, 149, 106, 66, 120, 163, 207, 133, 54, 97, 175, |
391 | 1 | 116, 160, 118, 252, 156, 183, 163, 95, 183, 247, 97, 111, 92, 151, 157, 72, 34, 43, 61, 47, |
392 | 1 | 167, 203, 35, 49, 239, 115, 149, 71, 38, 113, 77, 145, 202, 148, 92, 195, 79, 216, 12, 6, |
393 | 1 | 66, 65, 66, 69, 52, 2, 1, 0, 0, 0, 239, 85, 165, 15, 0, 0, 0, 0, 4, 66, 65, 66, 69, 73, 4, |
394 | 1 | 1, 24, 202, 35, 147, 146, 150, 4, 115, 254, 27, 198, 95, 148, 238, 39, 216, 144, 164, 156, |
395 | 1 | 27, 32, 12, 0, 111, 245, 220, 197, 37, 51, 14, 204, 22, 119, 1, 0, 0, 0, 0, 0, 0, 0, 180, |
396 | 1 | 111, 1, 135, 76, 231, 171, 187, 82, 32, 232, 253, 137, 190, 222, 10, 218, 209, 76, 115, 3, |
397 | 1 | 157, 145, 226, 142, 136, 24, 35, 67, 62, 114, 63, 1, 0, 0, 0, 0, 0, 0, 0, 214, 132, 217, |
398 | 1 | 23, 109, 110, 182, 152, 135, 84, 12, 154, 137, 250, 96, 151, 173, 234, 130, 252, 75, 15, |
399 | 1 | 242, 109, 16, 98, 180, 136, 243, 82, 225, 121, 1, 0, 0, 0, 0, 0, 0, 0, 104, 25, 90, 113, |
400 | 1 | 189, 222, 73, 17, 122, 97, 100, 36, 189, 198, 10, 23, 51, 233, 106, 203, 29, 165, 174, 171, |
401 | 1 | 93, 38, 140, 242, 165, 114, 233, 65, 1, 0, 0, 0, 0, 0, 0, 0, 26, 5, 117, 239, 74, 226, 75, |
402 | 1 | 223, 211, 31, 76, 181, 189, 97, 35, 154, 230, 124, 18, 212, 230, 74, 229, 26, 199, 86, 4, |
403 | 1 | 74, 166, 173, 130, 0, 1, 0, 0, 0, 0, 0, 0, 0, 24, 22, 143, 42, 173, 0, 129, 162, 87, 40, |
404 | 1 | 150, 30, 224, 6, 39, 207, 227, 94, 57, 131, 60, 128, 80, 22, 99, 43, 247, 193, 77, 165, |
405 | 1 | 128, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
406 | 1 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 66, 65, 66, 69, 1, 1, 70, 37, 40, 72, 131, 229, 100, |
407 | 1 | 188, 30, 64, 99, 245, 234, 43, 73, 132, 108, 221, 218, 163, 118, 29, 4, 245, 67, 182, 152, |
408 | 1 | 193, 195, 238, 147, 92, 64, 210, 91, 134, 146, 71, 195, 108, 107, 138, 140, 187, 215, 187, |
409 | 1 | 39, 104, 245, 96, 171, 124, 39, 109, 243, 198, 45, 243, 87, 167, 227, 177, 236, 141, |
410 | 1 | ]; |
411 | 1 | |
412 | 1 | let block2 = vec![ |
413 | 1 | 205, 155, 142, 47, 194, 245, 124, 69, 112, 168, 99, 25, 176, 5, 131, 32, 128, 224, 196, |
414 | 1 | 120, 171, 65, 174, 93, 68, 226, 55, 5, 135, 47, 90, 211, 8, 255, 150, 206, 251, 45, 135, |
415 | 1 | 125, 246, 130, 224, 54, 106, 95, 245, 49, 208, 120, 103, 209, 119, 57, 200, 93, 225, 26, |
416 | 1 | 88, 0, 194, 10, 128, 229, 204, 79, 133, 232, 31, 56, 113, 82, 250, 111, 61, 32, 44, 149, |
417 | 1 | 220, 57, 97, 234, 129, 229, 66, 134, 140, 116, 118, 106, 66, 255, 166, 203, 49, 13, 95, 8, |
418 | 1 | 6, 66, 65, 66, 69, 52, 2, 3, 0, 0, 0, 242, 85, 165, 15, 0, 0, 0, 0, 5, 66, 65, 66, 69, 1, |
419 | 1 | 1, 30, 94, 174, 6, 178, 65, 184, 201, 171, 92, 53, 248, 22, 33, 130, 13, 174, 76, 172, 14, |
420 | 1 | 50, 0, 42, 120, 77, 188, 35, 60, 193, 16, 250, 123, 117, 227, 254, 70, 249, 151, 51, 51, |
421 | 1 | 131, 155, 40, 151, 214, 202, 179, 155, 107, 97, 230, 47, 86, 51, 175, 4, 94, 167, 224, 20, |
422 | 1 | 123, 155, 99, 130, |
423 | 1 | ]; |
424 | | |
425 | 1 | let verified_header1 = match tree.verify_header(block1, Duration::new(0, 0)).unwrap() { |
426 | | HeaderVerifySuccess::Verified { |
427 | 1 | verified_header, .. |
428 | 1 | } => verified_header, |
429 | 0 | _ => panic!(), |
430 | | }; |
431 | | |
432 | 1 | tree.insert_verified_header(verified_header1, ()); |
433 | | |
434 | 1 | let verified_header2 = match tree.verify_header(block2, Duration::new(0, 0)).unwrap() { |
435 | | HeaderVerifySuccess::Verified { |
436 | 1 | verified_header, .. |
437 | 1 | } => verified_header, |
438 | 0 | _ => panic!(), |
439 | | }; |
440 | | |
441 | 1 | tree.insert_verified_header(verified_header2, ()); |
442 | 1 | } |