block-sdk/tests/e2e
2023-12-20 09:49:11 -08:00
..
block_sdk_e2e_test.go chore: rename integration to e2e (#291) 2023-12-12 16:23:15 -08:00
block_sdk_suite.go chore: rename integration to e2e (#291) 2023-12-12 16:23:15 -08:00
chain_setup.go chore: rename integration to e2e (#291) 2023-12-12 16:23:15 -08:00
go.mod test: use chaintestutil (#296) 2023-12-13 09:01:14 -05:00
go.sum test: use chaintestutil (#296) 2023-12-13 09:01:14 -05:00
README.md chore: Add e2e test readme (#319) 2023-12-20 09:49:11 -08:00

Block SDK E2E Tests

Integrating/Running Tests In Your Project

The Block SDK E2E tests are built around interchaintest. To run the full set of predefined test cases using your chain you can follow the steps below:

Integrate the Block SDK into your project

You will need to pull in the Block SDK as a dependency of your project. You can follow the guides located in our integration docs or this README for detailed instructions.
You can refer to this PR as one example of how the Block SDK can be integrated into an application. Be aware that each chain will have different requirements and this example may not be fully applicable to yours. Additionally, future versions may introduce new requirements.

Define a container image

Interchaintest will require a Docker image in order to spin up your chain's application. If you do not already have a container build setup that launches your application's binary you will need to define one.
An example of the Block SDK's test app's Docker build can be referenced here.

Create an InterchainTest Chain Spec

The test suite uses the interchaintest.ChainSpec to define the specifics around running your application. You'll need to define the number of validator and full node containers to run, the docker image, the genesis state, encoding config, and various other variables.
Some examples of ChainSpecs follow:

Instantiate the test suite and run the tests

You will need to pull the Block SDK's tests into your project as a separate dependency. It might be useful to do this in a separate go submodule specifically for running these tests (for example)

github.com/skip-mev/block-sdk/tests/integration {vLatest}

The following snippet is usually suitable.

func TestBlockSDKSuite(t *testing.T) {
	s := integration.NewIntegrationTestSuiteFromSpec(spec)
	s.WithDenom(denom)
	s.WithKeyringOptions(encodingConfig.Codec, keyring.Option())
	suite.Run(t, s)

Run the tests

Add a separate makefile target to run your tests.

go test -v -race -run TestBlockSDKSuite