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

e2e: expedited proposal test #2341

Merged
merged 10 commits into from
Aug 13, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ test-sim-app:
test-sim-determinism:
@VERSION=$(VERSION) go test -mod=readonly -run ^TestAppStateDeterminism -v $(PACKAGES_SIM)

test-sim-benchmark:
test-sim-bench:
@VERSION=$(VERSION) go test -benchmem -run ^BenchmarkFullAppSimulation -bench ^BenchmarkFullAppSimulation -cpuprofile cpu.out $(PACKAGES_SIM)

test-e2e:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ require (
replace (
// branch: v0.27.0.rc3-osmo, current tag: v0.27.0.rc3-osmo
github.com/CosmWasm/wasmd => github.com/osmosis-labs/wasmd v0.27.0-rc2.0.20220517191021-59051aa18d58
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current tag: 0.45.0x-osmo-v11-alpha.5 current branch: osmosis-main
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220727221653-51bfa90799ee
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current tag: 0.45.0x-osmo-v12-alpha.1 current branch: osmosis-main
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220808173601-02273b880e44
// Use Osmosis fast iavl
github.com/cosmos/iavl => github.com/osmosis-labs/iavl v0.17.3-osmo-v7
// use cosmos-compatible protobufs
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1043,8 +1043,8 @@ github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4
github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs=
github.com/ory/dockertest/v3 v3.9.1 h1:v4dkG+dlu76goxMiTT2j8zV7s4oPPEppKT8K8p2f1kY=
github.com/ory/dockertest/v3 v3.9.1/go.mod h1:42Ir9hmvaAPm0Mgibk6mBPi7SFvTXxEcnztDYOJ//uM=
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220727221653-51bfa90799ee h1:JUWaacaNfxC0IxxkpC/MsJozi1eKQztZX+Wa9OU6+cw=
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220727221653-51bfa90799ee/go.mod h1:uUkGXyCWol+CHoaMxZA0nKglvlN5uHBCMbMSsZoGSAs=
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220808173601-02273b880e44 h1:mjsR4jDM16FYVkh5ZQv6IRcPheU3yG60t1KetG8FEPU=
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220808173601-02273b880e44/go.mod h1:uUkGXyCWol+CHoaMxZA0nKglvlN5uHBCMbMSsZoGSAs=
github.com/osmosis-labs/iavl v0.17.3-osmo-v7 h1:6KcADC/WhL7yDmNQxUIJt2XmzNt4FfRmq9gRke45w74=
github.com/osmosis-labs/iavl v0.17.3-osmo-v7/go.mod h1:lJEOIlsd3sVO0JDyXWIXa9/Ur5FBscP26zJx0KxHjto=
github.com/osmosis-labs/wasmd v0.27.0-rc2.0.20220517191021-59051aa18d58 h1:15l3Iss2oCGCeJRi2g3CuCnqmEjpAr3Le7cDnoN/LS0=
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/configurer/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ type Config struct {

ValidatorInitConfigs []*initialization.NodeConfig
// voting period is number of blocks it takes to deposit, 1.2 seconds per validator to vote on the prop, and a buffer.
VotingPeriod float32
VotingPeriod float32
ExpeditedVotingPeriod float32
// upgrade proposal height for chain.
UpgradePropHeight int64
LatestProposalNumber int
Expand Down
36 changes: 33 additions & 3 deletions tests/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"regexp"
"strconv"
"strings"
"sync"
"time"

appparams "github.com/osmosis-labs/osmosis/v10/app/params"
"github.com/osmosis-labs/osmosis/v10/tests/e2e/configurer/config"
Expand Down Expand Up @@ -37,17 +39,24 @@ func (n *NodeConfig) SubmitSuperfluidProposal(asset string, initialDeposit sdk.C
n.LogActionF("successfully submitted superfluid proposal for asset %s", asset)
}

func (n *NodeConfig) SubmitTextProposal(text string, initialDeposit sdk.Coin) {
func (n *NodeConfig) SubmitTextProposal(text string, initialDeposit sdk.Coin, isExpedited bool) {
n.LogActionF("submitting text gov proposal")
cmd := []string{"osmosisd", "tx", "gov", "submit-proposal", "--type=text", fmt.Sprintf("--title=\"%s\"", text), "--description=\"test text proposal\"", "--from=val", fmt.Sprintf("--deposit=%s", initialDeposit)}
if isExpedited {
cmd = append(cmd, "--is-expedited=true")
}
_, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd)
require.NoError(n.t, err)
n.LogActionF("successfully submitted text gov proposal")
}

func (n *NodeConfig) DepositProposal(proposalNumber int) {
func (n *NodeConfig) DepositProposal(proposalNumber int, isExpedited bool) {
n.LogActionF("depositing on proposal: %d", proposalNumber)
cmd := []string{"osmosisd", "tx", "gov", "deposit", fmt.Sprintf("%d", proposalNumber), sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.MinDepositValue)).String(), "--from=val"}
deposit := sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.MinDepositValue)).String()
if isExpedited {
deposit = sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.MinExpeditedDepositValue)).String()
}
cmd := []string{"osmosisd", "tx", "gov", "deposit", fmt.Sprintf("%d", proposalNumber), deposit, "--from=val"}
_, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd)
require.NoError(n.t, err)
n.LogActionF("successfully deposited on proposal %d", proposalNumber)
Expand Down Expand Up @@ -105,3 +114,24 @@ func (n *NodeConfig) CreateWallet(walletName string) string {
n.LogActionF("created wallet %s, waller address - %s", walletName, walletAddr)
return walletAddr
}

