Skip to content

Commit

Permalink
chore[e2e]: parse from result (#5965)
Browse files Browse the repository at this point in the history
* parse from result e2e

* no err check for os.Remove

* default node

* more logging

* fix

* add mutex for IBC sends

* clean up

* add node level mutex

* add wallet address across all validators

* use any available node (chainA or chainB)

* properly release nodes

* mutex for addr rather than entire chain

* faster epoch

* remove use of public address

* potential revert, remove node mutex

* full remove node level mutex
  • Loading branch information
czarcas7ic authored Aug 7, 2023
1 parent f94e6e1 commit 03d558b
Show file tree
Hide file tree
Showing 9 changed files with 618 additions and 448 deletions.
35 changes: 17 additions & 18 deletions tests/e2e/configurer/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ type Config struct {
VotingPeriod float32
ExpeditedVotingPeriod float32
// upgrade proposal height for chain.
UpgradePropHeight int64
LatestProposalNumber int
LatestLockNumber int
NodeConfigs []*NodeConfig
NodeTempConfigs []*NodeConfig
UpgradePropHeight int64

NodeConfigs []*NodeConfig
NodeTempConfigs []*NodeConfig

LatestCodeId int

Expand Down Expand Up @@ -227,6 +226,12 @@ func (c *Config) SendIBC(dstChain *Config, recipient string, token sdk.Coin) {
c.t.Log("successfully sent IBC tokens")
}

func (c *Config) GetAllChainNodes() []*NodeConfig {
nodeConfigs := make([]*NodeConfig, len(c.NodeConfigs))
copy(nodeConfigs, c.NodeConfigs)
return nodeConfigs
}

// GetDefaultNode returns the default node of the chain.
// The default node is the first one created. Returns error if no
// ndoes created.
Expand All @@ -251,21 +256,15 @@ func (c *Config) GetNodeAtIndex(nodeIndex int) (*NodeConfig, error) {

func (c *Config) getNodeAtIndex(nodeIndex int) (*NodeConfig, error) {
if nodeIndex > len(c.NodeConfigs) {
return nil, fmt.Errorf("node index (%d) is greter than the number of nodes available (%d)", nodeIndex, len(c.NodeConfigs))
return nil, fmt.Errorf("node index (%d) is greater than the number of nodes available (%d)", nodeIndex, len(c.NodeConfigs))
}
return c.NodeConfigs[nodeIndex], nil
}

func (c *Config) SubmitCreateConcentratedPoolProposal() (uint64, error) {
node, err := c.GetDefaultNode()
if err != nil {
return 0, err
}

propNumber := node.SubmitCreateConcentratedPoolProposal(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit)))
c.LatestProposalNumber += 1
func (c *Config) SubmitCreateConcentratedPoolProposal(chainANode *NodeConfig) (uint64, error) {
propNumber := chainANode.SubmitCreateConcentratedPoolProposal(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit)))

node.DepositProposal(propNumber, false)
chainANode.DepositProposal(propNumber, false)

var wg sync.WaitGroup

Expand All @@ -280,12 +279,12 @@ func (c *Config) SubmitCreateConcentratedPoolProposal() (uint64, error) {
wg.Wait()

require.Eventually(c.t, func() bool {
status, err := node.QueryPropStatus(propNumber)
status, err := chainANode.QueryPropStatus(propNumber)
if err != nil {
return false
}
return status == proposalStatusPassed
}, time.Second*30, time.Millisecond*500)
poolId := node.QueryNumPools()
}, time.Second*30, 10*time.Millisecond)
poolId := chainANode.QueryNumPools()
return poolId, nil
}
338 changes: 197 additions & 141 deletions tests/e2e/configurer/chain/commands.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions tests/e2e/configurer/chain/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,18 @@ func (n *NodeConfig) QueryBalances(address string) (sdk.Coins, error) {
return balancesResp.GetBalances(), nil
}

