From 47be6be7dc21572a7502eee51f85f38ab8202f01 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 10:56:27 +0100 Subject: [PATCH 01/28] feat(e2e): adding script to dynamically generate list of e2e tests --- .github/scripts/build_test_matrix.go | 127 ++++++++++++++++++++ .github/scripts/build_test_matrix_test.go | 139 ++++++++++++++++++++++ .github/workflows/test.yml | 2 +- Makefile | 2 +- 4 files changed, 268 insertions(+), 2 deletions(-) create mode 100644 .github/scripts/build_test_matrix.go create mode 100644 .github/scripts/build_test_matrix_test.go diff --git a/.github/scripts/build_test_matrix.go b/.github/scripts/build_test_matrix.go new file mode 100644 index 00000000000..8e736cf341c --- /dev/null +++ b/.github/scripts/build_test_matrix.go @@ -0,0 +1,127 @@ +package main + +import ( + "encoding/json" + "fmt" + "go/ast" + "go/parser" + "go/token" + "io/fs" + "os" + "path/filepath" + "strings" +) + +const ( + testNamePrefix = "Test" + testFileNameSuffix = "_test.go" + e2eTestDirectory = "e2e" +) + +// GithubActionTestMatrix represents +type GithubActionTestMatrix struct { + Include []TestSuitePair `json:"include"` +} + +type TestSuitePair struct { + Test string `json:"test"` + Suite string `json:"suite"` +} + +func main() { + githubActionMatrix, err := getGithubActionMatrixForTests(e2eTestDirectory) + if err != nil { + fmt.Printf("error generating github action json: %s", err) + os.Exit(1) + } + + ghBytes, err := json.Marshal(githubActionMatrix) + if err != nil { + fmt.Printf("error marshalling github action json: %s", err) + os.Exit(1) + } + fmt.Println(string(ghBytes)) +} + +// getGithubActionMatrixForTests returns a json string representing the contents that should go in the matrix +// field in a github action workflow. This string can be used with `fromJSON(str)` to dynamically build +// the workflow matrix to include all E2E tests under the e2eRootDirectory directory. +func getGithubActionMatrixForTests(e2eRootDirectory string) (GithubActionTestMatrix, error) { + testSuiteMapping := map[string][]string{} + fset := token.NewFileSet() + err := filepath.Walk(e2eRootDirectory, func(path string, info fs.FileInfo, err error) error { + // only look at test files + if !strings.HasSuffix(path, testFileNameSuffix) { + return nil + } + + f, err := parser.ParseFile(fset, path, nil, 0) + if err != nil { + return fmt.Errorf("failed parsing file: %s", err) + } + + suiteNameForFile, testCases, err := extractSuiteAndTestNames(f) + if err != nil { + return fmt.Errorf("failed extracting test suite name and test cases: %s", err) + } + + testSuiteMapping[suiteNameForFile] = testCases + + return nil + }) + + if err != nil { + return GithubActionTestMatrix{}, err + } + + gh := GithubActionTestMatrix{ + Include: []TestSuitePair{}, + } + + for testSuiteName, testCases := range testSuiteMapping { + for _, testCaseName := range testCases { + gh.Include = append(gh.Include, TestSuitePair{ + Test: testCaseName, + Suite: testSuiteName, + }) + } + } + + return gh, nil +} + +// extractSuiteAndTestNames extracts the name of the test suite function as well +// as all tests associated with it in the same file. +func extractSuiteAndTestNames(file *ast.File) (string, []string, error) { + var suiteNameForFile string + var testCases []string + + for _, d := range file.Decls { + if f, ok := d.(*ast.FuncDecl); ok { + functionName := f.Name.Name + if isTestSuiteMethod(f) { + suiteNameForFile = functionName + continue + } + if isTestFunction(f) { + testCases = append(testCases, functionName) + } + } + } + if suiteNameForFile == "" { + return "", nil, fmt.Errorf("file %s had no test suite test case", file.Name.Name) + } + return suiteNameForFile, testCases, nil +} + +// isTestSuiteMethod returns true if the function is a test suite function. +// e.g. func TestFeeMiddlewareTestSuite(t *testing.T) { ... } +func isTestSuiteMethod(f *ast.FuncDecl) bool { + return strings.HasPrefix(f.Name.Name, testNamePrefix) && len(f.Type.Params.List) == 1 +} + +// isTestFunction returns true if the function name starts with "Test" and has no parameters. +// as test suite functions to not accept a testing.T. +func isTestFunction(f *ast.FuncDecl) bool { + return strings.HasPrefix(f.Name.Name, testNamePrefix) && len(f.Type.Params.List) == 0 +} diff --git a/.github/scripts/build_test_matrix_test.go b/.github/scripts/build_test_matrix_test.go new file mode 100644 index 00000000000..82445fd7da6 --- /dev/null +++ b/.github/scripts/build_test_matrix_test.go @@ -0,0 +1,139 @@ +package main + +import ( + "os" + "path" + "sort" + "strings" + "testing" + + "github.com/stretchr/testify/assert" +) + +const ( + nonTestFile = "not_test_file.go" + goTestFileNameOne = "first_go_file_test.go" + goTestFileNameTwo = "second_go_file_test.go" +) + +func TestGetGithubActionMatrixForTests(t *testing.T) { + t.Run("empty dir does not fail", func(t *testing.T) { + testingDir := t.TempDir() + _, err := getGithubActionMatrixForTests(testingDir) + assert.NoError(t, err) + }) + + t.Run("only test functions are picked up", func(t *testing.T) { + testingDir := t.TempDir() + createFileWithTestSuiteAndTests(t, "TestFeeMiddlewareTestSuite", "TestA", "TestB", testingDir, goTestFileNameOne) + + gh, err := getGithubActionMatrixForTests(testingDir) + assert.NoError(t, err) + + expected := GithubActionTestMatrix{ + Include: []TestSuitePair{ + { + Suite: "TestFeeMiddlewareTestSuite", + Test: "TestA", + }, + { + Suite: "TestFeeMiddlewareTestSuite", + Test: "TestB", + }, + }, + } + assertGithubActionTestMatricesEqual(t, expected, gh) + }) + + t.Run("all files are picked up", func(t *testing.T) { + testingDir := t.TempDir() + createFileWithTestSuiteAndTests(t, "TestFeeMiddlewareTestSuite", "TestA", "TestB", testingDir, goTestFileNameOne) + createFileWithTestSuiteAndTests(t, "TestTransferTestSuite", "TestC", "TestD", testingDir, goTestFileNameTwo) + + gh, err := getGithubActionMatrixForTests(testingDir) + assert.NoError(t, err) + + expected := GithubActionTestMatrix{ + Include: []TestSuitePair{ + { + Suite: "TestTransferTestSuite", + Test: "TestC", + }, + { + Suite: "TestFeeMiddlewareTestSuite", + Test: "TestA", + }, + { + Suite: "TestFeeMiddlewareTestSuite", + Test: "TestB", + }, + { + Suite: "TestTransferTestSuite", + Test: "TestD", + }, + }, + } + + assertGithubActionTestMatricesEqual(t, expected, gh) + }) + + t.Run("non test files are not picked up", func(t *testing.T) { + testingDir := t.TempDir() + createFileWithTestSuiteAndTests(t, "TestFeeMiddlewareTestSuite", "TestA", "TestB", testingDir, nonTestFile) + + gh, err := getGithubActionMatrixForTests(testingDir) + assert.NoError(t, err) + assert.Empty(t, gh.Include) + }) +} + +func assertGithubActionTestMatricesEqual(t *testing.T, expected, actual GithubActionTestMatrix) { + // sort by both suite and test as the order of the end result does not matter as + // all tests will be run. + sort.SliceStable(expected.Include, func(i, j int) bool { + memberI := expected.Include[i] + memberJ := expected.Include[j] + if memberI.Suite == memberJ.Suite { + return memberI.Test < memberJ.Test + } + return memberI.Suite < memberJ.Suite + }) + + sort.SliceStable(actual.Include, func(i, j int) bool { + memberI := actual.Include[i] + memberJ := actual.Include[j] + if memberI.Suite == memberJ.Suite { + return memberI.Test < memberJ.Test + } + return memberI.Suite < memberJ.Suite + }) + assert.Equal(t, expected.Include, actual.Include) +} + +func goTestFileContents(suiteName, fnName1, fnName2 string) string { + + replacedSuiteName := strings.ReplaceAll(`package foo + +func SuiteName(t *testing.T) { + suite.Run(t, new(FeeMiddlewareTestSuite)) +} + +type SuiteName struct {} + +func (s *SuiteName) fnName1() {} +func (s *SuiteName) fnName2() {} + +func (s *SuiteName) suiteHelper() {} + +func helper() {} +`, "SuiteName", suiteName) + + replacedFn1Name := strings.ReplaceAll(replacedSuiteName, "fnName1", fnName1) + return strings.ReplaceAll(replacedFn1Name, "fnName2", fnName2) +} + +func createFileWithTestSuiteAndTests(t *testing.T, suiteName, fn1Name, fn2Name, dir, filename string) { + goFileContents := goTestFileContents(suiteName, fn1Name, fn2Name) + err := os.WriteFile(path.Join(dir, filename), []byte(goFileContents), os.FileMode(777)) + assert.NoError(t, err) +} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c915db779cd..ff8ed4d65d9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Create a file with all the pkgs - run: go list ./... > pkgs.txt + run: go list ./... ./.github/scripts > pkgs.txt - name: Split pkgs into 4 files run: split -d -n l/4 pkgs.txt pkgs.txt.part. # cache multiple diff --git a/Makefile b/Makefile index 0ea7f0c10c5..9beb4ab61bc 100644 --- a/Makefile +++ b/Makefile @@ -216,7 +216,7 @@ view-docs: test: test-unit test-all: test-unit test-ledger-mock test-race test-cover -TEST_PACKAGES=./... +TEST_PACKAGES=./... ./.github/scripts TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-race test-ledger test-race # Test runs-specific rules. To add a new test target, just add From ce804118a10783d166c484121e67773773effdc6 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 11:27:49 +0100 Subject: [PATCH 02/28] feat(e2e): adding github CI to run E2E tests --- .github/workflows/test.yml | 89 +++++++++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ff8ed4d65d9..43fa59bcc77 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,10 @@ on: push: branches: - main +env: + REGISTRY: ghcr.io + IMAGE_NAME: ibc-go-simd-e2e + jobs: cleanup-runs: runs-on: ubuntu-latest @@ -51,13 +55,6 @@ jobs: - name: Build run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build - docker-build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Docker Build - run: docker build . --no-cache - split-test-files: runs-on: ubuntu-latest steps: @@ -161,3 +158,81 @@ jobs: with: file: ./coverage.txt if: env.GIT_DIFF + + + docker-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a + with: + images: ${{ env.REGISTRY }}/cosmos/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + # dynamically build a matrix of test/test suite pairs to run + build-test-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + - id: set-matrix + run: echo "::set-output name=matrix::$(go run .github/scripts/build_test_matrix.go)" + + + # the tag of the image will differ if this is a PR or the branch is being merged into main. + # we store the tag as an environment variable and use it in the E2E tests to determine the tag. + determine-image-tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + # if the PR is not yet merged, the tag will look like "pr-1234" + - if: github.event.pull_request.merged != 'true' + run: echo "SIMD_TAG=pr-${{ github.event.number }}" >> $GITHUB_ENV + # the tag will be "main" when a PR is merged + - if: github.event.pull_request.merged == 'true' >> $GITHUB_ENV + run: echo "SIMD_TAG=main" + + e2e: + runs-on: ubuntu-latest + needs: + - build-test-matrix + - determine-image-tag + - docker-build + env: + SIMD_TAG: ${{ env.SIMD_TAG }} + SIMD_IMAGE: ghcr.io/cosmos/ibc-go-simd-e2e + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.build-test-matrix.outputs.matrix) }} + steps: + - uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Run e2e Test + run: | + make e2e-test suite=${{ matrix.suite }} test=${{ matrix.test }} From bfbba0323fda1df561679b14d20cfd5e81c587b7 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 11:30:34 +0100 Subject: [PATCH 03/28] feat(e2e) adding placeholder test for github action to execute --- e2e/fee_middleware_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 e2e/fee_middleware_test.go diff --git a/e2e/fee_middleware_test.go b/e2e/fee_middleware_test.go new file mode 100644 index 00000000000..58d66f7fd96 --- /dev/null +++ b/e2e/fee_middleware_test.go @@ -0,0 +1,20 @@ +package e2e + +import ( + "testing" + + "github.com/stretchr/testify/suite" +) + +func TestFeeMiddlewareTestSuite(t *testing.T) { + suite.Run(t, new(FeeMiddlewareTestSuite)) +} + +type FeeMiddlewareTestSuite struct { + suite.Suite +} + +func (s *FeeMiddlewareTestSuite) TestPlaceholder() { + s.T().Logf("Placeholder test") + s.Require().True(true) +} From 4569fa56e8e37824fc8a38c110ea2ccfc76bedda Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 11:41:56 +0100 Subject: [PATCH 04/28] wip: extracting correct tag for image --- .github/workflows/test.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 43fa59bcc77..3c9af80bcb3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -199,19 +199,23 @@ jobs: - id: set-matrix run: echo "::set-output name=matrix::$(go run .github/scripts/build_test_matrix.go)" + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" # the tag of the image will differ if this is a PR or the branch is being merged into main. # we store the tag as an environment variable and use it in the E2E tests to determine the tag. - determine-image-tag: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - # if the PR is not yet merged, the tag will look like "pr-1234" - - if: github.event.pull_request.merged != 'true' - run: echo "SIMD_TAG=pr-${{ github.event.number }}" >> $GITHUB_ENV - # the tag will be "main" when a PR is merged - - if: github.event.pull_request.merged == 'true' >> $GITHUB_ENV - run: echo "SIMD_TAG=main" +# determine-image-tag: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# # if the PR is not yet merged, the tag will look like "pr-1234" +# - if: github.event.pull_request.merged != 'true' +# run: echo "SIMD_TAG=pr-${{ github.event.number }}" >> $GITHUB_ENV +# # the tag will be "main" when a PR is merged +# - if: github.event.pull_request.merged == 'true' >> $GITHUB_ENV +# run: echo "SIMD_TAG=main" e2e: runs-on: ubuntu-latest @@ -220,7 +224,7 @@ jobs: - determine-image-tag - docker-build env: - SIMD_TAG: ${{ env.SIMD_TAG }} + SIMD_TAG: ${{ github.event.pull_request.number || github.event.push.ref }} SIMD_IMAGE: ghcr.io/cosmos/ibc-go-simd-e2e strategy: fail-fast: false From 272ad61cde08e33275a065533ef6503be5885b21 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 11:43:18 +0100 Subject: [PATCH 05/28] wip: extracting correct tag for image --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c9af80bcb3..dd5518c7c89 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,7 @@ on: push: branches: - main + env: REGISTRY: ghcr.io IMAGE_NAME: ibc-go-simd-e2e From 6afe90c5a474bbd418ba3cc694cf790aa1cdf6a8 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 11:44:58 +0100 Subject: [PATCH 06/28] wip: corrected workflow syntax --- .github/workflows/test.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dd5518c7c89..de15953c4af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -200,10 +200,13 @@ jobs: - id: set-matrix run: echo "::set-output name=matrix::$(go run .github/scripts/build_test_matrix.go)" - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" + dump-github-context: + runs-on: ubuntu-latest + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" # the tag of the image will differ if this is a PR or the branch is being merged into main. # we store the tag as an environment variable and use it in the E2E tests to determine the tag. From 7497574cdb6bfe9854eaacef7c6a2f725fd8ab09 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 11:45:47 +0100 Subject: [PATCH 07/28] wip: corrected workflow syntax --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de15953c4af..cf010d26f03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -202,11 +202,11 @@ jobs: dump-github-context: runs-on: ubuntu-latest + env: + GITHUB_CONTEXT: ${{ toJson(github) }} steps: - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" + run: echo "$GITHUB_CONTEXT" # the tag of the image will differ if this is a PR or the branch is being merged into main. # we store the tag as an environment variable and use it in the E2E tests to determine the tag. From 7091fbc64fa4874dadefeff1d9023609ae087e1f Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 11:46:22 +0100 Subject: [PATCH 08/28] removed unreferenced job --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf010d26f03..4184b5af718 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -225,7 +225,7 @@ jobs: runs-on: ubuntu-latest needs: - build-test-matrix - - determine-image-tag +# - determine-image-tag - docker-build env: SIMD_TAG: ${{ github.event.pull_request.number || github.event.push.ref }} From 6ebcc6d5c9190807db70b59efbe275ab9bab380a Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 11:49:15 +0100 Subject: [PATCH 09/28] wip: adding makefile --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 9beb4ab61bc..df259c5a477 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ MOCKS_DIR = $(CURDIR)/tests/mocks HTTPS_GIT := https://github.com/cosmos/ibc-go.git DOCKER := $(shell which docker) DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8 +TEST_CONTAINERS=$(shell docker ps --filter "label=ibc-test" -a -q) export GO111MODULE = on @@ -324,6 +325,15 @@ benchmark: @go test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION) .PHONY: benchmark +cleanup-ibc-test-containers: + for id in $(TEST_CONTAINERS) ; do \ + $(DOCKER) stop $$id ; \ + $(DOCKER) rm $$id ; \ + done + +e2e-test: cleanup-ibc-test-containers + @go test -v ./e2e --run $(suite) -testify.m ^$(test)$$ + ############################################################################### ### Linting ### ############################################################################### From 05d9a45ac9dee868ac6c40bedb663fe66569c6c2 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 11:55:32 +0100 Subject: [PATCH 10/28] wip: displaying env vars in placeholder test --- .github/workflows/test.yml | 2 +- e2e/fee_middleware_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4184b5af718..61b4926a91c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -228,7 +228,7 @@ jobs: # - determine-image-tag - docker-build env: - SIMD_TAG: ${{ github.event.pull_request.number || github.event.push.ref }} + SIMD_TAG: ${{ github.event.push.ref}} || pr-${{ github.event.pull_request.number }} SIMD_IMAGE: ghcr.io/cosmos/ibc-go-simd-e2e strategy: fail-fast: false diff --git a/e2e/fee_middleware_test.go b/e2e/fee_middleware_test.go index 58d66f7fd96..33327ecfb15 100644 --- a/e2e/fee_middleware_test.go +++ b/e2e/fee_middleware_test.go @@ -1,6 +1,7 @@ package e2e import ( + "os" "testing" "github.com/stretchr/testify/suite" @@ -15,6 +16,14 @@ type FeeMiddlewareTestSuite struct { } func (s *FeeMiddlewareTestSuite) TestPlaceholder() { + tag, ok := os.LookupEnv("SIMD_TAG") + s.Require().True(ok) + s.T().Logf("SIMD_TAG=%s", tag) + + image, ok := os.LookupEnv("SIMD_IMAGE") + s.Require().True(ok) + s.T().Logf("SIMD_IMAGE=%s", image) + s.T().Logf("Placeholder test") s.Require().True(true) } From 308eb0ff2845ad36c7e3de9803e54d61c0070da7 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 12:14:36 +0100 Subject: [PATCH 11/28] wip: adding go script to determine simd tag --- .github/scripts/determine_simd_tag.go | 33 +++++++++++++++++++++++++++ .github/workflows/test.yml | 25 ++++++++++++++------ 2 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 .github/scripts/determine_simd_tag.go diff --git a/.github/scripts/determine_simd_tag.go b/.github/scripts/determine_simd_tag.go new file mode 100644 index 00000000000..804cef7a870 --- /dev/null +++ b/.github/scripts/determine_simd_tag.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "os" + "strconv" +) + +func main() { + args := os.Args + if len(args) != 3 { + fmt.Println("must specify exactly 2 args, ref and PR number") + os.Exit(1) + } + + tag, err := determineSimdTag(args[1], args[2]) + if err != nil { + fmt.Printf("failed to determine tag: %s", err) + os.Exit(1) + } + fmt.Println(tag) +} + +func determineSimdTag(ref, prNumber string) (string, error) { + if ref != "" { + return ref, nil + } + prNumm, err := strconv.Atoi(prNumber) + if err != nil { + return "", err + } + return fmt.Sprintf("pr-%d", prNumm), nil +} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61b4926a91c..e2276e6ee98 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -106,7 +106,7 @@ jobs: if: env.GIT_DIFF - name: test & coverage report creation run: | - cat pkgs.txt.part.${{ matrix.part }} | xargs go test -race -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock' + cat pkgs.txt.part.${{ matrix.part }} | xargs go test $(go list ./... | grep -v e2e) -race -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock' if: env.GIT_DIFF - uses: actions/upload-artifact@v3 with: @@ -210,10 +210,18 @@ jobs: # the tag of the image will differ if this is a PR or the branch is being merged into main. # we store the tag as an environment variable and use it in the E2E tests to determine the tag. -# determine-image-tag: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 + determine-image-tag: + runs-on: ubuntu-latest + outputs: + simd-tag: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + - id: get-tag + run: echo "::set-output name=simd-tag::$(go run .github/scripts/determine_simd_tag.go ${{ github.event.push.ref}} ${{ github.event.pull_request.number }} )" + # # if the PR is not yet merged, the tag will look like "pr-1234" # - if: github.event.pull_request.merged != 'true' # run: echo "SIMD_TAG=pr-${{ github.event.number }}" >> $GITHUB_ENV @@ -221,14 +229,17 @@ jobs: # - if: github.event.pull_request.merged == 'true' >> $GITHUB_ENV # run: echo "SIMD_TAG=main" + +# ${{ github.event.push.ref}} || pr-${{ github.event.pull_request.number }} + e2e: runs-on: ubuntu-latest needs: - build-test-matrix -# - determine-image-tag + - determine-image-tag - docker-build env: - SIMD_TAG: ${{ github.event.push.ref}} || pr-${{ github.event.pull_request.number }} + SIMD_TAG: ${{ needs.determine-image-tag.outputs.simd-tag }} SIMD_IMAGE: ghcr.io/cosmos/ibc-go-simd-e2e strategy: fail-fast: false From 9ebacd70b421800ecc415dc788af746c09eab384 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 12:17:26 +0100 Subject: [PATCH 12/28] fix: corrected outputs name in test.yml --- .github/scripts/determine_simd_tag.go | 4 ++++ .github/workflows/test.yml | 11 +---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/scripts/determine_simd_tag.go b/.github/scripts/determine_simd_tag.go index 804cef7a870..7c54dcc1acc 100644 --- a/.github/scripts/determine_simd_tag.go +++ b/.github/scripts/determine_simd_tag.go @@ -21,6 +21,10 @@ func main() { fmt.Println(tag) } +// determineSimdTag returns the tag which should be used for the E2E test image. +// when a ref is specified, this will usually be "main" which is the tag that should be +// used once a branch has been merged to main. If a PR number is specified, then the format +// of the tag will be "pr-1234". func determineSimdTag(ref, prNumber string) (string, error) { if ref != "" { return ref, nil diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e2276e6ee98..4c44d61f7b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -213,7 +213,7 @@ jobs: determine-image-tag: runs-on: ubuntu-latest outputs: - simd-tag: ${{ steps.set-matrix.outputs.matrix }} + simd-tag: ${{ steps.get-tag.outputs.matrix }} steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -222,15 +222,6 @@ jobs: - id: get-tag run: echo "::set-output name=simd-tag::$(go run .github/scripts/determine_simd_tag.go ${{ github.event.push.ref}} ${{ github.event.pull_request.number }} )" -# # if the PR is not yet merged, the tag will look like "pr-1234" -# - if: github.event.pull_request.merged != 'true' -# run: echo "SIMD_TAG=pr-${{ github.event.number }}" >> $GITHUB_ENV -# # the tag will be "main" when a PR is merged -# - if: github.event.pull_request.merged == 'true' >> $GITHUB_ENV -# run: echo "SIMD_TAG=main" - - -# ${{ github.event.push.ref}} || pr-${{ github.event.pull_request.number }} e2e: runs-on: ubuntu-latest From c4318506dd046640dfe6b031b29ccbd2974afaea Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 12:21:15 +0100 Subject: [PATCH 13/28] fix: specifying correct output name --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4c44d61f7b9..9b291492bb9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -213,7 +213,7 @@ jobs: determine-image-tag: runs-on: ubuntu-latest outputs: - simd-tag: ${{ steps.get-tag.outputs.matrix }} + simd-tag: ${{ steps.get-tag.outputs.simd-tag }} steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 From 3c4f62b4160581c117cd4b27b23f7457d5d1cab4 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 12:29:14 +0100 Subject: [PATCH 14/28] fix: updating go script to accept a single argument --- .github/scripts/determine_simd_tag.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/scripts/determine_simd_tag.go b/.github/scripts/determine_simd_tag.go index 7c54dcc1acc..8b6323969bf 100644 --- a/.github/scripts/determine_simd_tag.go +++ b/.github/scripts/determine_simd_tag.go @@ -8,12 +8,13 @@ import ( func main() { args := os.Args - if len(args) != 3 { - fmt.Println("must specify exactly 2 args, ref and PR number") + + if len(args) < 2 { + fmt.Printf("a ref or PR number is expected, provided: %+v\n", args) os.Exit(1) } - tag, err := determineSimdTag(args[1], args[2]) + tag, err := determineSimdTag(args[1]) if err != nil { fmt.Printf("failed to determine tag: %s", err) os.Exit(1) @@ -25,13 +26,17 @@ func main() { // when a ref is specified, this will usually be "main" which is the tag that should be // used once a branch has been merged to main. If a PR number is specified, then the format // of the tag will be "pr-1234". -func determineSimdTag(ref, prNumber string) (string, error) { - if ref != "" { - return ref, nil +func determineSimdTag(input string) (string, error) { + if input == "" { + return "", fmt.Errorf("empty input was provided") } - prNumm, err := strconv.Atoi(prNumber) - if err != nil { - return "", err + + // attempt to extract PR number + prNumm, err := strconv.Atoi(input) + if err == nil { + return fmt.Sprintf("pr-%d", prNumm), nil } - return fmt.Sprintf("pr-%d", prNumm), nil + + // a ref was provided instead, e.g. "main" + return input, nil } From b5fff2acad5159431e4801edbcf4e70b14fc6397 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 12:48:15 +0100 Subject: [PATCH 15/28] chore: greatly simplifying determine_simd_tag.go --- .github/scripts/determine_simd_tag.go | 43 ++++++++++----------------- .github/workflows/test.yml | 2 +- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/.github/scripts/determine_simd_tag.go b/.github/scripts/determine_simd_tag.go index 8b6323969bf..2cb527a91a2 100644 --- a/.github/scripts/determine_simd_tag.go +++ b/.github/scripts/determine_simd_tag.go @@ -1,42 +1,31 @@ package main import ( + "flag" "fmt" "os" - "strconv" ) -func main() { - args := os.Args +var prNum int +var ref string - if len(args) < 2 { - fmt.Printf("a ref or PR number is expected, provided: %+v\n", args) - os.Exit(1) - } +func init() { + flag.IntVar(&prNum, "pr", 0, "the number of the pr") + flag.StringVar(&ref, "ref", "", "the github ref") + flag.Parse() +} - tag, err := determineSimdTag(args[1]) - if err != nil { - fmt.Printf("failed to determine tag: %s", err) +func main() { + if prNum == 0 && ref == "" { + fmt.Printf("must specify exactly one of [pr, ref]") os.Exit(1) } - fmt.Println(tag) + fmt.Printf(getSimdTag(prNum, ref)) } -// determineSimdTag returns the tag which should be used for the E2E test image. -// when a ref is specified, this will usually be "main" which is the tag that should be -// used once a branch has been merged to main. If a PR number is specified, then the format -// of the tag will be "pr-1234". -func determineSimdTag(input string) (string, error) { - if input == "" { - return "", fmt.Errorf("empty input was provided") - } - - // attempt to extract PR number - prNumm, err := strconv.Atoi(input) - if err == nil { - return fmt.Sprintf("pr-%d", prNumm), nil +func getSimdTag(prNum int, ref string) string { + if ref != "" { + return ref } - - // a ref was provided instead, e.g. "main" - return input, nil + return fmt.Sprintf("pr-%d", prNum) } diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9b291492bb9..8a5bad662d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -220,7 +220,7 @@ jobs: with: go-version: 1.18 - id: get-tag - run: echo "::set-output name=simd-tag::$(go run .github/scripts/determine_simd_tag.go ${{ github.event.push.ref}} ${{ github.event.pull_request.number }} )" + run: echo "::set-output name=simd-tag::$(go run .github/scripts/determine_simd_tag.go -ref ${{ github.event.push.ref}} -pr ${{ github.event.pull_request.number }} )" e2e: From abb0eca9aba65cfa9a4fd4dce5287990cd7acf92 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 12:55:53 +0100 Subject: [PATCH 16/28] chore: adding docstring to determine_simd_tag.go --- .github/scripts/determine_simd_tag.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/scripts/determine_simd_tag.go b/.github/scripts/determine_simd_tag.go index 2cb527a91a2..3fb4ce6986f 100644 --- a/.github/scripts/determine_simd_tag.go +++ b/.github/scripts/determine_simd_tag.go @@ -15,9 +15,12 @@ func init() { flag.Parse() } +// in the context of a GithubAction workflow, the PR is the event number. So if the ref is not specified +// but the event number is, that means we are running for a PR. If the ref is specified, this means +// we have merged the PR, so we want to use the ref as a tag instead of the PR number. func main() { if prNum == 0 && ref == "" { - fmt.Printf("must specify exactly one of [pr, ref]") + fmt.Printf("must specify one or bot of [pr, ref]") os.Exit(1) } fmt.Printf(getSimdTag(prNum, ref)) From f36025bd282293590079960723918872e3786404 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 13:01:51 +0100 Subject: [PATCH 17/28] chore: extract output variable --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8a5bad662d3..1091550e916 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -220,7 +220,9 @@ jobs: with: go-version: 1.18 - id: get-tag - run: echo "::set-output name=simd-tag::$(go run .github/scripts/determine_simd_tag.go -ref ${{ github.event.push.ref}} -pr ${{ github.event.pull_request.number }} )" + run: | + tag=$(go run .github/scripts/determine_simd_tag.go -ref "${{ github.event.push.ref }}" -pr "${{ github.event.pull_request.number }}" ) + echo "::set-output name=simd-tag::$tag" e2e: From 903913741240b2c16e56e411456dcad864315d96 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 13:12:45 +0100 Subject: [PATCH 18/28] chore: adding echo to display the tag in the workflow --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1091550e916..94f0db65ada 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -222,6 +222,7 @@ jobs: - id: get-tag run: | tag=$(go run .github/scripts/determine_simd_tag.go -ref "${{ github.event.push.ref }}" -pr "${{ github.event.pull_request.number }}" ) + echo "Using tag $tag" echo "::set-output name=simd-tag::$tag" From 30591c94c08fd019ab8f6d06ce2184f02059037b Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 14:12:32 +0100 Subject: [PATCH 19/28] feat(e2e): adding E2ETestSuite --- Dockerfile | 2 +- e2e/fee_middleware_test.go | 28 ++-- e2e/testconfig/testconfig.go | 36 +++++ e2e/testsuite/testsuite.go | 285 +++++++++++++++++++++++++++++++++++ go.mod | 36 ++++- go.sum | 96 +++++++++++- 6 files changed, 463 insertions(+), 20 deletions(-) create mode 100644 e2e/testconfig/testconfig.go create mode 100644 e2e/testsuite/testsuite.go diff --git a/Dockerfile b/Dockerfile index a193f54906e..6420e1cb3fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,4 +20,4 @@ FROM ubuntu:20.04 COPY --from=builder /go/build/simd /bin/simd -ENTRYPOINT ["simd"] +#ENTRYPOINT ["simd"] diff --git a/e2e/fee_middleware_test.go b/e2e/fee_middleware_test.go index 33327ecfb15..fced71177f2 100644 --- a/e2e/fee_middleware_test.go +++ b/e2e/fee_middleware_test.go @@ -1,10 +1,13 @@ package e2e import ( - "os" + "context" "testing" + "github.com/strangelove-ventures/ibctest/ibc" "github.com/stretchr/testify/suite" + + "github.com/cosmos/ibc-go/v4/e2e/testsuite" ) func TestFeeMiddlewareTestSuite(t *testing.T) { @@ -12,18 +15,23 @@ func TestFeeMiddlewareTestSuite(t *testing.T) { } type FeeMiddlewareTestSuite struct { - suite.Suite + testsuite.E2ETestSuite } func (s *FeeMiddlewareTestSuite) TestPlaceholder() { - tag, ok := os.LookupEnv("SIMD_TAG") - s.Require().True(ok) - s.T().Logf("SIMD_TAG=%s", tag) + ctx := context.Background() + r := s.CreateChainsRelayerAndChannel(ctx, feeMiddlewareChannelOptions()) + s.T().Run("start relayer", func(t *testing.T) { + s.StartRelayer(r) + }) - image, ok := os.LookupEnv("SIMD_IMAGE") - s.Require().True(ok) - s.T().Logf("SIMD_IMAGE=%s", image) +} - s.T().Logf("Placeholder test") - s.Require().True(true) +// feeMiddlewareChannelOptions configures both of the chains to have fee middleware enabled. +func feeMiddlewareChannelOptions() func(options *ibc.CreateChannelOptions) { + return func(opts *ibc.CreateChannelOptions) { + opts.Version = "{\"fee_version\":\"ics29-1\",\"app_version\":\"ics20-1\"}" + opts.DestPortName = "transfer" + opts.SourcePortName = "transfer" + } } diff --git a/e2e/testconfig/testconfig.go b/e2e/testconfig/testconfig.go new file mode 100644 index 00000000000..87ef843b282 --- /dev/null +++ b/e2e/testconfig/testconfig.go @@ -0,0 +1,36 @@ +package testconfig + +import ( + "fmt" + "os" +) + +const ( + DefaultSimdImage = "ghcr.io/cosmos/ibc-go-simd-e2e" + SimdImageEnv = "SIMD_IMAGE" + SimdTagEnv = "SIMD_TAG" +) + +// TestConfig holds various fields used in the E2E tests. +type TestConfig struct { + SimdImage string + SimdTag string +} + +// FromEnv returns a TestConfig constructed from environment variables. +func FromEnv() TestConfig { + simdImage, ok := os.LookupEnv(SimdImageEnv) + if !ok { + simdImage = DefaultSimdImage + } + + simdTag, ok := os.LookupEnv(SimdTagEnv) + if !ok { + panic(fmt.Sprintf("must specify simd version for test with environment variable [%s]", SimdTagEnv)) + } + + return TestConfig{ + SimdImage: simdImage, + SimdTag: simdTag, + } +} diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go new file mode 100644 index 00000000000..c16bf2e8c8d --- /dev/null +++ b/e2e/testsuite/testsuite.go @@ -0,0 +1,285 @@ +package testsuite + +import ( + "context" + "fmt" + "io/ioutil" + "strings" + "testing" + "time" + + dockerclient "github.com/docker/docker/client" + "github.com/strangelove-ventures/ibctest" + "github.com/strangelove-ventures/ibctest/chain/cosmos" + "github.com/strangelove-ventures/ibctest/ibc" + "github.com/strangelove-ventures/ibctest/relayer" + "github.com/strangelove-ventures/ibctest/testreporter" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + "go.uber.org/zap" + "go.uber.org/zap/zaptest" + + "github.com/cosmos/ibc-go/v4/e2e/testconfig" +) + +const ( + SourceRelayerName = "srcRly" + DestinationRelayerName = "dstRly" +) + +// E2ETestSuite has methods and functionality which can be shared among all test suites. +type E2ETestSuite struct { + suite.Suite + chainPairs map[string]chainPair + logger *zap.Logger + Client *dockerclient.Client + network string + startRelayerFn func(relayer ibc.Relayer) + Rep *testreporter.Reporter + Req *require.Assertions +} + +type chainPair struct { + srcChain, dstChain *cosmos.CosmosChain +} + +type ChainOptions struct { + SrcChainConfig *ibc.ChainConfig + DstChainConfig *ibc.ChainConfig +} + +func (s *E2ETestSuite) SetupTest() { + s.Rep = testreporter.NewNopReporter() + s.Req = require.New(s.Rep.TestifyT(s.T())) +} + +// GetChains returns a src and dst chain that can be used in a test. The pair returned +// is unique to the current test being run. +func (s *E2ETestSuite) GetChains(chainOpts ...func(*ChainOptions)) (*cosmos.CosmosChain, *cosmos.CosmosChain) { + if s.chainPairs == nil { + s.chainPairs = map[string]chainPair{} + } + cp, ok := s.chainPairs[s.T().Name()] + if ok { + return cp.srcChain, cp.dstChain + } + + chainOptions := defaultChainOptions() + for _, opt := range chainOpts { + opt(&chainOptions) + } + + srcChain, dstChain := s.CreateCosmosChains(chainOptions) + cp = chainPair{ + srcChain: srcChain, + dstChain: dstChain, + } + s.chainPairs[s.T().Name()] = cp + + return cp.srcChain, cp.dstChain +} + +// CreateCosmosChains creates two separate chains in docker containers. +// test and can be retrieved with GetChains. +func (s *E2ETestSuite) CreateCosmosChains(chainOptions ChainOptions) (*cosmos.CosmosChain, *cosmos.CosmosChain) { + ctx := context.Background() + client, network := ibctest.DockerSetup(s.T()) + + s.logger = zap.NewExample() + s.Client = client + s.network = network + + logger := zaptest.NewLogger(s.T()) + srcChain := cosmos.NewCosmosChain(s.T().Name(), *chainOptions.SrcChainConfig, 1, 0, logger) + dstChain := cosmos.NewCosmosChain(s.T().Name(), *chainOptions.DstChainConfig, 1, 0, logger) + + s.T().Cleanup(func() { + if !s.T().Failed() { + for _, c := range []*cosmos.CosmosChain{srcChain, dstChain} { + if err := c.Cleanup(ctx); err != nil { + s.T().Logf("Chain cleanup for %s failed: %v", c.Config().ChainID, err) + } + } + } + }) + + return srcChain, dstChain +} + +func defaultChainOptions() ChainOptions { + tc := testconfig.FromEnv() + srcChainCfg := NewSimappConfig(tc, "simapp-a", "chain-a", "atoma") + dstChainCfg := NewSimappConfig(tc, "simapp-b", "chain-b", "atomb") + return ChainOptions{ + SrcChainConfig: &srcChainCfg, + DstChainConfig: &dstChainCfg, + } +} + +func NewRelayer(t *testing.T, logger *zap.Logger, client *dockerclient.Client, network string, home string) ibc.Relayer { + return ibctest.NewBuiltinRelayerFactory(ibc.CosmosRly, logger, relayer.CustomDockerImage("ghcr.io/cosmos/relayer", "main")).Build( + t, client, network, home, + ) +} + +// NewSimappConfig creates an ibc configuration for simd. +func NewSimappConfig(tc testconfig.TestConfig, name, chainId, denom string) ibc.ChainConfig { + return ibc.ChainConfig{ + Type: "cosmos", + Name: name, + ChainID: chainId, + Images: []ibc.DockerImage{ + { + Repository: tc.SimdImage, + Version: tc.SimdTag, + }, + }, + Bin: "simd", + Bech32Prefix: "cosmos", + Denom: denom, + GasPrices: fmt.Sprintf("0.01%s", denom), + GasAdjustment: 1.3, + TrustingPeriod: "508h", + NoHostMount: false, + } +} + +func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channelOpts ...func(*ibc.CreateChannelOptions)) ibc.Relayer { + srcChain, dstChain := s.GetChains() + req := s.Req + eRep := s.Rep.RelayerExecReporter(s.T()) + + home, err := ioutil.TempDir("", "") + req.NoError(err) + + r := NewRelayer(s.T(), s.logger, s.Client, s.network, home) + + pathName := fmt.Sprintf("%s-path", s.T().Name()) + pathName = strings.ReplaceAll(pathName, "/", "-") + + ic := ibctest.NewInterchain(). + AddChain(srcChain). + AddChain(dstChain). + AddRelayer(r, "r"). + AddLink(ibctest.InterchainLink{ + Chain1: srcChain, + Chain2: dstChain, + Relayer: r, + Path: pathName, + }) + + channelOptions := ibc.CreateChannelOptions{ + SourcePortName: "transfer", + DestPortName: "transfer", + Order: ibc.Unordered, + Version: "ics20-1", + } + + for _, opt := range channelOpts { + opt(&channelOptions) + } + + req.NoError(ic.Build(ctx, eRep, ibctest.InterchainBuildOptions{ + TestName: s.T().Name(), + HomeDir: home, + Client: s.Client, + NetworkID: s.network, + SkipPathCreation: true, + CreateChannelOpts: channelOptions, + })) + + s.startRelayerFn = func(relayer ibc.Relayer) { + err := relayer.StartRelayer(ctx, eRep, pathName) + req.NoError(err, fmt.Sprintf("failed to start relayer: %s", err)) + s.T().Cleanup(func() { + if !s.T().Failed() { + if err := relayer.StopRelayer(ctx, eRep); err != nil { + s.T().Logf("error stopping relayer: %v", err) + } + } + }) + // wait for relayer to start. + time.Sleep(time.Second * 10) + } + + return r +} + +// GetRelayerWallets returns the relayer wallets associated with the source and destination chains. +func (s *E2ETestSuite) GetRelayerWallets(relayer ibc.Relayer) (ibc.RelayerWallet, ibc.RelayerWallet, error) { + srcChain, dstChain := s.GetChains() + srcRelayWallet, ok := relayer.GetWallet(srcChain.Config().ChainID) + if !ok { + return ibc.RelayerWallet{}, ibc.RelayerWallet{}, fmt.Errorf("unable to find source chain relayer wallet") + } + dstRelayWallet, ok := relayer.GetWallet(dstChain.Config().ChainID) + if !ok { + return ibc.RelayerWallet{}, ibc.RelayerWallet{}, fmt.Errorf("unable to find destination chain relayer wallet") + } + return srcRelayWallet, dstRelayWallet, nil +} + +// RecoverRelayerWallets adds the corresponding relayer address to the keychain of the chain. +func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, relayer ibc.Relayer) error { + srcRelayerWallet, dstRelayerWallet, err := s.GetRelayerWallets(relayer) + if err != nil { + return err + } + + srcChain, dstChain := s.GetChains() + + if err := srcChain.RecoverKey(ctx, SourceRelayerName, srcRelayerWallet.Mnemonic); err != nil { + return fmt.Errorf("could not recover relayer wallet on source chain: %s", err) + } + if err := dstChain.RecoverKey(ctx, DestinationRelayerName, dstRelayerWallet.Mnemonic); err != nil { + return fmt.Errorf("could not recover relayer wallet on destination chain: %s", err) + } + return nil +} + +// StartRelayer starts the given relayer. +func (s *E2ETestSuite) StartRelayer(relayer ibc.Relayer) { + if s.startRelayerFn == nil { + panic("cannot start relayer before it is created!") + } + s.startRelayerFn(relayer) +} + +// CreateUserOnSourceChain creates a user with the given amount of funds on the source chain. +func (s *E2ETestSuite) CreateUserOnSourceChain(ctx context.Context, amount int64) *ibctest.User { + srcChain, _ := s.GetChains() + return ibctest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), amount, srcChain)[0] +} + +// CreateUserOnSourceChainWithMnemonic creates a user with the given amount of funds on the source chain from the given mnemonic. +func (s *E2ETestSuite) CreateUserOnSourceChainWithMnemonic(ctx context.Context, amount int64, mnemonic string) *ibctest.User { + srcChain, _ := s.GetChains() + return ibctest.GetAndFundTestUserWithMnemonic(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), mnemonic, amount, srcChain) +} + +// CreateUserOnDestinationChain creates a user with the given amount of funds on the destination chain. +func (s *E2ETestSuite) CreateUserOnDestinationChain(ctx context.Context, amount int64) *ibctest.User { + _, dstChain := s.GetChains() + return ibctest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), amount, dstChain)[0] +} + +// GetSourceChainNativeBalance gets the balance of a given user on the source chain. +func (s *E2ETestSuite) GetSourceChainNativeBalance(ctx context.Context, user *ibctest.User) (int64, error) { + srcChain, _ := s.GetChains() + return GetNativeChainBalance(ctx, srcChain, user) +} + +// GetDestinationChainNativeBalance gets the balance of a given user on the destination chain. +func (s *E2ETestSuite) GetDestinationChainNativeBalance(ctx context.Context, user *ibctest.User) (int64, error) { + _, dstChain := s.GetChains() + return GetNativeChainBalance(ctx, dstChain, user) +} + +// GetNativeChainBalance returns the balance of a specific user on a chain using the native denom. +func GetNativeChainBalance(ctx context.Context, chain ibc.Chain, user *ibctest.User) (int64, error) { + bal, err := chain.GetBalance(ctx, user.Bech32Address(chain.Config().Bech32Prefix), chain.Config().Denom) + if err != nil { + return -1, err + } + return bal, nil +} diff --git a/go.mod b/go.mod index de5b84637dc..cfe6e13478f 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/armon/go-metrics v0.4.0 github.com/confio/ics23/go v0.7.0 github.com/cosmos/cosmos-sdk v0.45.6 + github.com/docker/docker v20.10.17+incompatible github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 @@ -17,9 +18,11 @@ require ( github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.5.0 github.com/spf13/viper v1.12.0 + github.com/strangelove-ventures/ibctest v0.0.0-20220701220145-b783e516bff0 github.com/stretchr/testify v1.8.0 github.com/tendermint/tendermint v0.34.19 github.com/tendermint/tm-db v0.6.6 + go.uber.org/zap v1.21.0 google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd google.golang.org/grpc v1.47.0 google.golang.org/protobuf v1.28.0 @@ -31,7 +34,10 @@ require ( github.com/99designs/keyring v1.1.6 // indirect github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect github.com/DataDog/zstd v1.4.5 // indirect + github.com/Microsoft/go-winio v0.5.1 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect + github.com/avast/retry-go/v4 v4.0.4 // indirect + github.com/benbjohnson/clock v1.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect github.com/btcsuite/btcd v0.22.0-beta // indirect @@ -41,6 +47,7 @@ require ( github.com/cosmos/btcutil v1.0.4 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/iavl v0.17.3 // indirect + github.com/cosmos/ibc-go/v3 v3.0.0 // indirect github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect github.com/danieljoos/wincred v1.0.2 // indirect @@ -49,6 +56,9 @@ require ( github.com/dgraph-io/badger/v2 v2.2007.2 // indirect github.com/dgraph-io/ristretto v0.0.3 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect + github.com/docker/distribution v2.8.1+incompatible // indirect + github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-units v0.4.0 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect github.com/felixge/httpsnoop v1.0.1 // indirect @@ -62,6 +72,7 @@ require ( github.com/golang/snappy v0.0.3 // indirect github.com/google/btree v1.0.0 // indirect github.com/google/orderedcode v0.0.1 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect @@ -75,18 +86,21 @@ require ( github.com/improbable-eng/grpc-web v0.14.1 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect + github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect github.com/klauspost/compress v1.13.6 // indirect github.com/lib/pq v1.10.4 // indirect github.com/libp2p/go-buffer-pool v0.0.2 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-isatty v0.0.14 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.0.2 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.1 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect @@ -97,9 +111,11 @@ require ( github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/rs/cors v1.8.2 // indirect - github.com/rs/zerolog v1.23.0 // indirect + github.com/rs/zerolog v1.26.1 // indirect github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect + github.com/sirupsen/logrus v1.8.1 // indirect github.com/spf13/afero v1.8.2 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect @@ -111,12 +127,28 @@ require ( github.com/tendermint/go-amino v0.16.0 // indirect github.com/zondax/hid v0.9.0 // indirect go.etcd.io/bbolt v1.3.6 // indirect + go.uber.org/atomic v1.9.0 // indirect + go.uber.org/multierr v1.7.0 // indirect golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect + golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect + golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 // indirect golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect + golang.org/x/tools v0.1.10 // indirect + golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect gopkg.in/ini.v1 v1.66.4 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/uint128 v1.1.1 // indirect + modernc.org/cc/v3 v3.36.0 // indirect + modernc.org/ccgo/v3 v3.16.6 // indirect + modernc.org/libc v1.16.7 // indirect + modernc.org/mathutil v1.4.1 // indirect + modernc.org/memory v1.1.1 // indirect + modernc.org/opt v0.1.1 // indirect + modernc.org/sqlite v1.17.3 // indirect + modernc.org/strutil v1.1.1 // indirect + modernc.org/token v1.0.0 // indirect nhooyr.io/websocket v1.8.6 // indirect ) diff --git a/go.sum b/go.sum index 3d39b9e62c8..263a1fa68fa 100644 --- a/go.sum +++ b/go.sum @@ -130,6 +130,8 @@ github.com/armon/go-metrics v0.4.0/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/avast/retry-go/v4 v4.0.4 h1:38hLf0DsRXh+hOF6HbTni0+5QGTNdw9zbaMD7KAO830= +github.com/avast/retry-go/v4 v4.0.4/go.mod h1:HqmLvS2VLdStPCGDFjSuZ9pzlTqVRldCI4w2dO4m1Ms= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= @@ -138,6 +140,7 @@ github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZw github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -233,6 +236,8 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y= github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w= +github.com/cosmos/ibc-go/v3 v3.0.0 h1:XUNplHVS51Q2gMnTFsFsH9QJ7flsovMamnltKbEgPQ4= +github.com/cosmos/ibc-go/v3 v3.0.0/go.mod h1:Mb+1NXiPOLd+CPFlOC6BKeAUaxXlhuWenMmRiUiSmwY= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -268,7 +273,11 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUn github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= +github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v20.10.17+incompatible h1:JYCuMrWaVNophQTOrMMoSwudOVEfcegoZZrleKc1xwE= +github.com/docker/docker v20.10.17+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= @@ -331,8 +340,8 @@ github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/gin-gonic/gin v1.7.0 h1:jGB9xAJQ12AIGNB4HguylppmDK1Am9ppF7XnGXXJuoU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -466,6 +475,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= @@ -599,6 +610,8 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -661,8 +674,11 @@ github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0= +github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= @@ -688,6 +704,7 @@ github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= +github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 h1:rzf0wL0CHVc8CEsgyygG0Mn9CNCCPZqOPaz8RiiHYQk= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -696,6 +713,7 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= @@ -719,7 +737,6 @@ github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1t github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/neilotoole/errgroup v0.1.5/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= @@ -788,6 +805,7 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCr github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrre/gotestcover v0.0.0-20160517101806-924dca7d15f0/go.mod h1:4xpMLz7RBWyB+ElzHu8Llua96TRCB3YwX+l5EP1wmHk= github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -853,7 +871,10 @@ github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzy github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM= github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= +github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= +github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= +github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -863,9 +884,9 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= -github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= -github.com/rs/zerolog v1.23.0 h1:UskrK+saS9P9Y789yNNulYKdARjPZuS35B8gJF2x60g= -github.com/rs/zerolog v1.23.0/go.mod h1:6c7hFfxPOy7TacJc4Fcdi24/J0NKYGzjG8FWRI916Qo= +github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc= +github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -927,6 +948,8 @@ github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiu github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw= github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= +github.com/strangelove-ventures/ibctest v0.0.0-20220701220145-b783e516bff0 h1:NjImCG4wNpDbi1LQ7AtUHWx4Jlo6OCqaMtw2qDWu7EM= +github.com/strangelove-ventures/ibctest v0.0.0-20220701220145-b783e516bff0/go.mod h1:UjhKi/BLudic8IAvfFMNqBRzJC0wm1EVRAZTRZjR6+c= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -999,6 +1022,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -1028,17 +1052,23 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= +go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= +go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1067,6 +1097,7 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210915214749-c084706c2272/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA= golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1113,6 +1144,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1170,6 +1203,7 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -1204,6 +1238,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4= +golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1293,6 +1329,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1300,6 +1337,7 @@ golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1326,6 +1364,7 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1381,6 +1420,7 @@ golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -1393,10 +1433,15 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df h1:5Pf6pFKu98ODmgnpvkJ3kFUOQGGLIzLIkbzUHp47618= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= @@ -1574,8 +1619,8 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -1605,7 +1650,9 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1614,6 +1661,41 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU= +lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= +modernc.org/cc/v3 v3.36.0 h1:0kmRkTmqNidmu3c7BNDSdVHCxXCkWLmWmCIVX4LUboo= +modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= +modernc.org/ccgo/v3 v3.0.0-20220428102840-41399a37e894/go.mod h1:eI31LL8EwEBKPpNpA4bU1/i+sKOwOrQy8D87zWUcRZc= +modernc.org/ccgo/v3 v3.0.0-20220430103911-bc99d88307be/go.mod h1:bwdAnOoaIt8Ax9YdWGjxWsdkPcZyRPHqrOvJxaKAKGw= +modernc.org/ccgo/v3 v3.16.4/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ= +modernc.org/ccgo/v3 v3.16.6 h1:3l18poV+iUemQ98O3X5OMr97LOqlzis+ytivU4NqGhA= +modernc.org/ccgo/v3 v3.16.6/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ= +modernc.org/ccorpus v1.11.6 h1:J16RXiiqiCgua6+ZvQot4yUuUy8zxgqbqEEUuGPlISk= +modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= +modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM= +modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= +modernc.org/libc v0.0.0-20220428101251-2d5f3daf273b/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA= +modernc.org/libc v1.16.0/go.mod h1:N4LD6DBE9cf+Dzf9buBlzVJndKr/iJHG97vGLHYnb5A= +modernc.org/libc v1.16.1/go.mod h1:JjJE0eu4yeK7tab2n4S1w8tlWd9MxXLRzheaRnAKymU= +modernc.org/libc v1.16.7 h1:qzQtHhsZNpVPpeCu+aMIQldXeV1P0vRhSqCL0nOIJOA= +modernc.org/libc v1.16.7/go.mod h1:hYIV5VZczAmGZAnG15Vdngn5HSF5cSkbvfz2B7GRuVU= +modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= +modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8= +modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= +modernc.org/memory v1.1.1 h1:bDOL0DIDLQv7bWhP3gMvIrnoFw+Eo6F7a2QK9HPDiFU= +modernc.org/memory v1.1.1/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= +modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A= +modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= +modernc.org/sqlite v1.17.3 h1:iE+coC5g17LtByDYDWKpR6m2Z9022YrSh3bumwOnIrI= +modernc.org/sqlite v1.17.3/go.mod h1:10hPVYar9C0kfXuTWGz8s0XtB8uAGymUy51ZzStYe3k= +modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs= +modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= +modernc.org/tcl v1.13.1 h1:npxzTwFTZYM8ghWicVIX1cRWzj7Nd8i6AqqX2p+IYao= +modernc.org/tcl v1.13.1/go.mod h1:XOLfOwzhkljL4itZkK6T72ckMgvj0BDsnKNdZVUOecw= +modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk= +modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= +modernc.org/z v1.5.1 h1:RTNHdsrOpeoSeOF4FbzTo8gBYByaJ5xT7NgZ9ZqRiJM= +modernc.org/z v1.5.1/go.mod h1:eWFB510QWW5Th9YGZT81s+LwvaAs3Q2yr4sP0rmLkv8= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= From b43d07e40e9bba624941ff18e489a46a5f612882 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 14:23:12 +0100 Subject: [PATCH 20/28] wip: temporarily remove entrypoint in dockerfile --- .github/workflows/test.yml | 3 +++ Dockerfile | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 94f0db65ada..0025ba811dc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -240,6 +240,9 @@ jobs: matrix: ${{ fromJSON(needs.build-test-matrix.outputs.matrix) }} steps: - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 - name: Log in to the Container registry uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b with: diff --git a/Dockerfile b/Dockerfile index 6420e1cb3fb..b5a6414de25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,4 +20,5 @@ FROM ubuntu:20.04 COPY --from=builder /go/build/simd /bin/simd +# TODO(chatton): uncomment once https://github.com/strangelove-ventures/ibctest/issues/183 is resolved. #ENTRYPOINT ["simd"] From b1bcc12aadea1b9f495bc912cd420359413a2b3a Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 15:16:37 +0100 Subject: [PATCH 21/28] chore: removing SkipPathCreation --- e2e/testsuite/testsuite.go | 109 ++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 57 deletions(-) diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index c16bf2e8c8d..b184422d24e 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -35,8 +35,6 @@ type E2ETestSuite struct { Client *dockerclient.Client network string startRelayerFn func(relayer ibc.Relayer) - Rep *testreporter.Reporter - Req *require.Assertions } type chainPair struct { @@ -48,13 +46,8 @@ type ChainOptions struct { DstChainConfig *ibc.ChainConfig } -func (s *E2ETestSuite) SetupTest() { - s.Rep = testreporter.NewNopReporter() - s.Req = require.New(s.Rep.TestifyT(s.T())) -} - // GetChains returns a src and dst chain that can be used in a test. The pair returned -// is unique to the current test being run. +// is unique to the current test being run. Note: this function does not create containers. func (s *E2ETestSuite) GetChains(chainOpts ...func(*ChainOptions)) (*cosmos.CosmosChain, *cosmos.CosmosChain) { if s.chainPairs == nil { s.chainPairs = map[string]chainPair{} @@ -106,53 +99,20 @@ func (s *E2ETestSuite) CreateCosmosChains(chainOptions ChainOptions) (*cosmos.Co return srcChain, dstChain } -func defaultChainOptions() ChainOptions { - tc := testconfig.FromEnv() - srcChainCfg := NewSimappConfig(tc, "simapp-a", "chain-a", "atoma") - dstChainCfg := NewSimappConfig(tc, "simapp-b", "chain-b", "atomb") - return ChainOptions{ - SrcChainConfig: &srcChainCfg, - DstChainConfig: &dstChainCfg, - } -} - -func NewRelayer(t *testing.T, logger *zap.Logger, client *dockerclient.Client, network string, home string) ibc.Relayer { - return ibctest.NewBuiltinRelayerFactory(ibc.CosmosRly, logger, relayer.CustomDockerImage("ghcr.io/cosmos/relayer", "main")).Build( - t, client, network, home, - ) -} - -// NewSimappConfig creates an ibc configuration for simd. -func NewSimappConfig(tc testconfig.TestConfig, name, chainId, denom string) ibc.ChainConfig { - return ibc.ChainConfig{ - Type: "cosmos", - Name: name, - ChainID: chainId, - Images: []ibc.DockerImage{ - { - Repository: tc.SimdImage, - Version: tc.SimdTag, - }, - }, - Bin: "simd", - Bech32Prefix: "cosmos", - Denom: denom, - GasPrices: fmt.Sprintf("0.01%s", denom), - GasAdjustment: 1.3, - TrustingPeriod: "508h", - NoHostMount: false, - } -} - +// CreateChainsRelayerAndChannel create two chains, a relayer, establishes a connection and creates a channel +// using the given channel options. The relayer returned by this function has not yet started. It should be started +// with E2ETestSuite.StartRelayer if needed. +// This should be called at the start of every test, unless fine grained control is required. func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channelOpts ...func(*ibc.CreateChannelOptions)) ibc.Relayer { srcChain, dstChain := s.GetChains() - req := s.Req - eRep := s.Rep.RelayerExecReporter(s.T()) + rep := testreporter.NewNopReporter() + req := require.New(rep.TestifyT(s.T())) + eRep := rep.RelayerExecReporter(s.T()) home, err := ioutil.TempDir("", "") req.NoError(err) - r := NewRelayer(s.T(), s.logger, s.Client, s.network, home) + r := newRelayer(s.T(), s.logger, s.Client, s.network, home) pathName := fmt.Sprintf("%s-path", s.T().Name()) pathName = strings.ReplaceAll(pathName, "/", "-") @@ -168,13 +128,7 @@ func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channe Path: pathName, }) - channelOptions := ibc.CreateChannelOptions{ - SourcePortName: "transfer", - DestPortName: "transfer", - Order: ibc.Unordered, - Version: "ics20-1", - } - + channelOptions := ibc.DefaultChannelOpts() for _, opt := range channelOpts { opt(&channelOptions) } @@ -184,7 +138,6 @@ func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channe HomeDir: home, Client: s.Client, NetworkID: s.network, - SkipPathCreation: true, CreateChannelOpts: channelOptions, })) @@ -220,6 +173,7 @@ func (s *E2ETestSuite) GetRelayerWallets(relayer ibc.Relayer) (ibc.RelayerWallet } // RecoverRelayerWallets adds the corresponding relayer address to the keychain of the chain. +// This is useful if commands executed on the chains expect the relayer information to present in the keychain. func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, relayer ibc.Relayer) error { srcRelayerWallet, dstRelayerWallet, err := s.GetRelayerWallets(relayer) if err != nil { @@ -283,3 +237,44 @@ func GetNativeChainBalance(ctx context.Context, chain ibc.Chain, user *ibctest.U } return bal, nil } + +// defaultChainOptions returns the default configuration for the source and destination chains. +// These options can be configured by passing configuration functions to E2ETestSuite.GetChains. +func defaultChainOptions() ChainOptions { + tc := testconfig.FromEnv() + srcChainCfg := newDefaultSimappConfig(tc, "simapp-a", "chain-a", "atoma") + dstChainCfg := newDefaultSimappConfig(tc, "simapp-b", "chain-b", "atomb") + return ChainOptions{ + SrcChainConfig: &srcChainCfg, + DstChainConfig: &dstChainCfg, + } +} + +// newRelayer returns an instance of the go relayer. +func newRelayer(t *testing.T, logger *zap.Logger, client *dockerclient.Client, network string, home string) ibc.Relayer { + return ibctest.NewBuiltinRelayerFactory(ibc.CosmosRly, logger, relayer.CustomDockerImage("ghcr.io/cosmos/relayer", "main")).Build( + t, client, network, home, + ) +} + +// newDefaultSimappConfig creates an ibc configuration for simd. +func newDefaultSimappConfig(tc testconfig.TestConfig, name, chainId, denom string) ibc.ChainConfig { + return ibc.ChainConfig{ + Type: "cosmos", + Name: name, + ChainID: chainId, + Images: []ibc.DockerImage{ + { + Repository: tc.SimdImage, + Version: tc.SimdTag, + }, + }, + Bin: "simd", + Bech32Prefix: "cosmos", + Denom: denom, + GasPrices: fmt.Sprintf("0.01%s", denom), + GasAdjustment: 1.3, + TrustingPeriod: "508h", + NoHostMount: false, + } +} From d74029624fdf6767916a0593ca917cf76752f868 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 4 Jul 2022 15:37:45 +0100 Subject: [PATCH 22/28] removed Req and eRep member fields --- e2e/testsuite/testsuite.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index b184422d24e..ca659c2ea19 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -14,7 +14,6 @@ import ( "github.com/strangelove-ventures/ibctest/ibc" "github.com/strangelove-ventures/ibctest/relayer" "github.com/strangelove-ventures/ibctest/testreporter" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "go.uber.org/zap" "go.uber.org/zap/zaptest" @@ -46,6 +45,11 @@ type ChainOptions struct { DstChainConfig *ibc.ChainConfig } +func (s *E2ETestSuite) getExecReporter() *testreporter.RelayerExecReporter { + rep := testreporter.NewNopReporter() + return rep.RelayerExecReporter(s.T()) +} + // GetChains returns a src and dst chain that can be used in a test. The pair returned // is unique to the current test being run. Note: this function does not create containers. func (s *E2ETestSuite) GetChains(chainOpts ...func(*ChainOptions)) (*cosmos.CosmosChain, *cosmos.CosmosChain) { @@ -105,12 +109,8 @@ func (s *E2ETestSuite) CreateCosmosChains(chainOptions ChainOptions) (*cosmos.Co // This should be called at the start of every test, unless fine grained control is required. func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channelOpts ...func(*ibc.CreateChannelOptions)) ibc.Relayer { srcChain, dstChain := s.GetChains() - rep := testreporter.NewNopReporter() - req := require.New(rep.TestifyT(s.T())) - eRep := rep.RelayerExecReporter(s.T()) - home, err := ioutil.TempDir("", "") - req.NoError(err) + s.Require().NoError(err) r := newRelayer(s.T(), s.logger, s.Client, s.network, home) @@ -133,7 +133,8 @@ func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channe opt(&channelOptions) } - req.NoError(ic.Build(ctx, eRep, ibctest.InterchainBuildOptions{ + eRep := s.getExecReporter() + s.Require().NoError(ic.Build(ctx, eRep, ibctest.InterchainBuildOptions{ TestName: s.T().Name(), HomeDir: home, Client: s.Client, @@ -143,7 +144,7 @@ func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channe s.startRelayerFn = func(relayer ibc.Relayer) { err := relayer.StartRelayer(ctx, eRep, pathName) - req.NoError(err, fmt.Sprintf("failed to start relayer: %s", err)) + s.Require().NoError(err, fmt.Sprintf("failed to start relayer: %s", err)) s.T().Cleanup(func() { if !s.T().Failed() { if err := relayer.StopRelayer(ctx, eRep); err != nil { From 848f8880aace97d01bf64e3c3927bcab001bec5b Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Wed, 6 Jul 2022 12:59:00 +0100 Subject: [PATCH 23/28] chore: adding docstrings and cleaning up E2ETestSuite --- e2e/testsuite/testsuite.go | 85 ++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index ca659c2ea19..a437359f0ad 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -36,23 +36,25 @@ type E2ETestSuite struct { startRelayerFn func(relayer ibc.Relayer) } +// chainPair is a pairing of two chains which will be used in a test. type chainPair struct { srcChain, dstChain *cosmos.CosmosChain } +// ChainOptions stores chain configurations for the chains that will be +// created for the tests. They can be modified by passing ChainOptionConfiguration +// to E2ETestSuite.GetChains. type ChainOptions struct { SrcChainConfig *ibc.ChainConfig DstChainConfig *ibc.ChainConfig } -func (s *E2ETestSuite) getExecReporter() *testreporter.RelayerExecReporter { - rep := testreporter.NewNopReporter() - return rep.RelayerExecReporter(s.T()) -} +// ChainOptionConfiguration enables arbitrary configuration of ChainOptions. +type ChainOptionConfiguration func(options *ChainOptions) // GetChains returns a src and dst chain that can be used in a test. The pair returned // is unique to the current test being run. Note: this function does not create containers. -func (s *E2ETestSuite) GetChains(chainOpts ...func(*ChainOptions)) (*cosmos.CosmosChain, *cosmos.CosmosChain) { +func (s *E2ETestSuite) GetChains(chainOpts ...ChainOptionConfiguration) (*cosmos.CosmosChain, *cosmos.CosmosChain) { if s.chainPairs == nil { s.chainPairs = map[string]chainPair{} } @@ -66,7 +68,7 @@ func (s *E2ETestSuite) GetChains(chainOpts ...func(*ChainOptions)) (*cosmos.Cosm opt(&chainOptions) } - srcChain, dstChain := s.CreateCosmosChains(chainOptions) + srcChain, dstChain := s.createCosmosChains(chainOptions) cp = chainPair{ srcChain: srcChain, dstChain: dstChain, @@ -76,33 +78,6 @@ func (s *E2ETestSuite) GetChains(chainOpts ...func(*ChainOptions)) (*cosmos.Cosm return cp.srcChain, cp.dstChain } -// CreateCosmosChains creates two separate chains in docker containers. -// test and can be retrieved with GetChains. -func (s *E2ETestSuite) CreateCosmosChains(chainOptions ChainOptions) (*cosmos.CosmosChain, *cosmos.CosmosChain) { - ctx := context.Background() - client, network := ibctest.DockerSetup(s.T()) - - s.logger = zap.NewExample() - s.Client = client - s.network = network - - logger := zaptest.NewLogger(s.T()) - srcChain := cosmos.NewCosmosChain(s.T().Name(), *chainOptions.SrcChainConfig, 1, 0, logger) - dstChain := cosmos.NewCosmosChain(s.T().Name(), *chainOptions.DstChainConfig, 1, 0, logger) - - s.T().Cleanup(func() { - if !s.T().Failed() { - for _, c := range []*cosmos.CosmosChain{srcChain, dstChain} { - if err := c.Cleanup(ctx); err != nil { - s.T().Logf("Chain cleanup for %s failed: %v", c.Config().ChainID, err) - } - } - } - }) - - return srcChain, dstChain -} - // CreateChainsRelayerAndChannel create two chains, a relayer, establishes a connection and creates a channel // using the given channel options. The relayer returned by this function has not yet started. It should be started // with E2ETestSuite.StartRelayer if needed. @@ -133,7 +108,7 @@ func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channe opt(&channelOptions) } - eRep := s.getExecReporter() + eRep := s.getRelayerExecReporter() s.Require().NoError(ic.Build(ctx, eRep, ibctest.InterchainBuildOptions{ TestName: s.T().Name(), HomeDir: home, @@ -206,12 +181,6 @@ func (s *E2ETestSuite) CreateUserOnSourceChain(ctx context.Context, amount int64 return ibctest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), amount, srcChain)[0] } -// CreateUserOnSourceChainWithMnemonic creates a user with the given amount of funds on the source chain from the given mnemonic. -func (s *E2ETestSuite) CreateUserOnSourceChainWithMnemonic(ctx context.Context, amount int64, mnemonic string) *ibctest.User { - srcChain, _ := s.GetChains() - return ibctest.GetAndFundTestUserWithMnemonic(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), mnemonic, amount, srcChain) -} - // CreateUserOnDestinationChain creates a user with the given amount of funds on the destination chain. func (s *E2ETestSuite) CreateUserOnDestinationChain(ctx context.Context, amount int64) *ibctest.User { _, dstChain := s.GetChains() @@ -230,6 +199,42 @@ func (s *E2ETestSuite) GetDestinationChainNativeBalance(ctx context.Context, use return GetNativeChainBalance(ctx, dstChain, user) } +// createCosmosChains creates two separate chains in docker containers. +// test and can be retrieved with GetChains. +func (s *E2ETestSuite) createCosmosChains(chainOptions ChainOptions) (*cosmos.CosmosChain, *cosmos.CosmosChain) { + ctx := context.Background() + client, network := ibctest.DockerSetup(s.T()) + + s.logger = zap.NewExample() + s.Client = client + s.network = network + + logger := zaptest.NewLogger(s.T()) + + // TODO(chatton): allow for controller over number of validators and full nodes. + srcChain := cosmos.NewCosmosChain(s.T().Name(), *chainOptions.SrcChainConfig, 1, 0, logger) + dstChain := cosmos.NewCosmosChain(s.T().Name(), *chainOptions.DstChainConfig, 1, 0, logger) + + s.T().Cleanup(func() { + if !s.T().Failed() { + for _, c := range []*cosmos.CosmosChain{srcChain, dstChain} { + if err := c.Cleanup(ctx); err != nil { + s.T().Logf("Chain cleanup for %s failed: %v", c.Config().ChainID, err) + } + } + } + }) + + return srcChain, dstChain +} + +// getRelayerExecReporter returns a testreporter.RelayerExecReporter instances +// using the current test's testing.T. +func (s *E2ETestSuite) getRelayerExecReporter() *testreporter.RelayerExecReporter { + rep := testreporter.NewNopReporter() + return rep.RelayerExecReporter(s.T()) +} + // GetNativeChainBalance returns the balance of a specific user on a chain using the native denom. func GetNativeChainBalance(ctx context.Context, chain ibc.Chain, user *ibctest.User) (int64, error) { bal, err := chain.GetBalance(ctx, user.Bech32Address(chain.Config().Bech32Prefix), chain.Config().Denom) From 35e454f498b85bdf47f8465a619ac9852cc0c273 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Fri, 8 Jul 2022 09:00:23 +0100 Subject: [PATCH 24/28] chore: correcting docstring --- .github/scripts/determine_simd_tag.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/scripts/determine_simd_tag.go b/.github/scripts/determine_simd_tag.go index baa7dd52554..af3a6281268 100644 --- a/.github/scripts/determine_simd_tag.go +++ b/.github/scripts/determine_simd_tag.go @@ -12,9 +12,8 @@ func init() { flag.Parse() } -// in the context of a GithubAction workflow, the PR is the event number. So if the ref is not specified -// but the event number is, that means we are running for a PR. If the ref is specified, this means -// we have merged the PR, so we want to use the ref as a tag instead of the PR number. +// in the context of a GithubAction workflow, the PR is non empty if it is a pr. When +// code is merged to main, it will be empty. In this case we just use the "main" tag. func main() { fmt.Printf(getSimdTag(prNum)) } From ccd9fd5cf2e157fd05bea4943119fa1a1577ef9c Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Fri, 8 Jul 2022 09:07:37 +0100 Subject: [PATCH 25/28] chore: updating test.yml to pass only the pr --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8482853965a..4d9d17dcf13 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -214,7 +214,7 @@ jobs: go-version: 1.18 - id: get-tag run: | - tag=$(go run .github/scripts/determine_simd_tag.go -ref "${{ github.event.push.ref }}" -pr "${{ github.event.pull_request.number }}" ) + tag=$(go run .github/scripts/determine_simd_tag.go -pr "${{ github.event.pull_request.number }}" ) echo "Using tag $tag" echo "::set-output name=simd-tag::$tag" From e154f09e1f22f589b4cfa09e0d0fde278e394f17 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Fri, 8 Jul 2022 09:15:24 +0100 Subject: [PATCH 26/28] chore: upgrading go to 1.18 for e2e test --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4d9d17dcf13..3e2e3c11cb1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -233,6 +233,9 @@ jobs: matrix: ${{ fromJSON(needs.build-test-matrix.outputs.matrix) }} steps: - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 - name: Log in to the Container registry uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b with: From e768a46eb89e0c8b69d83836864df90342ac3965 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Thu, 14 Jul 2022 09:27:57 +0100 Subject: [PATCH 27/28] chore: addressing PR feedback --- e2e/fee_middleware_test.go | 2 +- e2e/testconfig/testconfig.go | 47 ++++++++ e2e/testsuite/relayer.go | 22 ++++ e2e/testsuite/testsuite.go | 212 ++++++++++++++--------------------- 4 files changed, 154 insertions(+), 129 deletions(-) create mode 100644 e2e/testsuite/relayer.go diff --git a/e2e/fee_middleware_test.go b/e2e/fee_middleware_test.go index fced71177f2..b911d781021 100644 --- a/e2e/fee_middleware_test.go +++ b/e2e/fee_middleware_test.go @@ -20,7 +20,7 @@ type FeeMiddlewareTestSuite struct { func (s *FeeMiddlewareTestSuite) TestPlaceholder() { ctx := context.Background() - r := s.CreateChainsRelayerAndChannel(ctx, feeMiddlewareChannelOptions()) + r := s.SetupChainsRelayerAndChannel(ctx, feeMiddlewareChannelOptions()) s.T().Run("start relayer", func(t *testing.T) { s.StartRelayer(r) }) diff --git a/e2e/testconfig/testconfig.go b/e2e/testconfig/testconfig.go index 87ef843b282..5a00e582b76 100644 --- a/e2e/testconfig/testconfig.go +++ b/e2e/testconfig/testconfig.go @@ -3,6 +3,8 @@ package testconfig import ( "fmt" "os" + + "github.com/strangelove-ventures/ibctest/ibc" ) const ( @@ -34,3 +36,48 @@ func FromEnv() TestConfig { SimdTag: simdTag, } } + +// ChainOptions stores chain configurations for the chains that will be +// created for the tests. They can be modified by passing ChainOptionConfiguration +// to E2ETestSuite.GetChains. +type ChainOptions struct { + ChainAConfig *ibc.ChainConfig + ChainBConfig *ibc.ChainConfig +} + +// ChainOptionConfiguration enables arbitrary configuration of ChainOptions. +type ChainOptionConfiguration func(options *ChainOptions) + +// DefaultChainOptions returns the default configuration for the chains. +// These options can be configured by passing configuration functions to E2ETestSuite.GetChains. +func DefaultChainOptions() ChainOptions { + tc := FromEnv() + chainACfg := newDefaultSimappConfig(tc, "simapp-a", "chain-a", "atoma") + chainBCfg := newDefaultSimappConfig(tc, "simapp-b", "chain-b", "atomb") + return ChainOptions{ + ChainAConfig: &chainACfg, + ChainBConfig: &chainBCfg, + } +} + +// newDefaultSimappConfig creates an ibc configuration for simd. +func newDefaultSimappConfig(tc TestConfig, name, chainId, denom string) ibc.ChainConfig { + return ibc.ChainConfig{ + Type: "cosmos", + Name: name, + ChainID: chainId, + Images: []ibc.DockerImage{ + { + Repository: tc.SimdImage, + Version: tc.SimdTag, + }, + }, + Bin: "simd", + Bech32Prefix: "cosmos", + Denom: denom, + GasPrices: fmt.Sprintf("0.01%s", denom), + GasAdjustment: 1.3, + TrustingPeriod: "508h", + NoHostMount: false, + } +} diff --git a/e2e/testsuite/relayer.go b/e2e/testsuite/relayer.go new file mode 100644 index 00000000000..4e4f5e95bba --- /dev/null +++ b/e2e/testsuite/relayer.go @@ -0,0 +1,22 @@ +package testsuite + +import ( + "testing" + + dockerclient "github.com/docker/docker/client" + "github.com/strangelove-ventures/ibctest" + "github.com/strangelove-ventures/ibctest/ibc" + "github.com/strangelove-ventures/ibctest/relayer" + "go.uber.org/zap" +) + +const ( + cosmosRelayerRepository = "ghcr.io/cosmos/relayer" +) + +// newCosmosRelayer returns an instance of the go relayer. +func newCosmosRelayer(t *testing.T, logger *zap.Logger, dockerClient *dockerclient.Client, network string, home string) ibc.Relayer { + return ibctest.NewBuiltinRelayerFactory(ibc.CosmosRly, logger, relayer.CustomDockerImage(cosmosRelayerRepository, "main")).Build( + t, dockerClient, network, home, + ) +} diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index a437359f0ad..b4aca09a83b 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -5,14 +5,12 @@ import ( "fmt" "io/ioutil" "strings" - "testing" "time" dockerclient "github.com/docker/docker/client" "github.com/strangelove-ventures/ibctest" "github.com/strangelove-ventures/ibctest/chain/cosmos" "github.com/strangelove-ventures/ibctest/ibc" - "github.com/strangelove-ventures/ibctest/relayer" "github.com/strangelove-ventures/ibctest/testreporter" "github.com/stretchr/testify/suite" "go.uber.org/zap" @@ -22,83 +20,56 @@ import ( ) const ( - SourceRelayerName = "srcRly" - DestinationRelayerName = "dstRly" + // ChainARelayerName is the name given to the relayer wallet on ChainA + ChainARelayerName = "rlyA" + // ChainBRelayerName is the name given to the relayer wallet on ChainB + ChainBRelayerName = "rlyB" ) // E2ETestSuite has methods and functionality which can be shared among all test suites. type E2ETestSuite struct { suite.Suite - chainPairs map[string]chainPair + paths map[string]path logger *zap.Logger - Client *dockerclient.Client + DockerClient *dockerclient.Client network string startRelayerFn func(relayer ibc.Relayer) } -// chainPair is a pairing of two chains which will be used in a test. -type chainPair struct { - srcChain, dstChain *cosmos.CosmosChain +// path is a pairing of two chains which will be used in a test. +type path struct { + chainA, chainB *cosmos.CosmosChain } -// ChainOptions stores chain configurations for the chains that will be -// created for the tests. They can be modified by passing ChainOptionConfiguration -// to E2ETestSuite.GetChains. -type ChainOptions struct { - SrcChainConfig *ibc.ChainConfig - DstChainConfig *ibc.ChainConfig -} - -// ChainOptionConfiguration enables arbitrary configuration of ChainOptions. -type ChainOptionConfiguration func(options *ChainOptions) - -// GetChains returns a src and dst chain that can be used in a test. The pair returned -// is unique to the current test being run. Note: this function does not create containers. -func (s *E2ETestSuite) GetChains(chainOpts ...ChainOptionConfiguration) (*cosmos.CosmosChain, *cosmos.CosmosChain) { - if s.chainPairs == nil { - s.chainPairs = map[string]chainPair{} - } - cp, ok := s.chainPairs[s.T().Name()] - if ok { - return cp.srcChain, cp.dstChain - } - - chainOptions := defaultChainOptions() - for _, opt := range chainOpts { - opt(&chainOptions) - } - - srcChain, dstChain := s.createCosmosChains(chainOptions) - cp = chainPair{ - srcChain: srcChain, - dstChain: dstChain, +// newPath returns a path built from the given chains. +func newPath(chainA, chainB *cosmos.CosmosChain) path { + return path{ + chainA: chainA, + chainB: chainB, } - s.chainPairs[s.T().Name()] = cp - - return cp.srcChain, cp.dstChain } -// CreateChainsRelayerAndChannel create two chains, a relayer, establishes a connection and creates a channel +// SetupChainsRelayerAndChannel create two chains, a relayer, establishes a connection and creates a channel // using the given channel options. The relayer returned by this function has not yet started. It should be started // with E2ETestSuite.StartRelayer if needed. // This should be called at the start of every test, unless fine grained control is required. -func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channelOpts ...func(*ibc.CreateChannelOptions)) ibc.Relayer { - srcChain, dstChain := s.GetChains() +func (s *E2ETestSuite) SetupChainsRelayerAndChannel(ctx context.Context, channelOpts ...func(*ibc.CreateChannelOptions)) ibc.Relayer { + chainA, chainB := s.GetChains() home, err := ioutil.TempDir("", "") s.Require().NoError(err) - r := newRelayer(s.T(), s.logger, s.Client, s.network, home) + r := newCosmosRelayer(s.T(), s.logger, s.DockerClient, s.network, home) pathName := fmt.Sprintf("%s-path", s.T().Name()) pathName = strings.ReplaceAll(pathName, "/", "-") ic := ibctest.NewInterchain(). - AddChain(srcChain). - AddChain(dstChain). + AddChain(chainA). + AddChain(chainB). AddRelayer(r, "r"). AddLink(ibctest.InterchainLink{ - Chain1: srcChain, - Chain2: dstChain, + Chain1: chainA, + Chain2: chainB, Relayer: r, Path: pathName, }) @@ -112,7 +83,7 @@ func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channe s.Require().NoError(ic.Build(ctx, eRep, ibctest.InterchainBuildOptions{ TestName: s.T().Name(), HomeDir: home, - Client: s.Client, + Client: s.DockerClient, NetworkID: s.network, CreateChannelOpts: channelOptions, })) @@ -134,35 +105,60 @@ func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channe return r } -// GetRelayerWallets returns the relayer wallets associated with the source and destination chains. +// GetChains returns two chains that can be used in a test. The pair returned +// is unique to the current test being run. Note: this function does not create containers. +func (s *E2ETestSuite) GetChains(chainOpts ...testconfig.ChainOptionConfiguration) (*cosmos.CosmosChain, *cosmos.CosmosChain) { + if s.paths == nil { + s.paths = map[string]path{} + } + + path, ok := s.paths[s.T().Name()] + if ok { + return path.chainA, path.chainB + } + + chainOptions := testconfig.DefaultChainOptions() + for _, opt := range chainOpts { + opt(&chainOptions) + } + + chainA, chainB := s.createCosmosChains(chainOptions) + path = newPath(chainA, chainB) + s.paths[s.T().Name()] = path + + return path.chainA, path.chainB +} + +// GetRelayerWallets returns the relayer wallets associated with the chains. func (s *E2ETestSuite) GetRelayerWallets(relayer ibc.Relayer) (ibc.RelayerWallet, ibc.RelayerWallet, error) { - srcChain, dstChain := s.GetChains() - srcRelayWallet, ok := relayer.GetWallet(srcChain.Config().ChainID) + chainA, chainB := s.GetChains() + chainARelayerWallet, ok := relayer.GetWallet(chainA.Config().ChainID) if !ok { - return ibc.RelayerWallet{}, ibc.RelayerWallet{}, fmt.Errorf("unable to find source chain relayer wallet") + return ibc.RelayerWallet{}, ibc.RelayerWallet{}, fmt.Errorf("unable to find chain A relayer wallet") } - dstRelayWallet, ok := relayer.GetWallet(dstChain.Config().ChainID) + + chainBRelayerWallet, ok := relayer.GetWallet(chainB.Config().ChainID) if !ok { - return ibc.RelayerWallet{}, ibc.RelayerWallet{}, fmt.Errorf("unable to find destination chain relayer wallet") + return ibc.RelayerWallet{}, ibc.RelayerWallet{}, fmt.Errorf("unable to find chain B relayer wallet") } - return srcRelayWallet, dstRelayWallet, nil + return chainARelayerWallet, chainBRelayerWallet, nil } // RecoverRelayerWallets adds the corresponding relayer address to the keychain of the chain. // This is useful if commands executed on the chains expect the relayer information to present in the keychain. func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, relayer ibc.Relayer) error { - srcRelayerWallet, dstRelayerWallet, err := s.GetRelayerWallets(relayer) + chainARelayerWallet, chainBRelayerWallet, err := s.GetRelayerWallets(relayer) if err != nil { return err } - srcChain, dstChain := s.GetChains() + chainA, chainB := s.GetChains() - if err := srcChain.RecoverKey(ctx, SourceRelayerName, srcRelayerWallet.Mnemonic); err != nil { - return fmt.Errorf("could not recover relayer wallet on source chain: %s", err) + if err := chainA.RecoverKey(ctx, ChainARelayerName, chainARelayerWallet.Mnemonic); err != nil { + return fmt.Errorf("could not recover relayer wallet on chain A: %s", err) } - if err := dstChain.RecoverKey(ctx, DestinationRelayerName, dstRelayerWallet.Mnemonic); err != nil { - return fmt.Errorf("could not recover relayer wallet on destination chain: %s", err) + if err := chainB.RecoverKey(ctx, ChainBRelayerName, chainBRelayerWallet.Mnemonic); err != nil { + return fmt.Errorf("could not recover relayer wallet on chain B: %s", err) } return nil } @@ -172,52 +168,53 @@ func (s *E2ETestSuite) StartRelayer(relayer ibc.Relayer) { if s.startRelayerFn == nil { panic("cannot start relayer before it is created!") } + s.startRelayerFn(relayer) } -// CreateUserOnSourceChain creates a user with the given amount of funds on the source chain. -func (s *E2ETestSuite) CreateUserOnSourceChain(ctx context.Context, amount int64) *ibctest.User { - srcChain, _ := s.GetChains() - return ibctest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), amount, srcChain)[0] +// CreateUserOnChainA creates a user with the given amount of funds on chain A. +func (s *E2ETestSuite) CreateUserOnChainA(ctx context.Context, amount int64) *ibctest.User { + chainA, _ := s.GetChains() + return ibctest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), amount, chainA)[0] } -// CreateUserOnDestinationChain creates a user with the given amount of funds on the destination chain. -func (s *E2ETestSuite) CreateUserOnDestinationChain(ctx context.Context, amount int64) *ibctest.User { - _, dstChain := s.GetChains() - return ibctest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), amount, dstChain)[0] +// CreateUserOnChainB creates a user with the given amount of funds on chain B. +func (s *E2ETestSuite) CreateUserOnChainB(ctx context.Context, amount int64) *ibctest.User { + _, chainB := s.GetChains() + return ibctest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), amount, chainB)[0] } -// GetSourceChainNativeBalance gets the balance of a given user on the source chain. -func (s *E2ETestSuite) GetSourceChainNativeBalance(ctx context.Context, user *ibctest.User) (int64, error) { - srcChain, _ := s.GetChains() - return GetNativeChainBalance(ctx, srcChain, user) +// GetChainANativeBalance gets the balance of a given user on chain A. +func (s *E2ETestSuite) GetChainANativeBalance(ctx context.Context, user *ibctest.User) (int64, error) { + chainA, _ := s.GetChains() + return GetNativeChainBalance(ctx, chainA, user) } -// GetDestinationChainNativeBalance gets the balance of a given user on the destination chain. -func (s *E2ETestSuite) GetDestinationChainNativeBalance(ctx context.Context, user *ibctest.User) (int64, error) { - _, dstChain := s.GetChains() - return GetNativeChainBalance(ctx, dstChain, user) +// GetChainBNativeBalance gets the balance of a given user on chain B. +func (s *E2ETestSuite) GetChainBNativeBalance(ctx context.Context, user *ibctest.User) (int64, error) { + _, chainB := s.GetChains() + return GetNativeChainBalance(ctx, chainB, user) } // createCosmosChains creates two separate chains in docker containers. // test and can be retrieved with GetChains. -func (s *E2ETestSuite) createCosmosChains(chainOptions ChainOptions) (*cosmos.CosmosChain, *cosmos.CosmosChain) { +func (s *E2ETestSuite) createCosmosChains(chainOptions testconfig.ChainOptions) (*cosmos.CosmosChain, *cosmos.CosmosChain) { ctx := context.Background() client, network := ibctest.DockerSetup(s.T()) s.logger = zap.NewExample() - s.Client = client + s.DockerClient = client s.network = network logger := zaptest.NewLogger(s.T()) // TODO(chatton): allow for controller over number of validators and full nodes. - srcChain := cosmos.NewCosmosChain(s.T().Name(), *chainOptions.SrcChainConfig, 1, 0, logger) - dstChain := cosmos.NewCosmosChain(s.T().Name(), *chainOptions.DstChainConfig, 1, 0, logger) + chainA := cosmos.NewCosmosChain(s.T().Name(), *chainOptions.ChainAConfig, 1, 0, logger) + chainB := cosmos.NewCosmosChain(s.T().Name(), *chainOptions.ChainBConfig, 1, 0, logger) s.T().Cleanup(func() { if !s.T().Failed() { - for _, c := range []*cosmos.CosmosChain{srcChain, dstChain} { + for _, c := range []*cosmos.CosmosChain{chainA, chainB} { if err := c.Cleanup(ctx); err != nil { s.T().Logf("Chain cleanup for %s failed: %v", c.Config().ChainID, err) } @@ -225,7 +222,7 @@ func (s *E2ETestSuite) createCosmosChains(chainOptions ChainOptions) (*cosmos.Co } }) - return srcChain, dstChain + return chainA, chainB } // getRelayerExecReporter returns a testreporter.RelayerExecReporter instances @@ -243,44 +240,3 @@ func GetNativeChainBalance(ctx context.Context, chain ibc.Chain, user *ibctest.U } return bal, nil } - -// defaultChainOptions returns the default configuration for the source and destination chains. -// These options can be configured by passing configuration functions to E2ETestSuite.GetChains. -func defaultChainOptions() ChainOptions { - tc := testconfig.FromEnv() - srcChainCfg := newDefaultSimappConfig(tc, "simapp-a", "chain-a", "atoma") - dstChainCfg := newDefaultSimappConfig(tc, "simapp-b", "chain-b", "atomb") - return ChainOptions{ - SrcChainConfig: &srcChainCfg, - DstChainConfig: &dstChainCfg, - } -} - -// newRelayer returns an instance of the go relayer. -func newRelayer(t *testing.T, logger *zap.Logger, client *dockerclient.Client, network string, home string) ibc.Relayer { - return ibctest.NewBuiltinRelayerFactory(ibc.CosmosRly, logger, relayer.CustomDockerImage("ghcr.io/cosmos/relayer", "main")).Build( - t, client, network, home, - ) -} - -// newDefaultSimappConfig creates an ibc configuration for simd. -func newDefaultSimappConfig(tc testconfig.TestConfig, name, chainId, denom string) ibc.ChainConfig { - return ibc.ChainConfig{ - Type: "cosmos", - Name: name, - ChainID: chainId, - Images: []ibc.DockerImage{ - { - Repository: tc.SimdImage, - Version: tc.SimdTag, - }, - }, - Bin: "simd", - Bech32Prefix: "cosmos", - Denom: denom, - GasPrices: fmt.Sprintf("0.01%s", denom), - GasAdjustment: 1.3, - TrustingPeriod: "508h", - NoHostMount: false, - } -} From 67b1a8b32b3aff39102046bb5b670f3fcca3fb25 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Thu, 14 Jul 2022 16:24:02 +0100 Subject: [PATCH 28/28] chore: adressing PR feedback --- e2e/testconfig/testconfig.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/testconfig/testconfig.go b/e2e/testconfig/testconfig.go index 5a00e582b76..c043712b4e4 100644 --- a/e2e/testconfig/testconfig.go +++ b/e2e/testconfig/testconfig.go @@ -61,11 +61,11 @@ func DefaultChainOptions() ChainOptions { } // newDefaultSimappConfig creates an ibc configuration for simd. -func newDefaultSimappConfig(tc TestConfig, name, chainId, denom string) ibc.ChainConfig { +func newDefaultSimappConfig(tc TestConfig, name, chainID, denom string) ibc.ChainConfig { return ibc.ChainConfig{ Type: "cosmos", Name: name, - ChainID: chainId, + ChainID: chainID, Images: []ibc.DockerImage{ { Repository: tc.SimdImage,