linera_sdk/test/
mod.rs

1// Copyright (c) Zefchain Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Helper types for writing integration tests for WebAssembly applications.
5//!
6//! Integration tests are usually written in the `tests` directory in the root of the crate's
7//! directory (i.e., beside the `src` directory). Linera application integration tests should be
8//! executed targeting the host architecture, instead of targeting `wasm32-unknown-unknown` like
9//! done for unit tests.
10
11#![cfg(any(with_testing, with_wasm_runtime))]
12
13#[cfg(with_integration_testing)]
14mod block;
15#[cfg(with_integration_testing)]
16mod chain;
17mod mock_stubs;
18#[cfg(with_integration_testing)]
19mod validator;
20
21#[cfg(with_integration_testing)]
22pub use {
23    linera_chain::{
24        data_types::MessageAction, test::HttpServer, ChainError, ChainExecutionContext,
25    },
26    linera_core::worker::WorkerError,
27    linera_execution::{system::Recipient, ExecutionError, QueryOutcome, WasmExecutionError},
28};
29
30#[cfg(with_testing)]
31pub use self::mock_stubs::*;
32#[cfg(with_integration_testing)]
33pub use self::{
34    block::BlockBuilder,
35    chain::{ActiveChain, TryGraphQLMutationError, TryGraphQLQueryError, TryQueryError},
36    validator::TestValidator,
37};
38use crate::{Contract, ContractRuntime, Service, ServiceRuntime};
39
40/// Creates a [`ContractRuntime`] to use in tests.
41pub fn test_contract_runtime<Application: Contract>() -> ContractRuntime<Application> {
42    ContractRuntime::new()
43}
44
45/// Creates a [`ServiceRuntime`] to use in tests.
46pub fn test_service_runtime<Application: Service>() -> ServiceRuntime<Application> {
47    ServiceRuntime::new()
48}