-
Notifications
You must be signed in to change notification settings - Fork 606
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
Add E2ETestSuite Type (E2E #3) #1650
Changes from all commits
47be6be
ce80411
bfbba03
4569fa5
272ad61
6afe90c
7497574
7091fbc
6ebcc6d
05d9a45
308eb0f
9ebacd7
c431850
3c4f62b
b5fff2a
abb0eca
f36025b
9039137
30591c9
b43d07e
b1bcc12
d740296
e94d35b
848f888
99328b1
35e454f
ccd9fd5
e154f09
236eb9f
11227eb
7541beb
e768a46
ce2828e
dcd5048
1fcd668
67b1a8b
07f7015
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
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) { | ||
suite.Run(t, new(FeeMiddlewareTestSuite)) | ||
} | ||
|
||
type FeeMiddlewareTestSuite struct { | ||
suite.Suite | ||
testsuite.E2ETestSuite | ||
} | ||
|
||
func (s *FeeMiddlewareTestSuite) TestPlaceholder() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the place holder test now creates chains in a container and starts a relayer (no assertions are made yet!) |
||
tag, ok := os.LookupEnv("SIMD_TAG") | ||
s.Require().True(ok) | ||
s.T().Logf("SIMD_TAG=%s", tag) | ||
ctx := context.Background() | ||
r := s.SetupChainsRelayerAndChannel(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" | ||
Comment on lines
+34
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: rename to avoid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is trickier as it is part of the ibctest library. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there already an issue created? Would you like me to open one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't created an issue against the ibctest repo yet for this. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea you are right. Do you think it is too much work to request changes for? In the past I've spent a fair amount of time debugging the difference between source/destination, that it seems worthwhile to me to consider changing naming conventions if a library is going to have increased usage. Happy to let the maintainers decide if they want to do the changes, but the "source" and "destination" terminology doesn't make much sense when packet flow is bidirectional There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at the ibctest code I see the following func (commander) CreateChannel(pathName string, opts ibc.CreateChannelOptions, homeDir string) []string {
return []string{
"rly", "tx", "channel", pathName,
"--src-port", opts.SourcePortName,
"--dst-port", opts.DestPortName,
"--order", opts.Order.String(),
"--version", opts.Version,
"--home", homeDir,
}
} It looks like the field names are mappings to the go relayer arguments for channel creation so in this case I think the name makes sense. I definitely agree that overall we shouldn't use |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package testconfig | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/strangelove-ventures/ibctest/ibc" | ||
) | ||
|
||
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, | ||
} | ||
} | ||
|
||
// 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, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had misunderstood the behaviour of the ref/pr values in GithubActions. I simplified this script to simply accept a PR number as a string, or use "main" if we are not in a PR.