Skip to content

Commit

Permalink
Update module to go 1.22 and simple start chain test
Browse files Browse the repository at this point in the history
  • Loading branch information
tnv1 committed May 31, 2024
1 parent 8938b00 commit 62ff556
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION="1.21"
ARG GO_VERSION="1.22"
# --------------------------------------------------------
# Builder
# --------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/osmosis-labs/fee-abstraction/v8

go 1.21
go 1.22

require (
cosmossdk.io/client/v2 v2.0.0-beta.1
Expand Down
37 changes: 32 additions & 5 deletions tests/interchaintest/chain_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package interchaintest

import (
"context"
"fmt"
"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"
)

// TestStartFeeabs is a basic test to assert that spinning up a Feeabs network with 1 validator works properly.
Expand All @@ -15,11 +16,37 @@ func TestStartFeeabs(t *testing.T) {
t.Skip()
}

// Set up chains, users and channels
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)

feeabs := chains[0].(*cosmos.CosmosChain)
ic := interchaintest.NewInterchain().AddChain(feeabs)
ctx := context.Background()
chains, _, _ := SetupChain(t, ctx)
feeabs, _, _ := chains[0].(*cosmos.CosmosChain), chains[1].(*cosmos.CosmosChain), chains[2].(*cosmos.CosmosChain)
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()
})

a, err := feeabs.AuthQueryModuleAccounts(ctx)
require.NoError(t, err)
fmt.Println("module accounts", a)
t.Log("module accounts", a)
}
11 changes: 5 additions & 6 deletions tests/interchaintest/ibc_transfer_customfee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
sdktypes "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
Expand Down Expand Up @@ -43,7 +42,7 @@ func TestFeeabsGaiaIBCTransferWithIBCFee(t *testing.T) {
require.NoError(t, err)
_ = crossChainRegistryContractID
// // Instatiate
owner := sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address())
owner := sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address())
initMsg := fmt.Sprintf("{\"owner\":\"%s\"}", owner)
registryContractAddress, err := osmosis.InstantiateContract(ctx, osmosisUser.KeyName(), crossChainRegistryContractID, initMsg, true)
require.NoError(t, err)
Expand Down Expand Up @@ -75,13 +74,13 @@ func TestFeeabsGaiaIBCTransferWithIBCFee(t *testing.T) {
// Create pool Osmosis(uatom)/Osmosis(stake) on Osmosis
denomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(channOsmosisGaia.PortID, channOsmosisGaia.ChannelID, gaia.Config().Denom))
uatomOnOsmosis := denomTrace.IBCDenom()
osmosisUserBalance, err := osmosis.GetBalance(ctx, sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address()), uatomOnOsmosis)
osmosisUserBalance, err := osmosis.GetBalance(ctx, sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address()), uatomOnOsmosis)
require.NoError(t, err)
require.Equal(t, amountToSend, osmosisUserBalance)

denomTrace = transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(channOsmosisFeeabs.PortID, channOsmosisFeeabs.ChannelID, feeabs.Config().Denom))
stakeOnOsmosis := denomTrace.IBCDenom()
osmosisUserBalance, err = osmosis.GetBalance(ctx, sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address()), stakeOnOsmosis)
osmosisUserBalance, err = osmosis.GetBalance(ctx, sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address()), stakeOnOsmosis)
require.NoError(t, err)
require.Equal(t, amountToSend, osmosisUserBalance)

