Skip to content
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

Optimize host zone proposal test faster #204

Merged
merged 10 commits into from
May 31, 2024
2 changes: 2 additions & 0 deletions tests/interchaintest/chain_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func TestStartFeeabs(t *testing.T) {
t.Skip()
}

t.Parallel()

numVals := 1
numFullNodes := 1

Expand Down
45 changes: 37 additions & 8 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,45 @@ 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]
t.Parallel()

numVals := 1
numFullNodes := 1

feeabsUser, _, _ := users[0], users[1], users[2]
osmoOnFeeabs := GetOsmoOnFeeabs(channFeeabsOsmosis, osmosis.Config().Denom)
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
Name: "feeabs",
ChainConfig: feeabsConfig,
NumValidators: &numVals,
NumFullNodes: &numFullNodes,
},
})

ParamChangeProposal(t, ctx, feeabs, feeabsUser, &channFeeabsOsmosis, &channFeeabsOsmosisICQ, osmoOnFeeabs)
chains, err := cf.Chains(t.Name())
require.NoError(t, err)

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
3 changes: 3 additions & 0 deletions tests/interchaintest/packet_foward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func TestPacketForwardMiddleware(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
}

t.Parallel()

// Set up chains, users and channels
ctx := context.Background()
chains, users, channels := SetupChain(t, ctx)
Expand Down
20 changes: 15 additions & 5 deletions tests/interchaintest/query_osmosis_twap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func TestQueryOsmosisTwap(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
}

t.Parallel()

// Set up chains, users and channels
ctx := context.Background()
chains, users, channels := SetupChain(t, ctx)
Expand Down Expand Up @@ -98,7 +101,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 +123,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 +180,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
Loading