func (n *NodeConfig) QueryPropStatusTimed(wg *sync.WaitGroup, proposalNumber int, desiredStatus string, totalTime chan time.Duration) {
defer wg.Done()
start := time.Now()
require.Eventually(
n.t,
func() bool {
status, err := n.QueryPropStatus(proposalNumber)
if err != nil {
return false
}

return status == desiredStatus
},
1*time.Minute,
10*time.Millisecond,
"Osmosis node failed to retrieve prop tally",
)
elapsed := time.Since(start)
totalTime <- elapsed
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
}
14 changes: 14 additions & 0 deletions tests/e2e/configurer/chain/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ func (n *NodeConfig) QueryPropTally(proposalNumber int) (sdk.Int, sdk.Int, sdk.I
return noTotal, yesTotal, noWithVetoTotal, abstainTotal, nil
}

func (n *NodeConfig) QueryPropStatus(proposalNumber int) (string, error) {
path := fmt.Sprintf("cosmos/gov/v1beta1/proposals/%d", proposalNumber)
bz, err := n.QueryGRPCGateway(path)
require.NoError(n.t, err)

var propResp govtypes.QueryProposalResponse
if err := util.Cdc.UnmarshalJSON(bz, &propResp); err != nil {
return "", err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something that is beyond the scope of this PR but is worth thinking about is when to return an error vs using require.NoError()

It seems that we are inconsistent across all methods and setting up a standard for this would be great

}
proposalStatus := propResp.Proposal.Status

return proposalStatus.String(), nil
}