Expand Down Expand Up @@ -147,8 +146,8 @@ func TestFeeabsGaiaIBCTransferWithIBCFee(t *testing.T) {
// Get our Bech32 encoded user addresses
feeabsUser, gaiaUser := users[0], users[1]

feeabsUserAddr := sdktypes.MustBech32ifyAddressBytes(feeabs.Config().Bech32Prefix, feeabsUser.Address())
gaiaUserAddr := sdktypes.MustBech32ifyAddressBytes(gaia.Config().Bech32Prefix, gaiaUser.Address())
feeabsUserAddr := sdk.MustBech32ifyAddressBytes(feeabs.Config().Bech32Prefix, feeabsUser.Address())
gaiaUserAddr := sdk.MustBech32ifyAddressBytes(gaia.Config().Bech32Prefix, gaiaUser.Address())

// Compose an IBC transfer and send from Gaia -> Feeabs
osmoTokenDenom := transfertypes.GetPrefixedDenom(channFeeabsOsmosis.PortID, channFeeabsOsmosis.ChannelID, osmosis.Config().Denom)
Expand Down
17 changes: 8 additions & 9 deletions tests/interchaintest/ibc_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"cosmossdk.io/math"
sdktypes "github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
Expand Down Expand Up @@ -113,8 +113,8 @@ func TestFeeabsGaiaIBCTransfer(t *testing.T) {
// Get our Bech32 encoded user addresses
feeabsUser, gaiaUser := users[0], users[1]

feeabsUserAddr := sdktypes.MustBech32ifyAddressBytes(feeabs.Config().Bech32Prefix, feeabsUser.Address())
gaiaUserAddr := sdktypes.MustBech32ifyAddressBytes(gaia.Config().Bech32Prefix, gaiaUser.Address())
feeabsUserAddr := sdk.MustBech32ifyAddressBytes(feeabs.Config().Bech32Prefix, feeabsUser.Address())
gaiaUserAddr := sdk.MustBech32ifyAddressBytes(gaia.Config().Bech32Prefix, gaiaUser.Address())

// Get original account balances
feeabsOrigBal, err := feeabs.GetBalance(ctx, feeabsUserAddr, feeabs.Config().Denom)
Expand All @@ -126,11 +126,10 @@ func TestFeeabsGaiaIBCTransfer(t *testing.T) {
require.Equal(t, genesisWalletAmount, gaiaOrigBal)

// Compose an IBC transfer and send from feeabs -> Gaia
transferAmount := math.NewInt(1_000)
transfer := ibc.WalletAmount{
Address: gaiaUserAddr,
Denom: feeabs.Config().Denom,
Amount: transferAmount,
Amount: amountToSend,
}

channel, err := ibc.GetTransferChannel(ctx, r, eRep, feeabs.Config().ChainID, gaia.Config().ChainID)
Expand All @@ -155,17 +154,17 @@ func TestFeeabsGaiaIBCTransfer(t *testing.T) {
require.NoError(t, err)

// The feeabs account should have the original balance minus the transfer amount and the fee
require.GreaterOrEqual(t, feeabsOrigBal.Sub(transferAmount).Int64(), feeabsUpdateBal.Int64())
require.GreaterOrEqual(t, feeabsOrigBal.Sub(amountToSend).Int64(), feeabsUpdateBal.Int64())

gaiaUpdateBal, err := gaia.GetBalance(ctx, gaiaUserAddr, feeabsIBCDenom)
require.NoError(t, err)
require.Equal(t, transferAmount, gaiaUpdateBal)
require.Equal(t, amountToSend, gaiaUpdateBal)

// Compose an IBC transfer and send from Gaia -> Feeabs
transfer = ibc.WalletAmount{
Address: feeabsUserAddr,
Denom: feeabsIBCDenom,
Amount: transferAmount,
Amount: amountToSend,
}

transferTx, err = gaia.SendIBCTransfer(ctx, channel.Counterparty.ChannelID, gaiaUserAddr, transfer, ibc.TransferOptions{})
Expand All @@ -181,7 +180,7 @@ func TestFeeabsGaiaIBCTransfer(t *testing.T) {
// Assert that the funds are now back on feeabs and not on Gaia
feeabsBalAfterGettingBackToken, err := feeabs.GetBalance(ctx, feeabsUserAddr, feeabs.Config().Denom)
require.NoError(t, err)
require.Equal(t, feeabsUpdateBal.Add(transferAmount).Int64(), feeabsBalAfterGettingBackToken.Int64())
require.Equal(t, feeabsUpdateBal.Add(amountToSend).Int64(), feeabsBalAfterGettingBackToken.Int64())

gaiaUpdateBal, err = gaia.GetBalance(ctx, gaiaUserAddr, feeabsIBCDenom)
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions tests/interchaintest/packet_foward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

sdktypes "github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
Expand Down Expand Up @@ -33,7 +33,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
require.NoError(t, err)
_ = crossChainRegistryContractID
// // Instatiate
owner := sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address())
owner := sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address())
initMsg := fmt.Sprintf("{\"owner\":\"%s\"}", owner)
registryContractAddress, err := osmosis.InstantiateContract(ctx, osmosisUser.KeyName(), crossChainRegistryContractID, initMsg, true)
require.NoError(t, err)
Expand Down Expand Up @@ -65,13 +65,13 @@ func TestPacketForwardMiddleware(t *testing.T) {
// Create pool Osmosis(uatom)/Osmosis(stake) on Osmosis
denomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(channOsmosisGaia.PortID, channOsmosisGaia.ChannelID, gaia.Config().Denom))
uatomOnOsmosis := denomTrace.IBCDenom()
osmosisUserBalance, err := osmosis.GetBalance(ctx, sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address()), uatomOnOsmosis)
osmosisUserBalance, err := osmosis.GetBalance(ctx, sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address()), uatomOnOsmosis)
require.NoError(t, err)
require.Equal(t, amountToSend, osmosisUserBalance)

denomTrace = transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(channOsmosisFeeabs.PortID, channOsmosisFeeabs.ChannelID, feeabs.Config().Denom))
stakeOnOsmosis := denomTrace.IBCDenom()
osmosisUserBalance, err = osmosis.GetBalance(ctx, sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address()), stakeOnOsmosis)
osmosisUserBalance, err = osmosis.GetBalance(ctx, sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address()), stakeOnOsmosis)
require.NoError(t, err)
require.Equal(t, amountToSend, osmosisUserBalance)

