Skip to content

Commit

Permalink
tests: qa running with docker network (#2105)
Browse files Browse the repository at this point in the history
* cosmwasm qa running with docker live network

* remove ths env variable check in e2e test suite setup
  • Loading branch information
gsk967 committed Jun 26, 2023
1 parent f899adf commit 8505c7f
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 94 deletions.
3 changes: 2 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ type Client struct {
// Accounts are generated using the list of mnemonics. Each string must be a sequence of words,
// eg: `["w11 w12 w13", "w21 w22 w23"]`. Keyring names for created accounts will be: val1, val2....
func NewClient(
chainDataDir,
chainID,
tmrpcEndpoint,
grpcEndpoint string,
mnemonics map[string]string,
gasAdjustment float64,
encCfg sdkparams.EncodingConfig,
) (Client, error) {
c, err := sdkclient.NewClient(chainID, tmrpcEndpoint, grpcEndpoint, mnemonics, gasAdjustment, encCfg)
c, err := sdkclient.NewClient(chainDataDir, chainID, tmrpcEndpoint, grpcEndpoint, mnemonics, gasAdjustment, encCfg)
if err != nil {
return Client{}, err
}
Expand Down
3 changes: 2 additions & 1 deletion sdkclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Client struct {
}

func NewClient(
chainDataDir,
chainID,
tmrpcEndpoint,
grpcEndpoint string,
Expand All @@ -35,7 +36,7 @@ func NewClient(
if err != nil {
return Client{}, err
}
uc.Tx, err = tx.NewClient(chainID, tmrpcEndpoint, mnemonics, gasAdjustment, encCfg)
uc.Tx, err = tx.NewClient(chainDataDir, chainID, tmrpcEndpoint, mnemonics, gasAdjustment, encCfg)
return uc, err
}

Expand Down
7 changes: 4 additions & 3 deletions sdkclient/tx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ type Client struct {
}

// Initializes a cosmos sdk client context and transaction factory for
// signing and broadcasting transactions
// signing and broadcasting transactions by passing chainDataDir and remaining func arguments
// Note: For signing the transactions accounts are created by names like this val0, val1....
func NewClient(
chainID string,
chainDataDir,
chainID,
tmrpcEndpoint string,
mnemonics map[string]string,
gasAdjustment float64,
Expand All @@ -45,7 +46,7 @@ func NewClient(
encCfg: encCfg,
}

c.keyringKeyring, err = keyring.New(keyringAppName, keyring.BackendTest, "", nil, encCfg.Codec)
c.keyringKeyring, err = keyring.New(keyringAppName, keyring.BackendTest, chainDataDir, nil, encCfg.Codec)
if err != nil {
return nil, err
}
Expand Down
22 changes: 15 additions & 7 deletions tests/e2e/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type E2ETestSuite struct {
GravityContractAddr string
Umee client.Client
cdc codec.Codec
MinNetwork bool // MinNetwork defines which runs only validator wihtout price-feeder, gaia and ibc-relayer

}

func (s *E2ETestSuite) SetupSuite() {
Expand Down Expand Up @@ -110,9 +112,13 @@ func (s *E2ETestSuite) SetupSuite() {
s.initGenesis()
s.initValidatorConfigs()
s.runValidators()
s.runPriceFeeder()
s.runGaiaNetwork()
s.runIBCRelayer()
if !s.MinNetwork {
s.runPriceFeeder()
s.runGaiaNetwork()
s.runIBCRelayer()
} else {
s.T().Log("running minimum network withut gaia,price-feeder and ibc-relayer")
}
// s.runContractDeployment()
// s.runOrchestrators()
s.initUmeeClient()
Expand All @@ -131,9 +137,11 @@ func (s *E2ETestSuite) TearDownSuite() {
s.T().Log("tearing down e2e integration test suite...")

// s.Require().NoError(s.DkrPool.Purge(s.ethResource))
s.Require().NoError(s.DkrPool.Purge(s.GaiaResource))
s.Require().NoError(s.DkrPool.Purge(s.HermesResource))
s.Require().NoError(s.DkrPool.Purge(s.priceFeederResource))
if !s.MinNetwork {
s.Require().NoError(s.DkrPool.Purge(s.GaiaResource))
s.Require().NoError(s.DkrPool.Purge(s.HermesResource))
s.Require().NoError(s.DkrPool.Purge(s.priceFeederResource))
}

for _, vc := range s.ValResources {
s.Require().NoError(s.DkrPool.Purge(vc))
Expand Down Expand Up @@ -1062,8 +1070,8 @@ func (s *E2ETestSuite) initUmeeClient() {
mnemonics[fmt.Sprintf("val%d", index)] = v.mnemonic
}
ecfg := app.MakeEncodingConfig()

s.Umee, err = client.NewClient(
s.Chain.dataDir,
s.Chain.ID,
"tcp://localhost:26657",
"tcp://localhost:9090",
Expand Down
13 changes: 0 additions & 13 deletions tests/qa/cw/config_example.yaml

This file was deleted.

34 changes: 13 additions & 21 deletions tests/qa/cw/cw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ package cw
import (
"encoding/json"
"math/rand"
"os"
"strings"
"sync"
"testing"
"time"

"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdkparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"
"gotest.tools/v3/assert"

"github.com/umee-network/umee/v5/app"
"github.com/umee-network/umee/v5/client"
cwutil "github.com/umee-network/umee/v5/tests/util"
)

Expand All @@ -33,28 +30,27 @@ var (
cwGroupMsgExecFunc func(name string, msg GroupExecMsg, wg *sync.WaitGroup, accSeq uint64)
)

func TestCWPlusGroup(t *testing.T) {
func TestQA(t *testing.T) {
t.Log("Running qa test...")
qaTest := new(QATest)
qaTest.MinNetwork = true
suite.Run(t, qaTest)
}

func (qaTest *QATest) TestCWPlusGroup() {
t := qaTest.T()
accAddrs := make([]sdk.AccAddress, 0)
for i := 0; i < TotalAccs; i++ {
privateKey := secp256k1.GenPrivKey()
pubKey := privateKey.PubKey()
accAddrs = append(accAddrs, sdk.AccAddress(pubKey.Address()))
}

// remove if old keyring exists for testing
os.RemoveAll("./keyring-test")
encConfig := app.MakeEncodingConfig()
cc, err := ReadConfig("./config_example.yaml")
assert.NilError(t, err)
// umee client
client, err := UmeeClient(cc, encConfig)
assert.NilError(t, err)

cw := cwutil.NewCosmwasmTestSuite(t, client)
cw := cwutil.NewCosmwasmTestSuite(qaTest.T(), qaTest.Umee)
cw.DeployWasmContract(cwGroupPath)

// sender is intital account
admin := client.Tx.SenderAddr()
admin := qaTest.Umee.Tx.SenderAddr()
// instantiate Contract
initMsg := GroupInitMsg{
Admin: admin.String(),
Expand Down Expand Up @@ -89,7 +85,7 @@ func TestCWPlusGroup(t *testing.T) {

// doing random txs to flood the cosmwasm network
wg := &sync.WaitGroup{}
accSeq, err := client.QueryAuthSeq(admin.String())
accSeq, err := qaTest.Umee.QueryAuthSeq(admin.String())
assert.NilError(t, err)
total := 0

Expand Down Expand Up @@ -160,7 +156,3 @@ func TestCWPlusGroup(t *testing.T) {
assert.NilError(t, err)
assert.Equal(t, updateAdmin.UpdateAdmin.Admin, adminQuery.Admin)
}

func UmeeClient(cc *ChainConfig, encConfig sdkparams.EncodingConfig) (client.Client, error) {
return client.NewClient(cc.ChainID, cc.RPC, cc.GRPC, cc.Mnemonics, 1.5, encConfig)
}
19 changes: 0 additions & 19 deletions tests/qa/cw/cw_utils.go

This file was deleted.

29 changes: 0 additions & 29 deletions tests/qa/cw/network_config.go

This file was deleted.

9 changes: 9 additions & 0 deletions tests/qa/cw/setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cw

import (
"github.com/umee-network/umee/v5/tests/e2e/setup"
)

type QATest struct {
setup.E2ETestSuite
}

0 comments on commit 8505c7f

Please sign in to comment.