Attribute Macro ockam::test

source · []
#[test]
Expand description

Marks an async test function to be run in an ockam node.

It transforms an async input function into a test output function that sets up an ockam node and executes the body of the input function inside the node.

The macro supports the following attributes:

  • #[ockam::test(crate = "...")]: specify a path to the crate that will be used to import the items required by the macro. This can be helpful when using the macro from an internal ockam crate. Defaults to ockam_node.

  • #[ockam::test(timeout = 1000)]: the macro executes the test with a timeout interval (in milliseconds) to avoid blocking the test indefinitely. If the test times out it will panic. Defaults to 30000 (30 seconds).

Example of use:

#[ockam::test]
async fn main(mut ctx: ockam::Context) -> ockam::Result<()> {
    ctx.stop().await
}