func (n *NodeConfig) QueryBalance(address, denom string) (sdk.Coin, error) {
path := fmt.Sprintf("cosmos/bank/v1beta1/balances/%s/by_denom?denom=%s", address, denom)
bz, err := n.QueryGRPCGateway(path)
require.NoError(n.t, err)

var balancesResp banktypes.QueryBalanceResponse
if err := util.Cdc.UnmarshalJSON(bz, &balancesResp); err != nil {
return sdk.Coin{}, err
}
return *balancesResp.GetBalance(), nil
}

func (n *NodeConfig) QuerySupplyOf(denom string) (sdk.Int, error) {
path := fmt.Sprintf("cosmos/bank/v1beta1/supply/%s", denom)
bz, err := n.QueryGRPCGateway(path)
Expand Down
12 changes: 6 additions & 6 deletions tests/e2e/configurer/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ var (
DaiOsmoPoolIdv16 uint64
// A pool created via CLI before starting an
// upgrade.
PreUpgradePoolId uint64
PreUpgradePoolId = []uint64{}

PreUpgradeStableSwapPoolId uint64
PreUpgradeStableSwapPoolId = []uint64{}

StrideMigrateWallet = "stride-migration"
StrideMigrateWallet = []string{"stride-migration", "stride-migration"}

LockupWallet = "lockup-wallet"
LockupWallet = []string{"lockup-wallet", "lockup-wallet"}

LockupWalletSuperfluid = "lockup-wallet-superfluid"
LockupWalletSuperfluid = []string{"lockup-wallet-superfluid", "lockup-wallet-superfluid"}

StableswapWallet = "stableswap-wallet"
StableswapWallet = []string{"stableswap-wallet", "stableswap-wallet"}
)
123 changes: 85 additions & 38 deletions tests/e2e/configurer/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {

go func() {
defer wg.Done()
chainA.SendIBC(chainB, chainB.NodeConfigs[0].PublicAddress, initialization.OsmoToken)
chainA.SendIBC(chainB, chainB.NodeConfigs[0].PublicAddress, initialization.StakeToken)
chainA.SendIBC(chainB, chainBNode.PublicAddress, initialization.OsmoToken)
chainA.SendIBC(chainB, chainBNode.PublicAddress, initialization.StakeToken)
}()

go func() {
defer wg.Done()
chainB.SendIBC(chainA, chainA.NodeConfigs[0].PublicAddress, initialization.OsmoToken)
chainB.SendIBC(chainA, chainA.NodeConfigs[0].PublicAddress, initialization.StakeToken)
chainB.SendIBC(chainA, chainANode.PublicAddress, initialization.OsmoToken)
chainB.SendIBC(chainA, chainANode.PublicAddress, initialization.StakeToken)
}()

// Wait for all goroutines to complete
Expand All @@ -145,19 +145,23 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {

wg.Add(4)

// Chain A

go func() {
defer wg.Done()
chainANode.FundCommunityPool(initialization.ValidatorWalletName, strAllUpgradeBaseDenoms())
}()

go func() {
defer wg.Done()
chainBNode.FundCommunityPool(initialization.ValidatorWalletName, strAllUpgradeBaseDenoms())
chainANode.EnableSuperfluidAsset(chainA, v17SuperfluidAssets)
}()

// Chain B

go func() {
defer wg.Done()
chainANode.EnableSuperfluidAsset(chainA, v17SuperfluidAssets)
chainBNode.FundCommunityPool(initialization.ValidatorWalletName, strAllUpgradeBaseDenoms())
}()

go func() {
Expand All @@ -170,34 +174,40 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {
// END: CAN REMOVE POST v17 UPGRADE

var (
poolShareDenom string
preUpgradePoolId uint64
preUpgradeStableSwapPoolId uint64
poolShareDenom = make([]string, 2)
preUpgradePoolId = make([]uint64, 2)
preUpgradeStableSwapPoolId = make([]uint64, 2)
)

// Increment the WaitGroup counter for each goroutine
wg.Add(4)

// Chain A

go func() {
defer wg.Done()
preUpgradePoolId = chainANode.CreateBalancerPool("pool1A.json", initialization.ValidatorWalletName)
poolShareDenom = fmt.Sprintf("gamm/pool/%d", preUpgradePoolId)
chainANode.EnableSuperfluidAsset(chainA, poolShareDenom)
preUpgradePoolId[0] = chainANode.CreateBalancerPool("pool1A.json", initialization.ValidatorWalletName)
poolShareDenom[0] = fmt.Sprintf("gamm/pool/%d", preUpgradePoolId[0])
chainANode.EnableSuperfluidAsset(chainA, poolShareDenom[0])
}()

go func() {
defer wg.Done()
chainBNode.CreateBalancerPool("pool1B.json", initialization.ValidatorWalletName)
preUpgradeStableSwapPoolId[0] = chainANode.CreateStableswapPool("stablePool.json", initialization.ValidatorWalletName)
}()

// Chain B

go func() {
defer wg.Done()
preUpgradeStableSwapPoolId = chainANode.CreateStableswapPool("stablePool.json", initialization.ValidatorWalletName)
preUpgradePoolId[1] = chainBNode.CreateBalancerPool("pool1B.json", initialization.ValidatorWalletName)
poolShareDenom[1] = fmt.Sprintf("gamm/pool/%d", preUpgradePoolId[1])
chainBNode.EnableSuperfluidAsset(chainB, poolShareDenom[1])
}()

go func() {
defer wg.Done()
chainBNode.CreateStableswapPool("stablePool.json", initialization.ValidatorWalletName)
preUpgradeStableSwapPoolId[1] = chainBNode.CreateStableswapPool("stablePool.json", initialization.ValidatorWalletName)
}()

// Wait for all goroutines to complete
Expand All @@ -207,60 +217,98 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {
config.PreUpgradeStableSwapPoolId = preUpgradeStableSwapPoolId

var (
lockupWallet string
lockupWalletSuperfluid string
stableswapWallet string
lockupWallet = make([]string, 2)
lockupWalletSuperfluid = make([]string, 2)
stableswapWallet = make([]string, 2)
)

wg.Add(3)
wg.Add(6)

// Chain A
go func() {
defer wg.Done()
// Setup wallets and send tokens to wallets (only chainA)
lockupWallet = chainANode.CreateWalletAndFund(config.LockupWallet, []string{
"10000000000000000000" + poolShareDenom,
})
lockupWallet[0] = chainANode.CreateWalletAndFund(config.LockupWallet[0], []string{
"10000000000000000000" + poolShareDenom[0],
}, chainA)
}()

go func() {
defer wg.Done()
lockupWalletSuperfluid = chainANode.CreateWalletAndFund(config.LockupWalletSuperfluid, []string{
"10000000000000000000" + poolShareDenom,
})
lockupWalletSuperfluid[0] = chainANode.CreateWalletAndFund(config.LockupWalletSuperfluid[0], []string{
"10000000000000000000" + poolShareDenom[0],
}, chainA)
}()

go func() {
defer wg.Done()
stableswapWallet = chainANode.CreateWalletAndFund(config.StableswapWallet, []string{
stableswapWallet[0] = chainANode.CreateWalletAndFund(config.StableswapWallet[0], []string{
"100000stake",
})
}, chainA)
}()

// Chain B
go func() {
defer wg.Done()
// Setup wallets and send tokens to wallets (only chainA)
lockupWallet[1] = chainBNode.CreateWalletAndFund(config.LockupWallet[1], []string{
"10000000000000000000" + poolShareDenom[1],
}, chainB)
}()

go func() {
defer wg.Done()
lockupWalletSuperfluid[1] = chainBNode.CreateWalletAndFund(config.LockupWalletSuperfluid[1], []string{
"10000000000000000000" + poolShareDenom[1],
}, chainB)
}()

go func() {
defer wg.Done()
stableswapWallet[1] = chainBNode.CreateWalletAndFund(config.StableswapWallet[1], []string{
"100000stake",
}, chainB)
}()

// Wait for all goroutines to complete
wg.Wait()

config.LockupWallet = lockupWallet
config.LockupWalletSuperfluid = lockupWalletSuperfluid
config.StableswapWallet = stableswapWallet

wg.Add(4)
wg.Add(6)

var errCh = make(chan error, 2)

// Chain A

go func() {
defer wg.Done()
// test swap exact amount in for stable swap pool (only chainA)A
chainANode.SwapExactAmountIn("2000stake", "1", fmt.Sprintf("%d", config.PreUpgradeStableSwapPoolId), "uosmo", config.StableswapWallet)
// test swap exact amount in for stable swap pool
chainANode.SwapExactAmountIn("2000stake", "1", fmt.Sprintf("%d", config.PreUpgradeStableSwapPoolId[0]), "uosmo", config.StableswapWallet[0])
}()

// Upload the rate limiting contract to both chains (as they both will be updated)
go func() {
defer wg.Done()
uc.t.Logf("Uploading rate limiting contract to chainA")
_, err := chainANode.SetupRateLimiting("", chainANode.QueryGovModuleAccount(), chainA)
errCh <- err
}()

go func() {
defer wg.Done()
uc.t.Logf("Lock and add to existing lock for both regular and superfluid lockups on chainA")
chainANode.LockAndAddToExistingLock(chainA, sdk.NewInt(1000000000000000000), poolShareDenom[0], config.LockupWallet[0], config.LockupWalletSuperfluid[0])
}()

// Chain B

go func() {
defer wg.Done()
// test swap exact amount in for stable swap pool
chainBNode.SwapExactAmountIn("2000stake", "1", fmt.Sprintf("%d", config.PreUpgradeStableSwapPoolId[1]), "uosmo", config.StableswapWallet[1])
}()

go func() {
defer wg.Done()
uc.t.Logf("Uploading rate limiting contract to chainB")
Expand All @@ -270,8 +318,8 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {

go func() {
defer wg.Done()
uc.t.Logf("Lock and add to existing lock for both regular and superfluid lockups on chainA")
chainANode.LockAndAddToExistingLock(chainA, sdk.NewInt(1000000000000000000), poolShareDenom, config.LockupWallet, config.LockupWalletSuperfluid)
uc.t.Logf("Lock and add to existing lock for both regular and superfluid lockups on chainB")
chainBNode.LockAndAddToExistingLock(chainB, sdk.NewInt(1000000000000000000), poolShareDenom[1], config.LockupWallet[1], config.LockupWalletSuperfluid[1])
}()

wg.Wait()
Expand Down Expand Up @@ -332,10 +380,9 @@ func (uc *UpgradeConfigurer) runProposalUpgrade() error {
return err
}
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, false)
propNumber := chainConfig.LatestProposalNumber
propNumber := node.SubmitUpgradeProposal(uc.upgradeVersion, chainConfig.UpgradePropHeight, sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit)))

node.DepositProposal(propNumber, false)

var wg sync.WaitGroup

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/containers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const (
// It should be uploaded to Docker Hub. OSMOSIS_E2E_SKIP_UPGRADE should be unset
// for this functionality to be used.
previousVersionOsmoRepository = "osmolabs/osmosis-dev"
previousVersionOsmoTag = "16.0"
previousVersionOsmoTag = "16.0-alpine"
// Pre-upgrade repo/tag for osmosis initialization (this should be one version below upgradeVersion)
previousVersionInitRepository = "osmolabs/osmosis-e2e-init-chain"
previousVersionInitTag = "v16.x-f34d07f8-1690568248"
previousVersionInitTag = "v16-faster-epoch"
// Hermes repo/version for relayer
relayerRepository = "informalsystems/hermes"
relayerTag = "1.5.1"
Expand Down
Loading

0 comments on commit 03d558b

Please sign in to comment.