Introducing a new way to review your PRs.

Read the announcement

lfdt-ibc / ibc-go

Inter-Blockchain Communication Protocol (IBC) implementation in Golang.

View on GitHub

20 documents · Updated Nov 13, 2026

docs / integration-and-test-infrastructure

Integration and test infrastructure

The integration and test infrastructure gives engineers two ways to check IBC behavior. The Go testing harness runs protocol steps against small in-memory chains and supports both connection-based and client-based packet paths. The end-to-end suite runs real chain and relayer processes in containers so it can check cross-chain behavior through public chain interfaces.

Testing system boundary

The test systems sit between IBC modules and the chain runtime. They create the chain state and time needed by a scenario, move messages or packets through the IBC flow, and check the state that each chain exposes after the flow completes.

The infrastructure supports two test levels:

Test levelMain purposeChain environment
Go harnessCheck core protocol and application behavior with fast, controlled scenariosIn-process simulated applications
End-to-end suiteCheck cross-chain behavior with chain binaries, relayers, queries, and upgradesContainerized chains and relayers

The Go testing harness explains the reusable local model. The end-to-end suite and simulation app explains the container test system and the app used to create test chains.

Simulated chain networks

The Go harness models a network as a coordinator that owns several test chains. A test chain represents an SDK application with block production, transaction delivery, validator state, accounts, and proof queries. The coordinator keeps proposed block time aligned across chains so a counterparty does not appear to be in the future. (testing/coordinator.go• L21-85, testing/chain.go• L51-105)

The harness uses a testing-app contract so a module test can supply an application with the IBC keeper, transaction settings, codec, and block runtime needed by the chain model. The default app is the repository's SimApp, while a module can provide its own compatible app and genesis state. (testing/testing_app.go• L36-71, testing/chain.go• L185-219)

The following diagram shows the local test model and the direction of its main responsibilities.

flowchart LR
    Coordinator[Coordinator\nshared time and chains]
    ChainA[Test chain A\napp and block state]
    ChainB[Test chain B\napp and block state]
    Path[Path\npaired endpoints]
    EndpointA[Endpoint A\nclient, connection, channel]
    EndpointB[Endpoint B\nclient, connection, channel]

    Coordinator --> ChainA
    Coordinator --> ChainB
    Path --> EndpointA
    Path --> EndpointB
    EndpointA --> ChainA
    EndpointB --> ChainB
    EndpointA <--> EndpointB

Simulated application surface

The simulation app is a representative Cosmos SDK application for tests and learning. It wires IBC core to application modules such as token transfer, interchain accounts, generalized message passing, packet forwarding, and rate limiting. It also exposes v1 and v2 IBC routers, light-client routes, and mock modules so tests can exercise real application paths and controlled callback behavior. (testing/…/app.go• L141-189, testing/…/app.go• L382-486)

This app gives the local harness a common chain surface. Its genesis helpers create validators, delegators, funded accounts, and module state before a scenario starts. Its transaction helper signs and delivers messages through the same block state that the test chain advances. The ante handler also applies normal transaction checks and the IBC redundant-relay check. (testing/testing_app.go• L54-142, testing/…/ante.go• L15-52)

References: testing/…/app.go• L141-189 testing/…/app.go• L382-486 testing/testing_app.go• L36-142 testing/…/ante.go• L15-52

Chain time and block state

Block production is explicit in the local model. A test commits a block when it changes chain state or needs a new proof height. The coordinator then advances shared time, which lets client updates and timeout checks use consistent headers across all simulated chains. (testing/coordinator.go• L54-85, testing/coordinator.go• L157-173, testing/chain.go• L338-387)

The chain model supplies proof queries and trusted validator data. It also exposes the state for the next block when a test writes directly to a keeper. This keeps direct setup changes separate from committed state until the next block is finalized. (testing/chain.go• L221-247, testing/chain.go• L260-335, testing/chain.go• L338-387)

