[][src]Struct exonum_testkit::TestKitBuilder

pub struct TestKitBuilder { /* fields omitted */ }

Builder for TestKit.

Example

let service = Spec::new(ExampleService).with_instance(SERVICE_ID, "example", ());
let mut testkit = TestKitBuilder::validator()
    .with(service)
    .with_validators(4)
    .build();
testkit.create_block();
// Other test code

Methods

impl TestKitBuilder[src]

pub fn validator() -> Self[src]

Creates testkit for the validator node.

pub fn auditor() -> Self[src]

Creates testkit for the auditor node.

pub fn with_keys(self, keys: impl IntoIterator<Item = Keys>) -> Self[src]

Creates the validator nodes from the specified keys.

pub fn with_validators(self, validator_count: u16) -> Self[src]

Sets the number of validator nodes in the test network.

pub fn with(self, spec: impl Deploy) -> Self[src]

Adds a deploy spec to this builder. The spec may contain artifacts and service instances to deploy at the blockchain start.

pub fn with_plugin(self, plugin: impl NodePlugin + 'static) -> Self[src]

Adds a node plugin to the testkit.

This method is only available if the crate is compiled with the exonum-node feature, which is off by default.

pub fn with_logger(self) -> Self[src]

Enables a logger inside the testkit.

pub fn with_additional_runtime(self, runtime: impl WellKnownRuntime) -> Self[src]

Adds a runtime to the testkit in addition to the default Rust runtime.

Panics

  • Panics if the builder already contains specified runtime.

pub fn build(self) -> TestKit[src]

Creates the testkit.

pub async fn serve(
    self,
    public_api_address: SocketAddr,
    private_api_address: SocketAddr
)
[src]

Starts a testkit web server, which listens to public and private APIs exposed by the testkit, on the respective addresses. The private address also exposes the testkit APIs with the /api/testkit URL prefix.

Unlike real Exonum nodes, the testkit web server does not create peer-to-peer connections with other nodes, and does not create blocks automatically. The only way to commit transactions is thus to use the testkit API.

See server module for the description of testkit server API.

Trait Implementations

impl Debug for TestKitBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,