Categorygithub.com/decentrio/rollup-e2e-testing
modulepackage
0.0.0-20241209105820-1e7195a7441b
Repository: https://github.com/decentrio/rollup-e2e-testing.git
Documentation: pkg.go.dev

# README

Rollup-e2e-testing

Overview

Rollup-e2e-testing is designed as a framework for the purpose of testing rollup models such as Dymension, Rollkit, etc.

The framework is developed based on the architecture of interchaintest, osmosis-e2e, gaia-e2e,... to help quickly spin up custom testnets and dev environments to test IBC, Relayer setup, hub and rollapp infrastructure, smart contracts, etc.

Tutorial

Use Rollup-e2e-testing as a Module:

This document breaks down code snippets from ibc_transfer_test.go. This test:

  1. Spins up Rollapp and Dymension Hub
  2. Creates an IBC Path between them (client, connection, channel)
  3. Sends an IBC transaction between them.

It then validates each step and confirms that the balances of each wallet are correct.

Three basic components of rollup-e2e-testing:

  • Chain Factory - Select hub and rollapps binaries to include in tests
  • Relayer Factory - Select Relayer to use in tests
  • Setup - Where the testnet is configured and spun up

Chain Factory

	numHubVals := 1
	numHubFullNodes := 1
	numRollAppFn := 0
	numRollAppVals := 1
	cf := cosmos.NewBuiltinChainFactory(zaptest.NewLogger(t), []*cosmos.ChainSpec{
		{
			Name: "rollapp1",
			ChainConfig: ibc.ChainConfig{
				Type:    "rollapp",
				Name:    "rollapp-temp",
				ChainID: "demo-dymension-rollapp",
				Images: []ibc.DockerImage{
					{
						Repository: "ghcr.io/decentrio/rollapp",
						Version:    "e2e",
						UidGid:     "1025:1025",
					},
				},
				Bin:                 "rollappd",
				Bech32Prefix:        "rol",
				Denom:               "urax",
				CoinType:            "118",
				GasPrices:           "0.0urax",
				GasAdjustment:       1.1,
				TrustingPeriod:      "112h",
				NoHostMount:         false,
				ModifyGenesis:       nil,
				ConfigFileOverrides: configFileOverrides,
			},
			NumValidators: &numRollAppVals,
			NumFullNodes:  &numRollAppFn,
		},
		{
			Name:          "dymension-hub",
			ChainConfig:   dymensionConfig,
			NumValidators: &numHubVals,
			NumFullNodes:  &numHubFullNodes,
		},
	})

Relayer Factory

client, network := test.DockerSetup(t)

r := relayer.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t),
	relayer.CustomDockerImage("ghcr.io/cosmos/relayer", "reece-v2.3.1-ethermint", "100:1000"),
    ).Build(t, client, network)

Setup

We prep the "Setup" by adding chains, a relayer, and specifying which chains to create IBC paths for:

const ibcPath = "dymension-demo"
ic := test.NewSetup().
	AddChain(rollapp1).
	AddChain(dymension).
	AddRelayer(r, "relayer").
	AddLink(test.InterchainLink{
		Chain1:  dymension,
		Chain2:  rollapp1,
		Relayer: r,
		Path:    ibcPath,
	})

Environment Variable

  • SHOW_CONTAINER_LOGS: Controls whether container logs are displayed.

    • Set to "always" to show logs for both pass and fail.
    • Set to "never" to never show any logs.
    • Leave unset to show logs only for failed tests.
  • KEEP_CONTAINERS: Prevents testnet cleanup after completion.

    • Set to any non-empty value to keep testnet containers alive.
  • CONTAINER_LOG_TAIL: Specifies the number of lines to display from container logs. Defaults to 50 lines.

Branches

Branch NameIBC-GoCosmos-sdk
v6v6v0.46
mainv8v0.50

Example

Send IBC transaction from Rollapp <-> Hub and vice versa.

cd example
go test -race -v -run TestIBCTransfer .

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

DockerSetup returns a new Docker Client and the ID of a configured network, associated with t.
GetAndFundTestUsers generates and funds chain users with the native chain denom.
GetAndFundTestUserWithMnemonic restores a user using the given mnemonic and funds it with the native chain denom.
KeepDockerVolumesOnFailure sets whether volumes associated with a particular test are retained or deleted following a test failure.
NewBuiltinChainFactory returns a BuiltinChainFactory that returns chains defined by entries.
No description provided by the author
NewSetup returns a new Setup.

# Constants

No description provided by the author

# Structs

BuiltinChainFactory implements ChainFactory to return a fixed set of chains.
ChainSpec is a wrapper around an ibc.ChainConfig that allows callers to easily reference one of the built-in chain configs and optionally provide overrides for some settings.
InterchainBuildOptions describes configuration for (*Setup).Build.
InterchainLink describes a link between two chains, by specifying the chain names, the relayer name, and the name of the path to create.
No description provided by the author
Setup represents a full IBC network, encompassing a collection of one or more chains, one or more relayer instances, and initial account configuration.

# Interfaces

ChainFactory describes how to get chains for tests.
RelayerFactory describes how to start a Relayer.
No description provided by the author