Skip to content

Commit

Permalink
Added some hermes stuff for tests (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjermundgaraba committed Jul 3, 2024
1 parent b9dbf8e commit 3346e4b
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
cosmossdk.io/core v0.11.0
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/log v1.3.1
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.1.0
cosmossdk.io/tools/confix v0.1.1
cosmossdk.io/x/circuit v0.1.0
Expand Down Expand Up @@ -61,7 +62,6 @@ require (
connectrpc.com/otelconnect v0.7.0 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
Expand Down
2 changes: 1 addition & 1 deletion interchaintest/ics20/ics20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (s *ICS20TestSuite) TestIBCTokenTransfers() {
_, err = s.LazyChain.SendIBCTransfer(s.Ctx, celestiaToSlothChannel.Counterparty.ChannelID, slothUserAddr, celestiaTransfer, ibc.TransferOptions{})
s.NoError(err)

s.NoError(testutil.WaitForBlocks(s.Ctx, 5, s.LazyChain, s.Stargaze))
s.NoError(testutil.WaitForBlocks(s.Ctx, 5, s.LazyChain, s.Stargaze, s.Celestia))

sgBalanceFinal, err := s.Stargaze.GetBalance(s.Ctx, sgUserAddr, s.Stargaze.Config().Denom)
s.NoError(err)
Expand Down
74 changes: 71 additions & 3 deletions interchaintest/utils/interchainvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
"github.com/CosmWasm/wasmd/x/wasm"
sdk "github.com/cosmos/cosmos-sdk/types"
sdktestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/pelletier/go-toml/v2"
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
interchaintestrelayer "github.com/strangelove-ventures/interchaintest/v8/relayer"
"github.com/strangelove-ventures/interchaintest/v8/relayer/hermes"
"github.com/strangelove-ventures/interchaintest/v8/testreporter"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
testifysuite "github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -118,6 +120,28 @@ func (s *InterchainValues) Equal(expected, actual interface{}, msgAndArgs ...int
}
}

func (s *InterchainValues) True(value bool) {
if s.testifySuiteRef != nil {
s.testifySuiteRef.True(value)
return
}

if !value {
panic("value is not true")
}
}

func (s *InterchainValues) NotNil(value interface{}) {
if s.testifySuiteRef != nil {
s.testifySuiteRef.NotNil(value)
return
}

if value == nil {
panic("value is nil")
}
}

func (s *InterchainValues) SetupInterchainValues() {
s.Ctx = context.Background()

Expand All @@ -139,8 +163,10 @@ func (s *InterchainValues) SetupInterchainValues() {
client, network := interchaintest.DockerSetup(s.TT())

rf := interchaintest.NewBuiltinRelayerFactory(
//ibc.Hermes,
ibc.CosmosRly,
zaptest.NewLogger(s.TT()),
//interchaintestrelayer.CustomDockerImage("ghcr.io/informalsystems/hermes", "1.10.0", "2000:2000"),
interchaintestrelayer.CustomDockerImage("ghcr.io/cosmos/relayer", "latest", "100:1000"),
interchaintestrelayer.StartupFlags("--processor", "events", "--block-history", "100"),
)
Expand Down Expand Up @@ -175,6 +201,10 @@ func (s *InterchainValues) SetupInterchainValues() {
})
s.NoError(err)

//s.modifyHermesConfig(r.(*hermes.Relayer))
//res := s.Relayer.Exec(s.Ctx, eRep, []string{"cat", "/home/hermes/.hermes/config.toml"}, nil)
//s.TT().Log(string(res.Stdout))

// For some reason automated path creation in Build didn't work when doing two paths 🤷
s.NoError(s.Relayer.GeneratePath(s.Ctx, s.RelayerExecRep, s.Celestia.Config().ChainID, s.LazyChain.Config().ChainID, s.CelestiaSlothPath))
s.NoError(s.Relayer.LinkPath(s.Ctx, s.RelayerExecRep, s.CelestiaSlothPath, ibc.DefaultChannelOpts(), ibc.DefaultClientOpts()))
Expand Down Expand Up @@ -224,7 +254,7 @@ func (s *InterchainValues) getChainFactory() *interchaintest.BuiltinChainFactory
Bech32Prefix: "lazy",
Denom: "useq",
CoinType: "118",
GasPrices: "0ibc/C3E53D20BC7A4CC993B17C7971F8ECD06A433C10B6A96F4C4C3714F0624C56DA",
GasPrices: "0.00useq",
GasAdjustment: 2.0,
TrustingPeriod: "112h",
NoHostMount: false,
Expand Down Expand Up @@ -311,7 +341,7 @@ da_address = \"http://%s:%s\"" >> /var/cosmos-chain/lazychain/config/config.toml
Bech32Prefix: "celestia",
Denom: "utia",
CoinType: "118",
GasPrices: "0utia",
GasPrices: "0.00utia",
GasAdjustment: 2.0,
TrustingPeriod: "112h",
NoHostMount: false,
Expand Down Expand Up @@ -344,7 +374,7 @@ da_address = \"http://%s:%s\"" >> /var/cosmos-chain/lazychain/config/config.toml
Name: "stargaze",
ChainID: sgChainID,
CoinType: "118",
GasPrices: "0stars",
GasPrices: "0.00ustars",
GasAdjustment: 2.0,
EncodingConfig: getEncodingConfig(),
},
Expand All @@ -363,3 +393,41 @@ func getEncodingConfig() *sdktestutil.TestEncodingConfig {

return &cfg
}

func (s *InterchainValues) modifyHermesConfig(h *hermes.Relayer) {
bz, err := h.ReadFileFromHomeDir(s.Ctx, ".hermes/config.toml")
s.NoError(err)

var config map[string]interface{}
err = toml.Unmarshal(bz, &config)
s.NoError(err)

chains, ok := config["chains"].([]interface{})
s.True(ok)
var celestia, lazychain map[string]interface{}
for _, ci := range chains {
c, ok := ci.(map[string]interface{})
s.True(ok)
if c["id"] == celestiaChainID {
celestia = c
} else if c["id"] == lazyChainId {
lazychain = c
}
}
s.NotNil(celestia)

celestia["compat_mode"] = "0.34"

lazychain["event_source"] = map[string]interface{}{
"mode": "pull",
"interval": "1s",
"max_retries": 20,
}
//lazychain["compat_mode"] = "0.37"

bz, err = toml.Marshal(config)
s.NoError(err)

err = h.WriteFileToHomeDir(s.Ctx, ".hermes/config.toml", bz)
s.NoError(err)
}

0 comments on commit 3346e4b

Please sign in to comment.