Skip to content

Commit

Permalink
pfm simapp for e2e (#117)
Browse files Browse the repository at this point in the history
* moves CI to individual files (WIP: path based actions)

* enable conditional paths for workflows

* perform full run if workflow is modified

* base pfm simapp

* bump interchaintest

* fixed app params

* use simapp for TestTimeoutOnForward

* resolve ictest relative path

* ibctm.RegisterInterfaces

* fix: simapp IBC setup

* extended block wait time

* wip

* rm old debugging files

* remove ibcmock

* add solomachine

* transfer key tweaking

* ibc-go/v7 v7.3.1 & regen mocks
  • Loading branch information
Reecepbcups authored Oct 25, 2023
1 parent 8fd49ec commit 04e47eb
Show file tree
Hide file tree
Showing 24 changed files with 2,809 additions and 214 deletions.
67 changes: 66 additions & 1 deletion .github/workflows/packet-forward-middleware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ env:
LINT_VERSION: v1.52
GO_VERSION: 1.21.0
WORKING_DIRECTORY: middleware/packet-forward-middleware/

DOCKER_TAG: pfm:local
TAR_PATH: /tmp/pfm-docker-image.tar
IMAGE_NAME: pfm-docker-image

jobs:
golangci:
Expand Down Expand Up @@ -39,4 +43,65 @@ jobs:
run: go test ./...
working-directory: ${{ env.WORKING_DIRECTORY }}

# TODO: e2e
build-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and export
uses: docker/build-push-action@v5
with:
context: ${{ env.WORKING_DIRECTORY }}
tags: ${{ env.DOCKER_TAG }}
outputs: type=docker,dest=${{ env.TAR_PATH }}

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.IMAGE_NAME }}
path: ${{ env.TAR_PATH }}

e2e-tests:
needs: build-docker
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
strategy:
matrix:
test:
- "ictest-forward"
- "ictest-timeout"
fail-fast: false

steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: checkout chain
uses: actions/checkout@v4

- name: Download Tarball Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.IMAGE_NAME }}
path: /tmp

- name: Load Docker Image
run: |
docker image load -i ${{ env.TAR_PATH }}
docker image ls -a
- name: Run Test
run: make ${{ matrix.test }}
30 changes: 30 additions & 0 deletions middleware/packet-forward-middleware/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# docker build . -t pfm:local
# docker run --rm -it pfm:local q ibc-router

FROM golang:1.21-alpine3.18 as builder

RUN set -eux; apk add --no-cache git libusb-dev linux-headers gcc musl-dev make;

ENV GOPATH=""

ADD testing testing
ADD LICENSE LICENSE

COPY testing/contrib/devtools/Makefile contrib/devtools/Makefile
COPY Makefile .

COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . .

RUN make build

FROM alpine:3.18

COPY --from=builder /go/build/simd /bin/simd

ENTRYPOINT ["simd"]

15 changes: 14 additions & 1 deletion middleware/packet-forward-middleware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ BUILD_TARGETS := build install

build: BUILD_ARGS=-o $(BUILDDIR)/
build-linux:
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build -o bin/simd ./cmd/simd

$(BUILD_TARGETS): go.sum $(BUILDDIR)/
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...
Expand Down Expand Up @@ -211,6 +211,19 @@ endif

.PHONY: run-tests test test-all $(TEST_TARGETS)

###############################################################################
### e2e interchain test ###
###############################################################################

local-image:
docker build . -t pfm:local

ictest-forward:
cd e2e && go test -race -v -timeout 15m -run TestPacketForwardMiddleware .

ictest-timeout:
cd e2e && go test -race -v -timeout 15m -run TestTimeoutOnForward .

###############################################################################
### Linting ###
###############################################################################
Expand Down
38 changes: 26 additions & 12 deletions middleware/packet-forward-middleware/e2e/forward_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,36 @@ func TestTimeoutOnForward(t *testing.T) {
t.Skip("skipping in short mode")
}

client, network := interchaintest.DockerSetup(t)
var (
ctx = context.Background()
client, network = interchaintest.DockerSetup(t)
rep = testreporter.NewNopReporter()
eRep = rep.RelayerExecReporter(t)
chainIdA, chainIdB, chainIdC, chainIdD = "chain-a", "chain-b", "chain-c", "chain-d"
)

rep := testreporter.NewNopReporter()
eRep := rep.RelayerExecReporter(t)
vals := 1
fullNodes := 0

ctx := context.Background()
baseCfg := DefaultConfig

chainIdA, chainIdB, chainIdC, chainIdD := "chain-a", "chain-b", "chain-c", "chain-d"
baseCfg.ChainID = chainIdA
configA := baseCfg

fullNodes := 1
vals := 1
baseCfg.ChainID = chainIdB
configB := baseCfg

baseCfg.ChainID = chainIdC
configC := baseCfg

baseCfg.ChainID = chainIdD
configD := baseCfg

cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{Name: "gaia", Version: "v9.0.1", ChainConfig: ibc.ChainConfig{ChainID: chainIdA, GasPrices: "0.0uatom"}, NumFullNodes: &fullNodes, NumValidators: &vals},
{Name: "gaia", Version: "v9.0.1", ChainConfig: ibc.ChainConfig{ChainID: chainIdB, GasPrices: "0.0uatom"}, NumFullNodes: &fullNodes, NumValidators: &vals},
{Name: "gaia", Version: "v9.0.1", ChainConfig: ibc.ChainConfig{ChainID: chainIdC, GasPrices: "0.0uatom"}, NumFullNodes: &fullNodes, NumValidators: &vals},
{Name: "gaia", Version: "v9.0.1", ChainConfig: ibc.ChainConfig{ChainID: chainIdD, GasPrices: "0.0uatom"}, NumFullNodes: &fullNodes, NumValidators: &vals},
{Name: "pfm", ChainConfig: configA, NumFullNodes: &fullNodes, NumValidators: &vals},
{Name: "pfm", ChainConfig: configB, NumFullNodes: &fullNodes, NumValidators: &vals},
{Name: "pfm", ChainConfig: configC, NumFullNodes: &fullNodes, NumValidators: &vals},
{Name: "pfm", ChainConfig: configD, NumFullNodes: &fullNodes, NumValidators: &vals},
})

chains, err := cf.Chains(t.Name())
Expand Down Expand Up @@ -208,9 +221,10 @@ func TestTimeoutOnForward(t *testing.T) {
require.NoError(t, err)

chainBHeight, err = chainB.Height(ctx)
require.NoError(t, err)

// Poll for the MsgTimeout on chainB and the MsgAck on chainA
_, err = cosmos.PollForMessage[*chantypes.MsgTimeout](ctx, chainB, cosmos.DefaultEncoding().InterfaceRegistry, chainBHeight, chainBHeight+20, nil)
_, err = cosmos.PollForMessage[*chantypes.MsgTimeout](ctx, chainB, chainB.Config().EncodingConfig.InterfaceRegistry, chainBHeight, chainBHeight+20, nil)
require.NoError(t, err)

_, err = testutil.PollForAck(ctx, chainA, chainAHeight, chainAHeight+30, transferTx.Packet)
Expand Down
Loading

0 comments on commit 04e47eb

Please sign in to comment.