Skip to content

Commit

Permalink
address Roman review
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Aug 12, 2022
1 parent faf72b1 commit 5eecad5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 30 deletions.
11 changes: 8 additions & 3 deletions tests/e2e/configurer/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/stretchr/testify/require"
coretypes "github.com/tendermint/tendermint/rpc/core/types"

"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 @@ -41,13 +43,16 @@ const (
)

func New(t *testing.T, containerManager *containers.Manager, id string, initValidatorConfigs []*initialization.NodeConfig) *Config {
numVal := float32(len(initValidatorConfigs))
return &Config{
ChainMeta: initialization.ChainMeta{
Id: id,
},
ValidatorInitConfigs: initValidatorConfigs,
t: t,
containerManager: containerManager,
ValidatorInitConfigs: initValidatorConfigs,
VotingPeriod: config.PropDepositBlocks + numVal*config.PropVoteBlocks + config.PropBufferBlocks,
ExpeditedVotingPeriod: config.PropDepositBlocks + numVal*config.PropVoteBlocks + config.PropBufferBlocks - 1,
t: t,
containerManager: containerManager,
}
}

Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"regexp"
"strconv"
"strings"
"sync"
"time"

appparams "github.com/osmosis-labs/osmosis/v10/app/params"
Expand Down Expand Up @@ -115,8 +114,7 @@ func (n *NodeConfig) CreateWallet(walletName string) string {
return walletAddr
}

func (n *NodeConfig) QueryPropStatusTimed(wg *sync.WaitGroup, proposalNumber int, desiredStatus string, totalTime chan time.Duration) {
defer wg.Done()
func (n *NodeConfig) QueryPropStatusTimed(proposalNumber int, desiredStatus string, totalTime chan time.Duration) {
start := time.Now()
require.Eventually(
n.t,
Expand Down
11 changes: 1 addition & 10 deletions tests/e2e/configurer/current.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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 @@ -46,15 +45,7 @@ func (cb *CurrentBranchConfigurer) ConfigureChain(chainConfig *chain.Config) err
}
cb.t.Logf("temp directory for chain-id %v: %v", chainConfig.Id, tmpDir)

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

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

votingPeriodDuration := time.Duration(chainConfig.VotingPeriod * 1000000000)
expeditedVotingPeriodDuration := time.Duration(chainConfig.ExpeditedVotingPeriod * 1000000000)

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

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 {
return err
Expand Down
14 changes: 6 additions & 8 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"path/filepath"
"strconv"
"sync"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -159,6 +158,7 @@ func (s *IntegrationTestSuite) TestStateSync() {
filepath.Join(runningNode.ConfigDir, "config", "genesis.json"),
stateSynchingNodeConfig,
time.Duration(chain.VotingPeriod),
//time.Duration(chain.ExpeditedVotingPeriod),
trustHeight,
trustHash,
stateSyncRPCServers,
Expand Down Expand Up @@ -218,27 +218,25 @@ func (s *IntegrationTestSuite) TestExpeditedProposals() {
s.T().Skip("this can be re-enabled post v12")
}

var wg sync.WaitGroup
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)
totalTimeChan := make(chan time.Duration, 1)
go node.QueryPropStatusTimed(chain.LatestProposalNumber, "PROPOSAL_STATUS_PASSED", totalTimeChan)
for _, node := range chain.NodeConfigs {
node.VoteYesProposal(initialization.ValidatorWalletName, chain.LatestProposalNumber)
}
// wait till prop status reaches desired pass status
wg.Wait()
elapsed := <-totalTime
elapsed := <-totalTimeChan
// 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)
close(totalTime)
s.T().Logf("expeditedVotingPeriodDuration within one second of expected time: %v", timeDelta)
close(totalTimeChan)
}
3 changes: 1 addition & 2 deletions x/mint/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ func (suite *KeeperTestSuite) TestSetInitialSupplyOffsetDuringMigration() {
// 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)))))
mintKeeper.MintCoins(ctx, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(keeper.DeveloperVestingAmount+1))))

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

0 comments on commit 5eecad5

Please sign in to comment.