test_parachain_halt/lib.rs
1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16
17//! Basic parachain that executes forever.
18
19#![no_std]
20#![cfg_attr(enable_alloc_error_handler, feature(alloc_error_handler))]
21
22// Make the WASM binary available.
23#[cfg(feature = "std")]
24include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
25
26#[cfg(feature = "std")]
27/// Wasm binary unwrapped. If built with `BUILD_DUMMY_WASM_BINARY`, the function panics.
28pub fn wasm_binary_unwrap() -> &'static [u8] {
29 WASM_BINARY.expect(
30 "Development wasm binary is not available. Testing is only \
31 supported with the flag disabled.",
32 )
33}
34
35#[cfg(not(feature = "std"))]
36#[panic_handler]
37pub fn panic(_info: &core::panic::PanicInfo) -> ! {
38 core::arch::wasm32::unreachable();
39}
40
41#[cfg(enable_alloc_error_handler)]
42#[alloc_error_handler]
43#[no_mangle]
44pub fn oom(_: core::alloc::Layout) -> ! {
45 core::intrinsics::abort();
46}
47
48#[cfg(not(feature = "std"))]
49#[no_mangle]
50pub extern "C" fn validate_block(_params: *const u8, _len: usize) -> u64 {
51 loop {}
52}