Expand Down
6 changes: 3 additions & 3 deletions tests/interchaintest/query_osmosis_twap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"testing"

sdktypes "github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
Expand Down Expand Up @@ -37,7 +37,7 @@ func TestQueryOsmosisTwap(t *testing.T) {
require.NoError(t, err)
_ = crossChainRegistryContractID
// // Instatiate
owner := sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address())
owner := sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address())
initMsg := fmt.Sprintf("{\"owner\":\"%s\"}", owner)
registryContractAddress, err := osmosis.InstantiateContract(ctx, osmosisUser.KeyName(), crossChainRegistryContractID, initMsg, true)
require.NoError(t, err)
Expand Down Expand Up @@ -68,7 +68,7 @@ func TestQueryOsmosisTwap(t *testing.T) {

// Create pool Osmosis(stake)/uosmo on Osmosis
stakeOnOsmosis := GetStakeOnOsmosis(channOsmosisFeeabs, feeabs.Config().Denom)
osmosisUserBalance, err := osmosis.GetBalance(ctx, sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address()), stakeOnOsmosis)
osmosisUserBalance, err := osmosis.GetBalance(ctx, sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address()), stakeOnOsmosis)
require.NoError(t, err)
require.Equal(t, amountToSend, osmosisUserBalance)

Expand Down
25 changes: 15 additions & 10 deletions tests/interchaintest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"

"cosmossdk.io/math"
sdktypes "github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/icza/dyno"
"github.com/strangelove-ventures/interchaintest/v8"
Expand Down Expand Up @@ -44,16 +44,17 @@ const (
votingPeriod = "10s"
maxDepositPeriod = "10s"
queryEpochTime = "10s"
)

