Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use code coverage feature from interchaintest 8.5.0 #79

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: 1.22.4
GO_VERSION: 1.22.5

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: 1.22.4
GO_VERSION: 1.22.5

jobs:
analyze:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ permissions:
packages: write

env:
GO_VERSION: 1.22.4
GO_VERSION: 1.22.5
TAR_PATH: /tmp/manifest-docker-image.tar
IMAGE_NAME: manifest-docker-image

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-bin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: '1.22.4'
go-version: '1.22.5'

- name: Clean up dist directory
run: rm -rf dist
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
types: [opened, reopened, synchronize]

env:
GO_VERSION: 1.22.4
GO_VERSION: 1.22.5

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/liftedinit/manifest-ledger

go 1.22.4
go 1.22.5

replace (
// core v0.12 was tagged wrong (SDK v51)
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.22.4
go 1.22.5

use (
.
Expand Down
8 changes: 4 additions & 4 deletions interchaintest/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/liftedinit/manifest-ledger/interchaintest

go 1.22.4
go 1.22.5

replace (
cosmossdk.io/core => cosmossdk.io/core v0.11.0 // proper SDK v50 version
Expand All @@ -18,9 +18,8 @@ require (
github.com/cosmos/cosmos-sdk v0.50.6
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-go/v8 v8.2.1
github.com/docker/docker v24.0.9+incompatible
github.com/liftedinit/manifest-ledger v0.0.0-00000000000000-000000000000
github.com/strangelove-ventures/interchaintest/v8 v8.4.0
github.com/strangelove-ventures/interchaintest/v8 v8.5.1-0.20240715163423-cbcd20f44321
github.com/strangelove-ventures/poa v0.50.1
github.com/strangelove-ventures/tokenfactory v0.50.1
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -95,6 +94,7 @@ require (
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.9+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
Expand Down Expand Up @@ -171,7 +171,7 @@ require (
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20230913220906-b988ea7da0c2 // indirect
github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20240603204351-26b456ae3afe // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions interchaintest/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,8 @@ github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA
github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20230913220906-b988ea7da0c2 h1:G/cVeTAbB9S/6FSWWqpFV0v49hiuHLbJPu9hTZ0UR2A=
github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20230913220906-b988ea7da0c2/go.mod h1:Q5BxOd9FxJqYp4vCiLGVdetecPcWTmUQIu0bRigYosU=
github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20240603204351-26b456ae3afe h1:0fcCSfvBgbagEsEMkZuxgA3Ex7IN9i1Hon0fwgMLpQw=
github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20240603204351-26b456ae3afe/go.mod h1:Q5BxOd9FxJqYp4vCiLGVdetecPcWTmUQIu0bRigYosU=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
Expand Down Expand Up @@ -1043,8 +1043,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
github.com/strangelove-ventures/interchaintest/v8 v8.4.0 h1:UHLmJfmkFXuJHfSE8qmOuEy4FWZWuRw4G6XZHm9hC6w=
github.com/strangelove-ventures/interchaintest/v8 v8.4.0/go.mod h1:nfPgRi1yjnzi+qF+0Fs9qN9kkS1Fk0oqgpKvqg5a200=
github.com/strangelove-ventures/interchaintest/v8 v8.5.1-0.20240715163423-cbcd20f44321 h1:uemY7a+M5RWC/6kTSgLql0kBEGKy/zY83p1Ne9kTzjY=
github.com/strangelove-ventures/interchaintest/v8 v8.5.1-0.20240715163423-cbcd20f44321/go.mod h1:UPMvR1joIXO8RMxDozoHIInLZWmd2345PSGLJYWyrwY=
github.com/strangelove-ventures/poa v0.50.1 h1:84OjmMrJEvQxfNKsgUW4aCeeqTqA0dswCAF7J+017Dg=
github.com/strangelove-ventures/poa v0.50.1/go.mod h1:Jmdk38G8DN3rrvPfQwVF60uUzVmn4Q7k2N8Q5eSRb6Y=
github.com/strangelove-ventures/tokenfactory v0.50.1 h1:4P+wux9HEk+apmT3nrKsuCvPbWFNOHApaYYsqX5/zY8=
Expand Down
20 changes: 5 additions & 15 deletions interchaintest/ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package interchaintest

import (
"context"
"fmt"
"path"
"testing"

"cosmossdk.io/math"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/dockerutil"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
interchaintestrelayer "github.com/strangelove-ventures/interchaintest/v8/relayer"
"github.com/strangelove-ventures/interchaintest/v8/testreporter"
Expand All @@ -21,22 +20,13 @@ import (
func TestIBC(t *testing.T) {
ctx := context.Background()

// Same as ChainNode.HomeDir() but we need it before the chain is created
// The node volume is always mounted at /var/cosmos-chain/[chain-name]
// This is a hackish way to get the coverage files from the ephemeral containers
cfgA := LocalChainConfig
cfgA.ChainID = "manifest-9"
internalGoCoverDirA := path.Join("/var/cosmos-chain", cfgA.ChainID)
cfgA.Env = []string{
fmt.Sprintf("GOCOVERDIR=%s", internalGoCoverDirA),
}
cfgA.WithCodeCoverage()

cfgB := LocalChainConfig
cfgB.ChainID = "manifest-10"
internalGoCoverDirB := path.Join("/var/cosmos-chain", cfgB.ChainID)
cfgB.Env = []string{
fmt.Sprintf("GOCOVERDIR=%s", internalGoCoverDirB),
}
cfgB.WithCodeCoverage()

cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t, zaptest.Level(zapcore.DebugLevel)), []*interchaintest.ChainSpec{
{
Expand Down Expand Up @@ -147,7 +137,7 @@ func TestIBC(t *testing.T) {
require.True(t, osmosUserBalNew.Equal(amountToSend))

t.Cleanup(func() {
CopyCoverageFromContainer(ctx, t, client, manifestA.GetNode().ContainerID(), manifestA.HomeDir())
CopyCoverageFromContainer(ctx, t, client, manifestB.GetNode().ContainerID(), manifestB.HomeDir())
dockerutil.CopyCoverageFromContainer(ctx, t, client, manifestA.GetNode().ContainerID(), manifestA.HomeDir(), ExternalGoCoverDir)
_ = ic.Close()
})
}
10 changes: 3 additions & 7 deletions interchaintest/mainfest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package interchaintest
import (
"context"
"fmt"
"path"
"testing"

sdkmath "cosmossdk.io/math"
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/dockerutil"
"github.com/strangelove-ventures/interchaintest/v8/testreporter"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zapcore"
Expand All @@ -23,15 +23,11 @@ import (
func TestManifestModule(t *testing.T) {
ctx := context.Background()

// Same as ChainNode.HomeDir() but we need it before the chain is created
// The node volume is always mounted at /var/cosmos-chain/[chain-name]
// This is a hackish way to get the coverage files from the ephemeral containers
cfgA := LocalChainConfig
internalGoCoverDir := path.Join("/var/cosmos-chain", cfgA.ChainID)
cfgA.Env = []string{
fmt.Sprintf("POA_ADMIN_ADDRESS=%s", accAddr),
fmt.Sprintf("GOCOVERDIR=%s", internalGoCoverDir),
}
cfgA.WithCodeCoverage()

cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t, zaptest.Level(zapcore.DebugLevel)), []*interchaintest.ChainSpec{
{
Expand Down Expand Up @@ -204,7 +200,7 @@ func TestManifestModule(t *testing.T) {
})

t.Cleanup(func() {
CopyCoverageFromContainer(ctx, t, client, appChain.GetNode().ContainerID(), appChain.HomeDir())
dockerutil.CopyCoverageFromContainer(ctx, t, client, manifestA.GetNode().ContainerID(), manifestA.HomeDir(), ExternalGoCoverDir)
_ = ic.Close()
})
}
18 changes: 6 additions & 12 deletions interchaintest/poa_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package interchaintest
import (
"context"
"fmt"
"path"
"strconv"
"testing"
"time"
Expand All @@ -18,6 +17,7 @@ import (
"github.com/cosmos/gogoproto/proto"
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/dockerutil"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
poatypes "github.com/strangelove-ventures/poa"
tokenfactorytypes "github.com/strangelove-ventures/tokenfactory/x/tokenfactory/types"
Expand Down Expand Up @@ -86,11 +86,7 @@ func TestGroupPOA(t *testing.T) {
t.Skip("skipping in short mode")
}

// Same as ChainNode.HomeDir() but we need it before the chain is created
// The node volume is always mounted at /var/cosmos-chain/[chain-name]
// This is a hackish way to get the coverage files from the ephemeral containers
name := "group-poa"
internalGoCoverDir := path.Join("/var/cosmos-chain", name)

err := groupPolicy.SetDecisionPolicy(createThresholdDecisionPolicy("1", 10*time.Second, 0*time.Second))
require.NoError(t, err)
Expand All @@ -106,26 +102,24 @@ func TestGroupPOA(t *testing.T) {
groupGenesis := createGroupGenesis()

cfgA := LocalChainConfig
cfgA.Name = name
cfgA.ModifyGenesis = cosmos.ModifyGenesis(groupGenesis)
cfgA.Env = []string{
fmt.Sprintf("GOCOVERDIR=%s", internalGoCoverDir),
fmt.Sprintf("POA_ADMIN_ADDRESS=%s", groupAddr), // This is required in order for GetPoAAdmin to return the Group address
}
cfgA.WithCodeCoverage()

// setup base chain
chains := interchaintest.CreateChainWithConfig(t, numVals, numNodes, name, "", cfgA)
chain := chains[0].(*cosmos.CosmosChain)

ctx, _, client, _ := interchaintest.BuildInitialChain(t, chains, false)
ctx, ic, client, _ := interchaintest.BuildInitialChain(t, chains, false)

user1Wallet, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, user1, accMnemonic, DefaultGenesisAmt, chain)
require.NoError(t, err)
_, err = interchaintest.GetAndFundTestUserWithMnemonic(ctx, user2, acc1Mnemonic, DefaultGenesisAmt, chain)
require.NoError(t, err)

// Make sure the chain's HomeDir and the GOCOVERDIR are the same
require.Equal(t, internalGoCoverDir, chain.GetNode().HomeDir())

// Software Upgrade
testSoftwareUpgrade(t, ctx, chain, &cfgA, accAddr)
// Manifest module
Expand All @@ -139,8 +133,8 @@ func TestGroupPOA(t *testing.T) {
testBankSend(t, ctx, chain, &cfgA, accAddr)
testBankSendIllegal(t, ctx, chain, &cfgA, accAddr)
t.Cleanup(func() {
// Copy coverage files from the container
CopyCoverageFromContainer(ctx, t, client, chain.GetNode().ContainerID(), chain.HomeDir())
dockerutil.CopyCoverageFromContainer(ctx, t, client, chain.GetNode().ContainerID(), chain.HomeDir(), ExternalGoCoverDir)
_ = ic.Close()
})
}

Expand Down
Loading
Loading