1// This file is part of Substrate.
23// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
56// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
1011// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
1516// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
1819//! Include sources generated from protobuf definitions.
2021pub(crate) mod v1 {
22pub(crate) mod light {
23include!(concat!(env!("OUT_DIR"), "/api.v1.light.rs"));
24 }
25}
2627#[cfg(test)]
28mod tests {
29use prost::Message as _;
3031#[test]
32fn empty_proof_encodes_correctly() {
33let encoded = super::v1::light::Response {
34 response: Some(super::v1::light::response::Response::RemoteReadResponse(
35super::v1::light::RemoteReadResponse { proof: Some(Vec::new()) },
36 )),
37 }
38 .encode_to_vec();
3940// Make sure that the response contains one field of number 2 and wire type 2 (message),
41 // then another field of number 2 and wire type 2 (bytes), then a length of 0.
42assert_eq!(encoded, vec![(2 << 3) | 2, 2, (2 << 3) | 2, 0]);
43 }
4445#[test]
46fn no_proof_encodes_correctly() {
47let encoded = super::v1::light::Response {
48 response: Some(super::v1::light::response::Response::RemoteReadResponse(
49super::v1::light::RemoteReadResponse { proof: None },
50 )),
51 }
52 .encode_to_vec();
5354// Make sure that the response contains one field of number 2 and wire type 2 (message).
55assert_eq!(encoded, vec![(2 << 3) | 2, 0]);
56 }
5758#[test]
59fn proof_encodes_correctly() {
60let encoded = super::v1::light::Response {
61 response: Some(super::v1::light::response::Response::RemoteReadResponse(
62super::v1::light::RemoteReadResponse { proof: Some(vec![1, 2, 3, 4]) },
63 )),
64 }
65 .encode_to_vec();
6667assert_eq!(encoded, vec![(2 << 3) | 2, 6, (2 << 3) | 2, 4, 1, 2, 3, 4]);
68 }
69}