-
Notifications
You must be signed in to change notification settings - Fork 607
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
e2e with IBC tx and test #1216
e2e with IBC tx and test #1216
Changes from 4 commits
13027cc
e1d35e9
a0007c5
625d894
6311466
bf33585
bf51d99
4b91fd4
9442265
af9ed4a
c38c1c6
d0b3705
826bad4
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM informalsystems/hermes:0.12.0 AS hermes-builder | ||
czarcas7ic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
FROM debian:buster-slim | ||
USER root | ||
|
||
COPY --chown=0:0 --from=hermes-builder /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /usr/lib/x86_64-linux-gnu/libssl.so.1.1 | ||
COPY --chown=0:0 --from=hermes-builder /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 | ||
COPY --from=hermes-builder /usr/bin/hermes /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/hermes | ||
|
||
EXPOSE 3031 | ||
ENTRYPOINT ["hermes", "start"] | ||
czarcas7ic marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,11 @@ import ( | |
"context" | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"io/ioutil" | ||
"net/http" | ||
"os" | ||
"path" | ||
"path/filepath" | ||
"strconv" | ||
"strings" | ||
|
@@ -31,12 +35,12 @@ const ( | |
stakeDenom = "stake" | ||
minGasPrice = "0.00001" | ||
// chainA | ||
chainAName = "osmo-test-a" | ||
chainAID = "osmo-test-a" | ||
osmoBalanceA = 200000000000 | ||
stakeBalanceA = 110000000000 | ||
stakeAmountA = 100000000000 | ||
// chainB | ||
chainBName = "osmo-test-b" | ||
chainBID = "osmo-test-b" | ||
osmoBalanceB = 500000000000 | ||
stakeBalanceB = 440000000000 | ||
stakeAmountB = 400000000000 | ||
|
@@ -54,12 +58,13 @@ var ( | |
type IntegrationTestSuite struct { | ||
suite.Suite | ||
|
||
tmpDirs []string | ||
chainA *chain | ||
chainB *chain | ||
dkrPool *dockertest.Pool | ||
dkrNet *dockertest.Network | ||
valResources map[string][]*dockertest.Resource | ||
tmpDirs []string | ||
chainA *chain | ||
chainB *chain | ||
dkrPool *dockertest.Pool | ||
dkrNet *dockertest.Network | ||
hermesResource *dockertest.Resource | ||
valResources map[string][]*dockertest.Resource | ||
} | ||
|
||
func TestIntegrationTestSuite(t *testing.T) { | ||
|
@@ -70,10 +75,10 @@ func (s *IntegrationTestSuite) SetupSuite() { | |
s.T().Log("setting up e2e integration test suite...") | ||
|
||
var err error | ||
s.chainA, err = newChain(chainAName) | ||
s.chainA, err = newChain(chainAID) | ||
s.Require().NoError(err) | ||
|
||
s.chainB, err = newChain(chainBName) | ||
s.chainB, err = newChain(chainBID) | ||
s.Require().NoError(err) | ||
|
||
s.dkrPool, err = dockertest.NewPool("") | ||
|
@@ -101,6 +106,8 @@ func (s *IntegrationTestSuite) SetupSuite() { | |
s.initGenesis(s.chainB) | ||
s.initValidatorConfigs(s.chainB) | ||
s.runValidators(s.chainB, 10) | ||
|
||
s.runIBCRelayer() | ||
} | ||
|
||
func (s *IntegrationTestSuite) TearDownSuite() { | ||
|
@@ -115,6 +122,8 @@ func (s *IntegrationTestSuite) TearDownSuite() { | |
|
||
s.T().Log("tearing down e2e integration test suite...") | ||
|
||
s.Require().NoError(s.dkrPool.Purge(s.hermesResource)) | ||
|
||
for _, vr := range s.valResources { | ||
for _, r := range vr { | ||
s.Require().NoError(s.dkrPool.Purge(r)) | ||
|
@@ -137,11 +146,11 @@ func (s *IntegrationTestSuite) initNodes(c *chain) { | |
// initialize a genesis file for the first validator | ||
val0ConfigDir := c.validators[0].configDir() | ||
for _, val := range c.validators { | ||
if c.id == chainAName { | ||
if c.id == chainAID { | ||
s.Require().NoError( | ||
addGenesisAccount(val0ConfigDir, "", initBalanceStrA, val.keyInfo.GetAddress()), | ||
) | ||
} else if c.id == chainBName { | ||
} else if c.id == chainBID { | ||
s.Require().NoError( | ||
addGenesisAccount(val0ConfigDir, "", initBalanceStrB, val.keyInfo.GetAddress()), | ||
) | ||
|
@@ -197,7 +206,7 @@ func (s *IntegrationTestSuite) initGenesis(c *chain) { | |
genTxs := make([]json.RawMessage, len(c.validators)) | ||
for i, val := range c.validators { | ||
stakeAmountCoin := stakeAmountCoinA | ||
if c.id != chainAName { | ||
if c.id != chainAID { | ||
stakeAmountCoin = stakeAmountCoinB | ||
} | ||
createValmsg, err := val.buildCreateValidatorMsg(stakeAmountCoin) | ||
|
@@ -340,6 +349,94 @@ func (s *IntegrationTestSuite) runValidators(c *chain, portOffset int) { | |
) | ||
} | ||
|
||
func (s *IntegrationTestSuite) runIBCRelayer() { | ||
s.T().Log("starting Hermes relayer container...") | ||
|
||
tmpDir, err := ioutil.TempDir("", "gaia-e2e-testnet-hermes-") | ||
s.Require().NoError(err) | ||
s.tmpDirs = append(s.tmpDirs, tmpDir) | ||
|
||
gaiaAVal := s.chainA.validators[0] | ||
gaiaBVal := s.chainB.validators[0] | ||
hermesCfgPath := path.Join(tmpDir, "hermes") | ||
|
||
s.Require().NoError(os.MkdirAll(hermesCfgPath, 0755)) | ||
_, err = copyFile( | ||
filepath.Join("./scripts/", "hermes_bootstrap.sh"), | ||
filepath.Join(hermesCfgPath, "hermes_bootstrap.sh"), | ||
) | ||
s.Require().NoError(err) | ||
|
||
s.hermesResource, err = s.dkrPool.RunWithOptions( | ||
&dockertest.RunOptions{ | ||
Name: fmt.Sprintf("%s-%s-relayer", s.chainA.id, s.chainB.id), | ||
Repository: "ghcr.io/cosmos/hermes-e2e", | ||
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. It looks like we are depending on an image that is not under our control. Let's push the image to our own repository and switch to using that 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. @nikever do you know how to add this as an image to our repo? I'm not positive of the process 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. To avoid blocking this PR, let's create an issue to address this separately? It should be fine to use 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. The credentials for the I will also create personal accounts for both of you on our Docker account. Lets use a new repository |
||
Tag: "latest", | ||
NetworkID: s.dkrNet.Network.ID, | ||
Mounts: []string{ | ||
fmt.Sprintf("%s/:/root/hermes", hermesCfgPath), | ||
}, | ||
PortBindings: map[docker.Port][]docker.PortBinding{ | ||
"3031/tcp": {{HostIP: "", HostPort: "3031"}}, | ||
}, | ||
Env: []string{ | ||
fmt.Sprintf("OSMO_A_E2E_CHAIN_ID=%s", s.chainA.id), | ||
fmt.Sprintf("OSMO_B_E2E_CHAIN_ID=%s", s.chainB.id), | ||
fmt.Sprintf("OSMO_A_E2E_VAL_MNEMONIC=%s", gaiaAVal.mnemonic), | ||
fmt.Sprintf("OSMO_B_E2E_VAL_MNEMONIC=%s", gaiaBVal.mnemonic), | ||
fmt.Sprintf("OSMO_A_E2E_VAL_HOST=%s", s.valResources[s.chainA.id][0].Container.Name[1:]), | ||
fmt.Sprintf("OSMO_B_E2E_VAL_HOST=%s", s.valResources[s.chainB.id][0].Container.Name[1:]), | ||
}, | ||
Entrypoint: []string{ | ||
"sh", | ||
"-c", | ||
"chmod +x /root/hermes/hermes_bootstrap.sh && /root/hermes/hermes_bootstrap.sh", | ||
}, | ||
}, | ||
noRestart, | ||
) | ||
s.Require().NoError(err) | ||
|
||
endpoint := fmt.Sprintf("http://%s/state", s.hermesResource.GetHostPort("3031/tcp")) | ||
s.Require().Eventually( | ||
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. Can we add something similar to the setup of validators? As we discussed offline - simply keep querying balances endpoint until we get a 200 response. I think this exact The goal is to make sure that HTTP server is available before we start running actual tests. 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. Validators? You mean the node containers themselves? I believe we already have a health check for that. Are you suggesting that we implement a test that queries for validators? |
||
func() bool { | ||
resp, err := http.Get(endpoint) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
defer resp.Body.Close() | ||
|
||
bz, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
var respBody map[string]interface{} | ||
if err := json.Unmarshal(bz, &respBody); err != nil { | ||
return false | ||
} | ||
|
||
status := respBody["status"].(string) | ||
result := respBody["result"].(map[string]interface{}) | ||
|
||
return status == "success" && len(result["chains"].([]interface{})) == 2 | ||
}, | ||
5*time.Minute, | ||
time.Second, | ||
"hermes relayer not healthy", | ||
) | ||
|
||
s.T().Logf("started Hermes relayer container: %s", s.hermesResource.Container.ID) | ||
|
||
// XXX: Give time to both networks to start, otherwise we might see gRPC | ||
// transport errors. | ||
time.Sleep(10 * time.Second) | ||
|
||
// create the client, connection and channel between the two Gaia chains | ||
s.connectIBCChains() | ||
} | ||
|
||
func noRestart(config *docker.HostConfig) { | ||
// in this case we don't want the nodes to restart on failure | ||
config.RestartPolicy = docker.RestartPolicy{ | ||
|
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.
It looks like we are already not building this image in ci. Instead, we grab it from here: https://github.com/orgs/cosmos/packages/container/package/hermes-e2e
I think we should push the image to our own docker hub or github packages and use that instead
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.
@nikever can we link on getting this on our docker hub as well?
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 would also like to learn about how to get access to our docker hub. Please let me know if it's possible to get permissions for that
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.
Yes, good idea. It's very easy to push to our org. All you need is a github PAT (personal access token) and then you login with that and just push it. Note, just make sure the package set to public.