Skip to content

Commit

Permalink
Optimize host zone proposal test faster
Browse files Browse the repository at this point in the history
  • Loading branch information
tnv1 committed May 31, 2024
1 parent b20e0bb commit 987dd07
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 16 deletions.
46 changes: 36 additions & 10 deletions tests/interchaintest/host_zone_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"context"
"testing"

"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"

feeabsCli "github.com/osmosis-labs/fee-abstraction/v8/tests/interchaintest/feeabs"
)
Expand All @@ -14,18 +16,42 @@ func TestHostZoneProposal(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
}
ctx := context.Background()

chains, users, channels := SetupChain(t, ctx)
feeabs, _, osmosis := chains[0].(*cosmos.CosmosChain), chains[1].(*cosmos.CosmosChain), chains[2].(*cosmos.CosmosChain)
channFeeabsOsmosis, _, channFeeabsOsmosisICQ := channels[0], channels[1], channels[6]

feeabsUser, _, _ := users[0], users[1], users[2]
osmoOnFeeabs := GetOsmoOnFeeabs(channFeeabsOsmosis, osmosis.Config().Denom)
numVals := 1
numFullNodes := 1

cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
Name: "feeabs",
ChainConfig: feeabsConfig,
NumValidators: &numVals,
NumFullNodes: &numFullNodes,
},
})

chains, err := cf.Chains(t.Name())
require.NoError(t, err)

ParamChangeProposal(t, ctx, feeabs, feeabsUser, &channFeeabsOsmosis, &channFeeabsOsmosisICQ, osmoOnFeeabs)
ctx := context.Background()
feeabs := chains[0].(*cosmos.CosmosChain)
ic := interchaintest.NewInterchain().AddChain(feeabs)
client, network := interchaintest.DockerSetup(t)

require.NoError(t, ic.Build(ctx, nil, interchaintest.InterchainBuildOptions{
TestName: t.Name(),
Client: client,
NetworkID: network,
SkipPathCreation: true,
}))
t.Cleanup(func() {
_ = ic.Close()
})

users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), genesisWalletAmount, feeabs)
feeabsUser := users[0]

ParamChangeProposal(t, ctx, feeabs, feeabsUser, "channel-0", "channel-1", fakeIBCDenom)
AddHostZoneProposal(t, ctx, feeabs, feeabsUser)

_, err := feeabsCli.QueryHostZoneConfigWithDenom(feeabs, ctx, osmoOnFeeabs)
_, err = feeabsCli.QueryHostZoneConfigWithDenom(feeabs, ctx, fakeIBCDenom)
require.NoError(t, err)
}
2 changes: 1 addition & 1 deletion tests/interchaintest/ibc_transfer_customfee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestFeeabsGaiaIBCTransferWithIBCFee(t *testing.T) {
// Setup feeabs module & add host zone via proposals
////////////////////////////////////////////////////////////////////////////////////////

ParamChangeProposal(t, ctx, feeabs, feeabsUser, &channFeeabsOsmosis, &channFeeabsOsmosisICQ, stakeOnOsmosis)
ParamChangeProposal(t, ctx, feeabs, feeabsUser, channFeeabsOsmosis.ChannelID, channFeeabsOsmosisICQ.ChannelID, stakeOnOsmosis)
AddHostZoneProposal(t, ctx, feeabs, feeabsUser)
_, err = feeabsCli.QueryAllHostZoneConfig(feeabs, ctx)
require.NoError(t, err)
Expand Down
17 changes: 12 additions & 5 deletions tests/interchaintest/query_osmosis_twap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestQueryOsmosisTwap(t *testing.T) {
err = osmosis.QueryContract(ctx, registryContractAddress, queryMsg, &res)
require.NoError(t, err)

ParamChangeProposal(t, ctx, feeabs, feeabsUser, &channFeeabsOsmosis, &channFeeabsOsmosisICQ, stakeOnOsmosis)
ParamChangeProposal(t, ctx, feeabs, feeabsUser, channFeeabsOsmosis.ChannelID, channFeeabsOsmosisICQ.ChannelID, stakeOnOsmosis)
AddHostZoneProposal(t, ctx, feeabs, feeabsUser)

// ensure that the host zone is added
Expand All @@ -120,16 +120,23 @@ func TestQueryOsmosisTwap(t *testing.T) {
require.NoError(t, err)
}

func ParamChangeProposal(t *testing.T, ctx context.Context, feeabs *cosmos.CosmosChain, feeabsUser ibc.Wallet, channFeeabsOsmosis, channFeeabsOsmosisFeeabs *ibc.ChannelOutput, stakeOnOsmosis string) {
func ParamChangeProposal(
t *testing.T,
ctx context.Context,
feeabs *cosmos.CosmosChain,
feeabsUser ibc.Wallet,
channFeeabsOsmosis, channFeeabsOsmosisFeeabs string,
stakeOnOsmosis string,
) {
t.Helper()
govAddr, err := feeabs.AuthQueryModuleAddress(ctx, "gov")
require.NoError(t, err)
require.NotEmpty(t, govAddr)
updateParamMsg := feeabstypes.MsgUpdateParams{
Params: feeabstypes.Params{
OsmosisQueryTwapPath: "/osmosis.twap.v1beta1.Query/ArithmeticTwapToNow",
IbcTransferChannel: channFeeabsOsmosis.ChannelID,
IbcQueryIcqChannel: channFeeabsOsmosisFeeabs.ChannelID,
IbcTransferChannel: channFeeabsOsmosis,
IbcQueryIcqChannel: channFeeabsOsmosisFeeabs,
NativeIbcedInOsmosis: stakeOnOsmosis,
OsmosisCrosschainSwapAddress: "osmo17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgs5yczr8",
ChainName: feeabs.Config().ChainID,
Expand Down Expand Up @@ -170,7 +177,7 @@ func AddHostZoneProposal(t *testing.T, ctx context.Context, feeabs *cosmos.Cosmo

addHostZoneMsg := feeabstypes.MsgAddHostZone{
HostChainConfig: &feeabstypes.HostChainFeeAbsConfig{
IbcDenom: "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B",
IbcDenom: fakeIBCDenom,
OsmosisPoolTokenDenomIn: "uosmo",
PoolId: 1,
Status: 0,
Expand Down
1 change: 1 addition & 0 deletions tests/interchaintest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ var (
pathOsmosisGaia = "osmosis-gaia"
genesisWalletAmount = math.NewInt(100_000_000_000)
amountToSend = math.NewInt(1_000_000_000)
fakeIBCDenom = "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"
)

// feeabsEncoding registers the feeabs specific module codecs so that the associated types and msgs
Expand Down

0 comments on commit 987dd07

Please sign in to comment.