var (
FFeeabsMainRepo = "osmolabs/fee-abstraction"
// Chain and relayer version info
FeeabsMainRepo = "osmolabs/fee-abstraction"
FeeabsICTestRepo = "osmolabs/fee-abstraction-ictest"
IBCRelayerImage = "ghcr.io/cosmos/relayer"
IBCRelayerVersion = "latest"
GaiaImageVersion = "v14.1.0"
OsmosisImageVersion = "v22.0.1"
)

var (
repo, version = GetDockerImageInfo()

feeabsImage = ibc.DockerImage{
Expand Down Expand Up @@ -84,7 +85,7 @@ var (
pathFeeabsOsmosis = "feeabs-osmosis"
pathOsmosisGaia = "osmosis-gaia"
genesisWalletAmount = math.NewInt(100_000_000_000)
amountToSend = math.NewInt(1_000_000_000)
amountToSend = math.NewInt(1_000_000)
)

// feeabsEncoding registers the feeabs specific module codecs so that the associated types and msgs
Expand Down Expand Up @@ -144,7 +145,11 @@ func modifyGenesisWhitelistTwapQueryOsmosis() func(ibc.ChainConfig, []byte) ([]b
}
}

func modifyGenesisShortProposals(votingPeriod string, maxDepositPeriod string, queryEpochTime string) func(ibc.ChainConfig, []byte) ([]byte, error) {
func modifyGenesisShortProposals(
votingPeriod string,
maxDepositPeriod string,
queryEpochTime string,
) func(ibc.ChainConfig, []byte) ([]byte, error) {
return func(chainConfig ibc.ChainConfig, genbz []byte) ([]byte, error) {
g := make(map[string]interface{})
if err := json.Unmarshal(genbz, &g); err != nil {
Expand Down Expand Up @@ -463,7 +468,7 @@ func SetupChain(t *testing.T, ctx context.Context) ([]ibc.Chain, []ibc.Wallet, [
// Send Gaia uatom to Osmosis
gaiaHeight, err := gaia.Height(ctx)
require.NoError(t, err)
dstAddress := sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address())
dstAddress := sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address())
transfer := ibc.WalletAmount{
Address: dstAddress,
Denom: gaia.Config().Denom,
Expand All @@ -482,7 +487,7 @@ func SetupChain(t *testing.T, ctx context.Context) ([]ibc.Chain, []ibc.Wallet, [
// Send Feeabs stake to Osmosis
feeabsHeight, err := feeabs.Height(ctx)
require.NoError(t, err)
dstAddress = sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address())
dstAddress = sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, osmosisUser.Address())
transfer = ibc.WalletAmount{
Address: dstAddress,
Denom: feeabs.Config().Denom,
Expand All @@ -501,7 +506,7 @@ func SetupChain(t *testing.T, ctx context.Context) ([]ibc.Chain, []ibc.Wallet, [
// Send Gaia uatom to Feeabs
gaiaHeight, err = gaia.Height(ctx)
require.NoError(t, err)
dstAddress = sdktypes.MustBech32ifyAddressBytes(feeabs.Config().Bech32Prefix, feeabsUser.Address())
dstAddress = sdk.MustBech32ifyAddressBytes(feeabs.Config().Bech32Prefix, feeabsUser.Address())
transfer = ibc.WalletAmount{
Address: dstAddress,
Denom: gaia.Config().Denom,
Expand Down Expand Up @@ -558,7 +563,7 @@ func SetupOsmosisContracts(t *testing.T,

// Instantiate contracts
// 1. Crosschain Registry Contract
owner := sdktypes.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, user.Address())
owner := sdk.MustBech32ifyAddressBytes(osmosis.Config().Bech32Prefix, user.Address())
initMsg := fmt.Sprintf("{\"owner\":\"%s\"}", owner)

registryContractAddr, err := osmosis.InstantiateContract(ctx, user.KeyName(), registryCodeId, initMsg, true)
Expand Down

0 comments on commit 62ff556

Please sign in to comment.