References: testing/coordinator.go• L54-85 testing/coordinator.go• L157-173 testing/chain.go• L221-247 testing/chain.go• L260-335 testing/chain.go• L338-387

Protocol scenario assembly

The harness assembles a cross-chain scenario from two endpoint views joined by a path. An endpoint acts on one chain. A path knows the counterparty relationship and coordinates the ordered steps needed to create IBC clients, connections, channels, and packet outcomes. (testing/path.go• L15-35, testing/endpoint.go• L26-45)

The usual local scenario moves through these stages:

  1. Create test chains and a path.
  2. Configure the application port, channel order, and client or connection settings.
  3. Create clients on both sides.
  4. Complete the connection handshake and then the channel handshake.
  5. Send a packet on one side.
  6. Relay the packet to the counterparty and return its acknowledgement.
  7. Advance clients or chain time when the scenario tests a later proof, timeout, or upgrade state.

The path can also set up the IBC v2 counterparty relationship without the v1 connection and channel handshake. V2 packet helpers then send packets between registered client counterparties and drive receive, acknowledgement, and timeout outcomes. (testing/path.go• L135-176, testing/endpoint_v2.go• L15-151)

The packet flow below shows how the harness turns a source commitment into a receive result and an acknowledgement.

sequenceDiagram
    participant S as Source endpoint
    participant SC as Source chain
    participant DC as Destination chain
    participant D as Destination endpoint

    S->>SC: Send packet
    SC-->>S: Store packet commitment
    D->>SC: Read commitment proof
    D->>DC: Receive packet
    DC-->>D: Write acknowledgement
    S->>DC: Read acknowledgement proof
    S->>SC: Acknowledge packet

Handshake and packet paths

The path helpers model the v1 protocol order rather than hide the relationship between the two chains. Connection and channel setup performs each handshake leg in sequence. Packet relay first finds the commitment on the source side, updates the destination client, receives the packet, reads the acknowledgement, and submits it back to the source. (testing/path.go• L63-125, testing/path.go• L178-247)

Endpoint operations also cover client updates, packet timeouts, channel changes, and direct acknowledgement writes. These operations let focused tests move one protocol state at a time while still using chain state and counterparty proofs. (testing/endpoint.go• L139-165, testing/endpoint.go• L441-623)

V2 uses client identifiers and packet payloads as its cross-chain link. The path first registers each counterparty. A send creates a packet from the transaction result. Receive returns an acknowledgement when the application produces one. Relay then submits that acknowledgement on the source side. (testing/path.go• L144-176, testing/endpoint_v2.go• L25-151)

References: testing/path.go• L63-125 testing/path.go• L135-247 testing/endpoint.go• L139-165 testing/endpoint.go• L441-623 testing/endpoint_v2.go• L15-151

Application and middleware paths

The simulation app exposes application routes through separate v1 and v2 IBC routers. A transfer scenario can test token movement through its middleware stack before core IBC handles the packet. Mock application routes provide controlled callback results for channel, receive, acknowledgement, timeout, and upgrade tests. (testing/…/app.go• L382-486, testing/…/ibc_app.go• L12-120, testing/…/ibc_module.go• L29-160)

The mock modules also represent failure and asynchronous acknowledgement outcomes. The v2 mock module uses the same callback idea with packet status results. This lets protocol tests isolate core behavior from application business rules while still checking the callback contract. (testing/…/ibc_module.go• L108-153, testing/…/ibc_app.go• L11-16, testing/…/ibc_module.go• L28-79)

This relationship connects the infrastructure to the IBC core protocol and to the IBC application modules and middleware. Core tests can use the mock route when application behavior is not the subject. Application tests can use the transfer or middleware routes when the full cross-module path matters.

References: testing/…/app.go• L382-486 testing/…/ibc_app.go• L12-120 testing/…/ibc_module.go• L29-160 testing/…/middleware.go• L23-171 testing/…/ibc_module.go• L28-79

Event and callback surfaces