func (n *NodeConfig) QueryIntermediaryAccount(denom string, valAddr string) (int, error) {
intAccount := superfluidtypes.GetSuperfluidIntermediaryAccountAddr(denom, valAddr)
path := fmt.Sprintf(
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/configurer/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const (
var (
// Minimum deposit value for a proposal to enter a voting period.
MinDepositValue = govtypes.DefaultMinDepositTokens.Int64()
// Minimum expedited deposit value for a proposal to enter a voting period.
MinExpeditedDepositValue = govtypes.DefaultMinExpeditedDepositTokens.Int64()
// Minimum deposit value for proposal to be submitted.
InitialMinDeposit = MinDepositValue / 4
// Minimum expedited deposit value for proposal to be submitted.
InitialMinExpeditedDeposit = MinExpeditedDepositValue / 4
)
12 changes: 11 additions & 1 deletion tests/e2e/configurer/current.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/osmosis-labs/osmosis/v10/tests/e2e/configurer/chain"
"github.com/osmosis-labs/osmosis/v10/tests/e2e/configurer/config"
"github.com/osmosis-labs/osmosis/v10/tests/e2e/containers"
"github.com/osmosis-labs/osmosis/v10/tests/e2e/initialization"
)
Expand Down Expand Up @@ -44,7 +45,16 @@ func (cb *CurrentBranchConfigurer) ConfigureChain(chainConfig *chain.Config) err
return err
}
cb.t.Logf("temp directory for chain-id %v: %v", chainConfig.Id, tmpDir)
initializedChain, err := initialization.InitChain(chainConfig.Id, tmpDir, chainConfig.ValidatorInitConfigs, time.Duration(chainConfig.VotingPeriod), 0)

numVal := float32(len(chainConfig.ValidatorInitConfigs))

chainConfig.VotingPeriod = config.PropDepositBlocks + numVal*config.PropVoteBlocks + config.PropBufferBlocks
chainConfig.ExpeditedVotingPeriod = config.PropDepositBlocks + numVal*config.PropVoteBlocks + config.PropBufferBlocks - 1

czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
votingPeriodDuration := time.Duration(chainConfig.VotingPeriod * 1000000000)
expeditedVotingPeriodDuration := time.Duration(chainConfig.ExpeditedVotingPeriod * 1000000000)

initializedChain, err := initialization.InitChain(chainConfig.Id, tmpDir, chainConfig.ValidatorInitConfigs, votingPeriodDuration, expeditedVotingPeriodDuration, 0)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/configurer/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (uc *UpgradeConfigurer) ConfigureChain(chainConfig *chain.Config) error {

numVal := float32(len(chainConfig.ValidatorInitConfigs))
chainConfig.VotingPeriod = config.PropDepositBlocks + numVal*config.PropVoteBlocks + config.PropBufferBlocks
chainConfig.ExpeditedVotingPeriod = config.PropDepositBlocks + numVal*config.PropVoteBlocks + config.PropBufferBlocks - 1

validatorConfigBytes, err := json.Marshal(chainConfig.ValidatorInitConfigs)
if err != nil {
Expand All @@ -73,7 +74,7 @@ func (uc *UpgradeConfigurer) ConfigureChain(chainConfig *chain.Config) error {
forkHeight = forkHeight - config.ForkHeightPreUpgradeOffset
}

chainInitResource, err := uc.containerManager.RunChainInitResource(chainConfig.Id, int(chainConfig.VotingPeriod), validatorConfigBytes, tmpDir, int(forkHeight))
chainInitResource, err := uc.containerManager.RunChainInitResource(chainConfig.Id, int(chainConfig.VotingPeriod), int(chainConfig.ExpeditedVotingPeriod), validatorConfigBytes, tmpDir, int(forkHeight))
if err != nil {
return err
}
Expand Down Expand Up @@ -154,7 +155,7 @@ func (uc *UpgradeConfigurer) runProposalUpgrade() error {
chainConfig.UpgradePropHeight = currentHeight + int64(chainConfig.VotingPeriod) + int64(config.PropSubmitBlocks) + int64(config.PropBufferBlocks)
node.SubmitUpgradeProposal(uc.upgradeVersion, chainConfig.UpgradePropHeight, sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit)))
chainConfig.LatestProposalNumber += 1
node.DepositProposal(chainConfig.LatestProposalNumber)
node.DepositProposal(chainConfig.LatestProposalNumber, false)
}
node.VoteYesProposal(initialization.ValidatorWalletName, chainConfig.LatestProposalNumber)
}
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/containers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir st
// The genesis and configs are to be mounted on the init container as volume on mountDir path.
// Returns the container resource and error if any. This method does not Purge the container. The caller
// must deal with removing the resource.
func (m *Manager) RunChainInitResource(chainId string, chainVotingPeriod int, validatorConfigBytes []byte, mountDir string, forkHeight int) (*dockertest.Resource, error) {
func (m *Manager) RunChainInitResource(chainId string, chainVotingPeriod, chainExpeditedVotingPeriod int, validatorConfigBytes []byte, mountDir string, forkHeight int) (*dockertest.Resource, error) {
votingPeriodDuration := time.Duration(chainVotingPeriod * 1000000000)
// TODO: Uncomment this after v12 release
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
//expeditedVotingPeriodDuration := time.Duration(chainExpeditedVotingPeriod * 1000000000)

initResource, err := m.pool.RunWithOptions(
&dockertest.RunOptions{
Expand All @@ -226,6 +228,8 @@ func (m *Manager) RunChainInitResource(chainId string, chainVotingPeriod int, va
fmt.Sprintf("--chain-id=%s", chainId),
fmt.Sprintf("--config=%s", validatorConfigBytes),
fmt.Sprintf("--voting-period=%v", votingPeriodDuration),
// TODO: Uncomment this after v12 release
//fmt.Sprintf("--expedited-voting-period=%v", expeditedVotingPeriodDuration),
fmt.Sprintf("--fork-height=%v", forkHeight),
},
User: "root:root",
Expand Down
37 changes: 34 additions & 3 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"strconv"
"sync"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -55,7 +56,7 @@ func (s *IntegrationTestSuite) TestSuperfluidVoting() {
// enable superfluid via proposal.
node.SubmitSuperfluidProposal("gamm/pool/1", sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit)))
chain.LatestProposalNumber += 1
node.DepositProposal(chain.LatestProposalNumber)
node.DepositProposal(chain.LatestProposalNumber, false)
for _, node := range chain.NodeConfigs {
node.VoteYesProposal(initialization.ValidatorWalletName, chain.LatestProposalNumber)
}
Expand All @@ -70,9 +71,9 @@ func (s *IntegrationTestSuite) TestSuperfluidVoting() {
node.SuperfluidDelegate(chain.LatestLockNumber, chain.NodeConfigs[1].OperatorAddress, walletName)

// create a text prop, deposit and vote yes
node.SubmitTextProposal("superfluid vote overwrite test", sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit)))
node.SubmitTextProposal("superfluid vote overwrite test", sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit)), false)
chain.LatestProposalNumber += 1
node.DepositProposal(chain.LatestProposalNumber)
node.DepositProposal(chain.LatestProposalNumber, false)
for _, node := range chain.NodeConfigs {
node.VoteYesProposal(initialization.ValidatorWalletName, chain.LatestProposalNumber)
}
Expand Down Expand Up @@ -211,3 +212,33 @@ func (s *IntegrationTestSuite) TestStateSync() {
err = chain.RemoveNode(stateSynchingNode.Name)
s.NoError(err)
}

