iota_transactional_test_runner/
offchain_state.rs

1// Copyright (c) Mysten Labs, Inc.
2// Modifications Copyright (c) 2025 IOTA Stiftung
3// SPDX-License-Identifier: Apache-2.0
4
5use std::time::Duration;
6
7use async_trait::async_trait;
8
9pub struct TestResponse {
10    pub response_body: String,
11    pub http_headers: Option<http::HeaderMap>,
12    pub service_version: Option<String>,
13}
14
15/// Trait for interacting with the offchain state of the Iota network. To reduce
16/// test flakiness, these methods are used in the `RunGraphqlCommand` to
17/// stabilize the off-chain indexed state.
18#[async_trait]
19pub trait OffchainStateReader: Send + Sync + 'static {
20    /// Polls the objects snapshot table until it is within the allowed lag from
21    /// the latest checkpoint.
22    async fn wait_for_objects_snapshot_catchup(&self, base_timeout: Duration);
23    /// Polls the checkpoint table until the given checkpoint is committed.
24    async fn wait_for_checkpoint_catchup(&self, checkpoint: u64, base_timeout: Duration);
25    /// Polls the checkpoint table until the given checkpoint is pruned.
26    async fn wait_for_pruned_checkpoint(&self, checkpoint: u64, base_timeout: Duration);
27    /// Executes a GraphQL query and returns the response.
28    async fn execute_graphql(
29        &self,
30        query: String,
31        show_usage: bool,
32    ) -> Result<TestResponse, anyhow::Error>;
33}