The harness turns chain events into the identifiers and packet values that the next scenario step needs. Event helpers support v1 packet fields and v2 encoded packets. They also check acknowledgement events and expected event attributes so tests can validate the observable contract between a transaction and the next relay action. (testing/events.go• L23-60, testing/events.go• L63-153, testing/events.go• L155-256, testing/events.go• L279-345)

These helpers keep scenario assembly independent of hard-coded identifiers. A changed event shape can therefore stop a flow even when the underlying transaction succeeds. The event tests cover successful v1 and v2 extraction and reject missing or malformed packet data. (testing/events_test.go• L23-228, testing/events_test.go• L230-392)

References: testing/events.go• L23-60 testing/events.go• L63-153 testing/events.go• L155-256 testing/events.go• L279-345 testing/events_test.go• L23-228 testing/events_test.go• L230-392

End-to-end environments

The end-to-end suite extends the same scenario idea to real processes. It uses Interchain Test to create chain and relayer containers on a shared Docker network. Tests can run chain commands, broadcast signed messages, query chain services, and observe the result of relayed packets. (e2e/README.md• L121-126, e2e/…/testsuite.go• L103-109)

An end-to-end suite creates its chains during suite setup. Each test then creates the clients, connections, and channels it needs. This split allows tests to run in parallel while keeping channel choices and chain-wide changes under the control of the individual test. (e2e/README.md• L128-142, e2e/…/testsuite.go• L162-204)

The end-to-end lifecycle is shown below.

flowchart TD
    Config[Test configuration] --> Build[Build chain containers]
    Build --> Chains[Start simulated chain processes]
    Chains --> Relayer[Create relayer pool]
    Relayer --> Paths[Create clients, connections, and channels]
    Paths --> Scenario[Run protocol scenario]
    Scenario --> Queries[Query chain state and events]
    Queries --> Diagnostics[Collect logs and debug state]

Chain and relayer setup