func (s *IntegrationTestSuite) TestExpeditedProposals() {
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
if !s.skipUpgrade {
s.T().Skip("this can be re-enabled post v12")
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
}

var wg sync.WaitGroup
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
chain := s.configurer.GetChainConfig(0)
node, err := chain.GetDefaultNode()
s.NoError(err)

node.SubmitTextProposal("expedited text proposal", sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinExpeditedDeposit)), true)
chain.LatestProposalNumber += 1
node.DepositProposal(chain.LatestProposalNumber, true)
wg.Add(1)
totalTime := make(chan time.Duration, 1)
go node.QueryPropStatusTimed(&wg, chain.LatestProposalNumber, "PROPOSAL_STATUS_PASSED", totalTime)
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
for _, node := range chain.NodeConfigs {
node.VoteYesProposal(initialization.ValidatorWalletName, chain.LatestProposalNumber)
}
// wait till prop status reaches desired pass status
wg.Wait()
elapsed := <-totalTime
// compare the time it took to reach pass status to expected expedited voting period
expeditedVotingPeriodDuration := time.Duration(chain.ExpeditedVotingPeriod * 1000000000)
timeDelta := elapsed - expeditedVotingPeriodDuration
// ensure delta is within one second of expected time
s.Require().Less(timeDelta, time.Second)
p0mvn marked this conversation as resolved.
Show resolved Hide resolved
close(totalTime)
}
16 changes: 9 additions & 7 deletions tests/e2e/initialization/chain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ import (

func main() {
var (
valConfig []*initialization.NodeConfig
dataDir string
chainId string
config string
votingPeriod time.Duration
forkHeight int
valConfig []*initialization.NodeConfig
dataDir string
chainId string
config string
votingPeriod time.Duration
expeditedVotingPeriod time.Duration
forkHeight int
)

flag.StringVar(&dataDir, "data-dir", "", "chain data directory")
flag.StringVar(&chainId, "chain-id", "", "chain ID")
flag.StringVar(&config, "config", "", "serialized config")
flag.DurationVar(&votingPeriod, "voting-period", 30000000000, "voting period")
flag.DurationVar(&expeditedVotingPeriod, "expedited-voting-period", 20000000000, "expedited voting period")
flag.IntVar(&forkHeight, "fork-height", 0, "fork height")

flag.Parse()
Expand All @@ -41,7 +43,7 @@ func main() {
panic(err)
}

createdChain, err := initialization.InitChain(chainId, dataDir, valConfig, votingPeriod, forkHeight)
createdChain, err := initialization.InitChain(chainId, dataDir, valConfig, votingPeriod, expeditedVotingPeriod, forkHeight)
if err != nil {
panic(err)
}
Expand Down
13 changes: 7 additions & 6 deletions tests/e2e/initialization/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var (
OsmoToken = sdk.NewInt64Coin(OsmoDenom, IbcSendAmount) // 3,300uosmo
StakeToken = sdk.NewInt64Coin(StakeDenom, IbcSendAmount) // 3,300ustake
tenOsmo = sdk.Coins{sdk.NewInt64Coin(OsmoDenom, 10_000_000)}
fiftyOsmo = sdk.Coins{sdk.NewInt64Coin(OsmoDenom, 50_000_000)}
)

func addAccount(path, moniker, amountStr string, accAddr sdk.AccAddress, forkHeight int) error {
Expand Down Expand Up @@ -166,7 +167,7 @@ func updateModuleGenesis[V proto.Message](appGenState map[string]json.RawMessage
return nil
}

func initGenesis(chain *internalChain, votingPeriod time.Duration, forkHeight int) error {
func initGenesis(chain *internalChain, votingPeriod, expeditedVotingPeriod time.Duration, forkHeight int) error {
// initialize a genesis file
configDir := chain.nodes[0].configDir()
for _, val := range chain.nodes {
Expand Down Expand Up @@ -249,7 +250,7 @@ func initGenesis(chain *internalChain, votingPeriod time.Duration, forkHeight in
return err
}

err = updateModuleGenesis(appGenState, govtypes.ModuleName, &govtypes.GenesisState{}, updateGovGenesis(votingPeriod))
err = updateModuleGenesis(appGenState, govtypes.ModuleName, &govtypes.GenesisState{}, updateGovGenesis(votingPeriod, expeditedVotingPeriod))
if err != nil {
return err
}
Expand Down Expand Up @@ -358,12 +359,12 @@ func updateCrisisGenesis(crisisGenState *crisistypes.GenesisState) {
crisisGenState.ConstantFee.Denom = OsmoDenom
}

func updateGovGenesis(votingPeriod time.Duration) func(*govtypes.GenesisState) {
func updateGovGenesis(votingPeriod, expeditedVotingPeriod time.Duration) func(*govtypes.GenesisState) {
return func(govGenState *govtypes.GenesisState) {
govGenState.VotingParams = govtypes.VotingParams{
VotingPeriod: votingPeriod,
}
govGenState.VotingParams.VotingPeriod = votingPeriod
govGenState.VotingParams.ExpeditedVotingPeriod = expeditedVotingPeriod
govGenState.DepositParams.MinDeposit = tenOsmo
govGenState.DepositParams.MinExpeditedDeposit = fiftyOsmo
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/initialization/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/osmosis-labs/osmosis/v10/tests/e2e/util"
)

func InitChain(id, dataDir string, nodeConfigs []*NodeConfig, votingPeriod time.Duration, forkHeight int) (*Chain, error) {
func InitChain(id, dataDir string, nodeConfigs []*NodeConfig, votingPeriod, expeditedVotingPeriod time.Duration, forkHeight int) (*Chain, error) {
chain, err := new(id, dataDir)
if err != nil {
return nil, err
Expand All @@ -23,7 +23,7 @@ func InitChain(id, dataDir string, nodeConfigs []*NodeConfig, votingPeriod time.
chain.nodes = append(chain.nodes, newNode)
}

if err := initGenesis(chain, votingPeriod, forkHeight); err != nil {
if err := initGenesis(chain, votingPeriod, expeditedVotingPeriod, forkHeight); err != nil {
return nil, err
}

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/initialization/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestChainInit(t *testing.T) {
dataDir, err = os.MkdirTemp("", "osmosis-e2e-testnet-test")
)

chain, err := initialization.InitChain(id, dataDir, nodeConfigs, time.Second*3, forkHeight)
chain, err := initialization.InitChain(id, dataDir, nodeConfigs, time.Second*3, time.Second, forkHeight)
require.NoError(t, err)

require.Equal(t, chain.ChainMeta.DataDir, dataDir)
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestSingleNodeInit(t *testing.T) {
)

// Setup
existingChain, err := initialization.InitChain(id, dataDir, existingChainNodeConfigs, time.Second*3, forkHeight)
existingChain, err := initialization.InitChain(id, dataDir, existingChainNodeConfigs, time.Second*3, time.Second, forkHeight)
require.NoError(t, err)

actualNode, err := initialization.InitSingleNode(existingChain.ChainMeta.Id, dataDir, filepath.Join(existingChain.Nodes[0].ConfigDir, "config", "genesis.json"), expectedConfig, time.Second*3, 3, "testHash", []string{"some server"}, []string{"some server"})
Expand Down
6 changes: 6 additions & 0 deletions x/mint/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ func (suite *KeeperTestSuite) TestSetInitialSupplyOffsetDuringMigration() {
bankKeeper := suite.App.BankKeeper
mintKeeper := suite.App.MintKeeper

// in order to ensure the offset is correctly calculated, we need to mint the supply + 1
// this is because a negative supply offset will always return zero
// by setting this to the supply + 1, we ensure we are correctly calculating the offset by keeping it delta positive
supply := bankKeeper.GetSupply(ctx, sdk.DefaultBondDenom)
mintKeeper.MintCoins(ctx, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, supply.Amount.Add(sdk.NewInt(1)))))
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved

supplyWithOffsetBefore := bankKeeper.GetSupplyWithOffset(ctx, sdk.DefaultBondDenom)
supplyOffsetBefore := bankKeeper.GetSupplyOffset(ctx, sdk.DefaultBondDenom)

Expand Down