diff --git a/interchaintest/go.mod b/interchaintest/go.mod index 95c9722..17dd94b 100644 --- a/interchaintest/go.mod +++ b/interchaintest/go.mod @@ -9,6 +9,9 @@ replace ( github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/liftedinit/manifest-ledger => ../ + + // TODO: Remove when https://github.com/strangelove-ventures/interchaintest/pull/1173 is merged + github.com/strangelove-ventures/interchaintest/v8 => github.com/fmorency/interchaintest/v8 v8.0.0-20240705153035-7061d824d5a8 ) require ( @@ -18,9 +21,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.0 github.com/strangelove-ventures/poa v0.50.1 github.com/strangelove-ventures/tokenfactory v0.50.1 github.com/stretchr/testify v1.9.0 @@ -95,6 +97,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 @@ -171,7 +174,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 diff --git a/interchaintest/go.sum b/interchaintest/go.sum index 737d6c9..c003cf7 100644 --- a/interchaintest/go.sum +++ b/interchaintest/go.sum @@ -465,6 +465,8 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fmorency/interchaintest/v8 v8.0.0-20240705153035-7061d824d5a8 h1:FSAbAZdICdBaYFvCWTQcOaxcP6WWkIPCnWjslNA0t3g= +github.com/fmorency/interchaintest/v8 v8.0.0-20240705153035-7061d824d5a8/go.mod h1:UPMvR1joIXO8RMxDozoHIInLZWmd2345PSGLJYWyrwY= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= @@ -824,8 +826,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= @@ -1043,8 +1045,6 @@ 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/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= diff --git a/interchaintest/ibc_test.go b/interchaintest/ibc_test.go index 6920df5..6fbb0fc 100644 --- a/interchaintest/ibc_test.go +++ b/interchaintest/ibc_test.go @@ -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" @@ -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{ { @@ -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() }) } diff --git a/interchaintest/mainfest_test.go b/interchaintest/mainfest_test.go index f3c8f44..6d77351 100644 --- a/interchaintest/mainfest_test.go +++ b/interchaintest/mainfest_test.go @@ -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" @@ -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{ { @@ -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() }) } diff --git a/interchaintest/poa_group_test.go b/interchaintest/poa_group_test.go index d55f052..45ee9cb 100644 --- a/interchaintest/poa_group_test.go +++ b/interchaintest/poa_group_test.go @@ -3,7 +3,6 @@ package interchaintest import ( "context" "fmt" - "path" "strconv" "testing" "time" @@ -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" @@ -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) @@ -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 @@ -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() }) } diff --git a/interchaintest/poa_test.go b/interchaintest/poa_test.go index 17c57b1..f24210f 100644 --- a/interchaintest/poa_test.go +++ b/interchaintest/poa_test.go @@ -2,18 +2,14 @@ package interchaintest import ( "context" - "encoding/json" - "fmt" - "path" - "strings" "testing" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/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" - "github.com/strangelove-ventures/interchaintest/v8/testutil" "github.com/strangelove-ventures/poa" "github.com/stretchr/testify/require" @@ -23,7 +19,6 @@ import ( const ( // cosmos1hj5fveer5cjtn4wd6wstzugjfdxzl0xpxvjjvr (test_node.sh) accMnemonic acc1Mnemonic = "wealth flavor believe regret funny network recall kiss grape useless pepper cram hint member few certain unveil rather brick bargain curious require crowd raise" - userFunds = 10_000_000_000 numVals = 2 numNodes = 0 ) @@ -33,26 +28,17 @@ func TestPOA(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 := "poa" - internalGoCoverDir := path.Join("/var/cosmos-chain", name) - cfgA := LocalChainConfig - cfgA.Env = []string{ - fmt.Sprintf("GOCOVERDIR=%s", internalGoCoverDir), - } + cfgA.Name = name + cfgA.WithCodeCoverage() // setup base chain chains := interchaintest.CreateChainWithConfig(t, numVals, numNodes, name, "", cfgA) chain := chains[0].(*cosmos.CosmosChain) enableBlockDB := false - ctx, _, client, _ := interchaintest.BuildInitialChain(t, chains, enableBlockDB) - - // Make sure the chain's HomeDir and the GOCOVERDIR are the same - require.Equal(t, internalGoCoverDir, chain.GetNode().HomeDir()) + ctx, ic, client, _ := interchaintest.BuildInitialChain(t, chains, enableBlockDB) // setup accounts acc0, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, "acc0", accMnemonic, DefaultGenesisAmt, chain) @@ -85,49 +71,11 @@ func TestPOA(t *testing.T) { 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() }) } -// createAuthzJSON generates a JSON file for an authorization message. -// This is a copy of interchaintest/chain/cosmos/module_authz.go#createAuthzJSON with the addition of the chain environment variables to the Exec call -func createAuthzJSON(ctx context.Context, chain *cosmos.CosmosChain, filePath string, genMsgCmd []string) error { - if !strings.Contains(strings.Join(genMsgCmd, " "), "--generate-only") { - genMsgCmd = append(genMsgCmd, "--generate-only") - } - - res, resErr, err := chain.GetNode().Exec(ctx, genMsgCmd, chain.Config().Env) - if resErr != nil { - return fmt.Errorf("failed to generate msg: %s", resErr) - } - if err != nil { - return err - } - - return chain.GetNode().WriteFile(ctx, res, filePath) -} - -// ExecTx executes a transaction, waits for 2 blocks if successful, then returns the tx hash. -// This is a copy of interchaintest/chain/cosmos/chain_node.go#ExecTx with the addition of the chain environment variables to the Exec call -func ExecTx(ctx context.Context, chain *cosmos.CosmosChain, keyName string, command ...string) (string, error) { - stdout, _, err := chain.GetNode().Exec(ctx, chain.GetNode().TxCommand(keyName, command...), chain.Config().Env) - if err != nil { - return "", err - } - output := cosmos.CosmosTx{} - err = json.Unmarshal([]byte(stdout), &output) - if err != nil { - return "", err - } - if output.Code != 0 { - return output.TxHash, fmt.Errorf("transaction failed with code %d: %s", output.Code, output.RawLog) - } - if err := testutil.WaitForBlocks(ctx, 2, chain.GetNode()); err != nil { - return "", err - } - return output.TxHash, nil -} - func testStakingDisabled(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, validators []string, acc0, acc1 ibc.Wallet) { t.Log("\n===== TEST STAKING DISABLED =====") @@ -147,13 +95,7 @@ func testStakingDisabled(t *testing.T, ctx context.Context, chain *cosmos.Cosmos nested := []string{"tx", "staking", "delegate", validators[0], "1stake"} nestedCmd := helpers.TxCommandBuilder(ctx, chain, nested, granter.FormattedAddress()) - // Execute nested message via a wrapped Exec - // Workaround AuthzExec which doesn't propagate the environment variables to the Exec call - fileName := "authz.json" - err = createAuthzJSON(ctx, chain, fileName, nestedCmd) - require.NoError(t, err) - - _, err = ExecTx(ctx, chain, grantee.KeyName(), []string{"authz", "exec", path.Join(chain.GetNode().HomeDir(), fileName)}...) + _, err = chain.GetNode().AuthzExec(ctx, grantee, nestedCmd) require.Error(t, err) require.ErrorContains(t, err, poa.ErrStakingActionNotAllowed.Error()) } diff --git a/interchaintest/setup.go b/interchaintest/setup.go index 246e2ed..dc7f63b 100644 --- a/interchaintest/setup.go +++ b/interchaintest/setup.go @@ -1,22 +1,9 @@ package interchaintest import ( - "archive/tar" - "bytes" - "context" - "io" - "os" - "path" - "path/filepath" - "strings" - "testing" - - "github.com/docker/docker/client" + grouptypes "github.com/cosmos/cosmos-sdk/x/group" poatypes "github.com/strangelove-ventures/poa" tokenfactorytypes "github.com/strangelove-ventures/tokenfactory/x/tokenfactory/types" - "github.com/stretchr/testify/require" - - grouptypes "github.com/cosmos/cosmos-sdk/x/group" manifesttypes "github.com/liftedinit/manifest-ledger/x/manifest/types" @@ -107,41 +94,3 @@ func AppEncoding() *sdktestutil.TestEncodingConfig { return &enc } - -func CopyCoverageFromContainer(ctx context.Context, t *testing.T, client *client.Client, containerId string, internalGoCoverDir string) { - r, _, err := client.CopyFromContainer(ctx, containerId, internalGoCoverDir) - require.NoError(t, err) - defer r.Close() - - err = os.MkdirAll(ExternalGoCoverDir, os.ModePerm) - require.NoError(t, err) - - tr := tar.NewReader(r) - for { - hdr, err := tr.Next() - if err == io.EOF { - break // End of archive - } - require.NoError(t, err) - - var fileBuff bytes.Buffer - _, err = io.Copy(&fileBuff, tr) - require.NoError(t, err) - - name := hdr.Name - extractedFileName := path.Base(name) - - //Only extract coverage files - if !strings.HasPrefix(extractedFileName, "cov") { - continue - } - isDirectory := extractedFileName == "" - if isDirectory { - continue - } - - filePath := filepath.Join(ExternalGoCoverDir, extractedFileName) - err = os.WriteFile(filePath, fileBuff.Bytes(), os.ModePerm) - require.NoError(t, err) - } -} diff --git a/interchaintest/tokenfactory_test.go b/interchaintest/tokenfactory_test.go index 340dd0c..93da68e 100644 --- a/interchaintest/tokenfactory_test.go +++ b/interchaintest/tokenfactory_test.go @@ -2,12 +2,11 @@ package interchaintest import ( "context" - "fmt" - "path" "testing" "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" @@ -17,14 +16,8 @@ import ( func TestTokenFactory(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("GOCOVERDIR=%s", internalGoCoverDir), - } + cfgA.WithCodeCoverage() cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t, zaptest.Level(zapcore.DebugLevel)), []*interchaintest.ChainSpec{ { @@ -82,7 +75,8 @@ func TestTokenFactory(t *testing.T) { require.NoError(t, err) t.Log("Mint TF Denom to user") - node.TokenFactoryMintDenom(ctx, user.FormattedAddress(), tfDenom, 100) + _, err = node.TokenFactoryMintDenom(ctx, user.FormattedAddress(), tfDenom, 100) + require.NoError(t, err) if balance, err := appChain.GetBalance(ctx, uaddr, tfDenom); err != nil { t.Fatal(err) } else if balance.Int64() != 100 { @@ -107,7 +101,8 @@ func TestTokenFactory(t *testing.T) { } t.Log("SudoMint from non PoA Admin (fail) - Manifest specific") - node.TokenFactoryMintDenom(ctx, user.FormattedAddress(), sudoToken, 7) + _, err = node.TokenFactoryMintDenom(ctx, user.FormattedAddress(), sudoToken, 7) + require.Error(t, err) if balance, err := appChain.GetBalance(ctx, uaddr, sudoToken); err != nil { t.Fatal(err) } else if balance.Int64() != 0 { @@ -116,7 +111,8 @@ func TestTokenFactory(t *testing.T) { } t.Log("Mint TF Denom to another user") - node.TokenFactoryMintDenomTo(ctx, user.FormattedAddress(), tfDenom, 70, user2.FormattedAddress()) + _, err = node.TokenFactoryMintDenomTo(ctx, user.FormattedAddress(), tfDenom, 70, user2.FormattedAddress()) + require.NoError(t, err) if balance, err := appChain.GetBalance(ctx, uaddr2, tfDenom); err != nil { t.Fatal(err) } else if balance.Int64() != 70 { @@ -135,7 +131,7 @@ func TestTokenFactory(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() }) }