The end-to-end suite runs as a separate Go module. Its dependency boundary links the suite to local IBC code during development and provides the chain, relayer, and container clients needed for process-based tests. (e2e/go.mod#L1-L37)

The suite turns chain configuration into chain specifications. A configuration selects the binary, image, version, chain identity, node counts, and basic chain settings. The active relayer is selected from the configured relayer set. Configuration can come from a local YAML file or from environment overrides, with defaults for common local and CI runs. The suite validates the chain, relayer, chain-ID revision, upgrade, and debug settings before it starts the environment. (e2e/…/testconfig.go• L96-134, e2e/…/testconfig.go• L137-250, e2e/…/testconfig.go• L390-484, e2e/…/testconfig.go• L617-645, e2e/…/testconfig.go• L711-780)

The suite creates a pool of relayers before tests run. A test receives one relayer and keeps that assignment for its lifetime. The infrastructure supports the Cosmos relayer and Hermes. Hermes can be limited to the channels used by a test so parallel scenarios do not process unrelated traffic. (e2e/…/testsuite.go• L150-188, e2e/…/testsuite.go• L359-381, e2e/…/relayer.go• L43-109)

References: e2e/go.mod• L1-37 e2e/…/testconfig.go• L96-134 e2e/…/testconfig.go• L137-250 e2e/…/testconfig.go• L390-484 e2e/…/testconfig.go• L617-645 e2e/…/testconfig.go• L711-780 e2e/…/testsuite.go• L150-188 e2e/…/relayer.go• L43-109

Scenario paths and packet flushing

Tests create paths after the chains exist. Path creation generates a relayer path, creates clients, waits for chain progress, creates connections, and opens a channel. The suite records each path and channel by test name so later actions use the correct cross-chain link. (e2e/…/testsuite.go• L206-288, e2e/…/testsuite.go• L330-357)

Relaying can be started as a long-running process or driven as a controlled flush. A flush sends packets along a chain sequence and then sends acknowledgements back in reverse order. This supports both two-chain tests and multi-hop scenarios. (e2e/…/testsuite.go• L408-437, e2e/…/testsuite.go• L594-618)

References: e2e/…/testsuite.go• L206-288 e2e/…/testsuite.go• L330-357 e2e/…/testsuite.go• L408-437 e2e/…/testsuite.go• L594-618

Configuration and execution

The Makefile provides the normal local entry points. A single test resolves its suite entry point and runs the package that owns the test. A full suite runs the selected suite with parallel package execution. The setup step creates a default local configuration when needed and removes old test containers before a new run. (e2e/Makefile#L4-L19, e2e/…/init.sh• L9-28, e2e/…/run-e2e.sh• L61-103)

CI uses the same test model with a generated matrix. The matrix tool maps test functions to suite entry points. Build constraints keep end-to-end files out of normal local test runs. Compatibility annotations let release checks select tests for older chain versions. (e2e/README.md• L50-71, e2e/README.md• L155-179, e2e/…/base_test.go• L1-28)

References: e2e/Makefile• L4-19 e2e/…/init.sh• L9-28 e2e/…/run-e2e.sh• L61-103 e2e/README.md• L50-71 e2e/README.md• L155-179

Cross-chain validation

Validation checks both the action and its effect. End-to-end helpers query balances, packet commitments, packet acknowledgements, denomination metadata, and other chain state through query services. This keeps assertions on observable chain results instead of on the relayer's internal work. (e2e/…/testsuite.go• L649-707)

Scenario tests combine these checks with protocol events. For example, a transfer test verifies the source balance after escrow, starts the relayer, checks that the packet commitment is cleared, and checks the destination balance. Timeout and invalid-address cases verify that funds return to the source rather than only checking that a transaction was accepted. (e2e/…/base_test.go• L53-166, e2e/…/base_test.go• L169-273)

The suite also supports version and upgrade checks. A chain configuration can select different image tags for each chain. Genesis changes make governance and feature behavior usable in a test window. Upgrade tests then check state before and after the chain changes version. (e2e/…/testconfig.go• L435-484, e2e/…/testconfig.go• L783-797, e2e/…/upgrade_test.go• L1-80)

Evidence and diagnostics

The end-to-end environment treats logs and genesis state as test evidence. Suite cleanup can collect logs from containers before they are removed. Optional genesis export settings capture a selected chain's initial state for failure analysis. Docker helpers also read container files when a test needs data that is not available through a chain query. (e2e/…/testsuite.go• L111-148, e2e/…/testsuite.go• L710-738, e2e/…/dockerutil.go• L18-73)

References: e2e/…/testsuite.go• L111-148 e2e/…/testsuite.go• L649-707 e2e/…/testsuite.go• L710-738 e2e/…/dockerutil.go• L18-73

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the TestingApp contract aligned with the application returned by the default app creator. A mismatch can stop every local cross-chain scenario before it begins.
  • Keep simulated v1 and v2 router routes aligned with the application modules and mock callbacks that scenarios exercise. A route that exists in one environment but not the other can hide an integration break.
  • Keep the next-block context and commit flow aligned when tests write directly to keeper state. A write in the wrong state can disappear or affect a different block than the scenario expects.
  • Keep event attribute names and packet encodings aligned with the event parsers. A transaction can succeed while the next relay step cannot recover its packet or identifier.
  • Keep v2 client-counterparty registration aligned with endpoint identifiers and packet payloads. A mismatch can fail a packet path before application callbacks run.
  • Keep solo-machine proof paths and sequence updates aligned with the client state used by the scenario. A generated proof with stale sequence or path data is rejected as counterparty evidence.
  • Keep chain identity revisions compatible with client height parsing. Invalid or mismatched revisions can look like packet timeout failures.
  • Keep relayer path and channel tracking aligned with per-test ownership when changing parallel suite setup. A shared path or packet filter can send traffic to the wrong scenario.
  • Keep the generated test matrix and end-to-end build constraints aligned when moving suites or test files. Otherwise CI can omit a test or include it in normal local runs.
  • Keep version-gated genesis changes aligned with the chain image versions used by compatibility and upgrade tests.
  • Keep e2e/go.mod and e2e/go.sum aligned when changing the end-to-end dependency set. A module change that is not reflected in its checksums can stop the suite before a scenario runs.
  • Keep configuration validation aligned with every required chain, relayer, upgrade, and debug input. Invalid chain-ID revisions or missing active relayer entries must fail before container setup.
  • Keep configuration defaults and environment overrides aligned with the chain specifications built for single-test and suite modes. A tag, image, or relayer override that is applied in only one loading path can run the wrong process version.

Important failure modes

TriggerConsequenceGuard
A local test commits a block without advancing coordinator timeCounterparty headers can appear stale or in the futureUse coordinator block helpers and keep all simulated chain clocks under coordinator control
A test writes keeper state outside the next-block context or reads it before commitThe change can be lost or can affect the wrong block stateUse the chain context for the next block and commit before proof-based actions
A path uses a client, connection, channel, or v2 counterparty before the related state is currentProof checks or packet relay failComplete the setup stage and update the counterparty client before proof-based actions
An event changes its packet or identifier attributes without a matching parser changeA successful transaction cannot provide the next scenario inputPreserve the v1 and v2 event contracts and validate them with event parser tests
A v2 packet uses an unregistered client counterparty or an application returns an unsupported resultReceive or acknowledgement flow fails before the intended application checkRegister both counterparties and use the v2 callback result contract
A solo-machine sequence or commitment path does not match the generated proofThe simulated counterparty proof is rejectedGenerate each proof from the current solo-machine sequence and exact IBC path
Two parallel tests share a relayer without a channel filterThe relayer can process channels created by another testAssign relayers per test and apply the channel allow list where supported
A chain ID lacks the expected revision format or chain revisions differHeight checks can produce timeout-like failuresValidate chain IDs before building the test environment
A full suite changes chain-wide state or restarts a chain in parallelResults become non-deterministic or shared containers become invalidRun those tests without parallel execution and preserve containers when shared resources require it
A required image, binary, or active relayer entry is missing from configurationContainer setup fails before the scenario runsLoad and validate the complete test configuration before creating chains

Key files

FileWhy to read it
testing/README.mdExplains the local harness mental model and the expected way to assemble chains and paths.
testing/coordinator.goShows shared time and multi-chain coordination.
testing/chain.goShows how a simulated chain advances blocks, delivers messages, and supplies proofs.
testing/testing_app.goDefines how a custom SDK application joins the local harness.
testing/path.goShows how two endpoints become a client, connection, channel, counterparty, and packet path.
testing/endpoint.goShows the v1 protocol actions available on one side of a simulated link.
testing/endpoint_v2.goShows the v2 counterparty and packet actions used by the local harness.
testing/events.goShows how transaction events become identifiers, packets, acknowledgements, and assertions.
testing/solomachine.goShows how a signed solo-machine counterparty and its proofs are simulated.
testing/…/app.goShows the representative application and IBC router surfaces used by local integration tests.
testing/…/ante.goShows the transaction checks applied by the simulation app.
testing/config.goDefines the client, connection, and channel settings used to assemble local paths.
testing/…/ibc_module.goShows controlled v1 application callbacks and packet outcomes.
testing/…/ibc_module.goShows controlled v2 application callbacks and packet outcomes.
e2e/README.mdExplains end-to-end test design, local execution, CI selection, and compatibility runs.
e2e/go.modDefines the dependency boundary for the process-based end-to-end suite.
e2e/…/testsuite.goShows suite setup, path creation, relayer ownership, packet flushing, and observable assertions.
e2e/…/testconfig.goDefines how configuration files and environment overrides select chain images, relayers, versions, genesis changes, and debug settings for an end-to-end run.
e2e/…/relayer.goShows the relayer choices and channel filtering used by container tests.
e2e/…/base_test.goIllustrates a complete cross-chain scenario with state and failure assertions.