WIP: fixing the test cases

This commit is contained in:
Sai Kumar 2022-04-26 19:02:26 +05:30
parent e6d416db7f
commit 8ae41eb7cc
4 changed files with 29 additions and 19 deletions

View File

@ -25,19 +25,21 @@ func TestEthermintAppExport(t *testing.T) {
AppOpts: EmptyAppOptions{}, AppOpts: EmptyAppOptions{},
}) })
// for acc := range maccPerms { for acc := range allowedReceivingModAcc {
// fmt.Println(acc) // check module account is not blocked in bank
// require.True( require.False(
// t, t,
// app.BankKeeper.BlockedAddr(app.AccountKeeper.GetModuleAddress(acc)), app.BankKeeper.BlockedAddr(app.AccountKeeper.GetModuleAddress(acc)),
// fmt.Sprintf("ensure that blocked addresses %s are properly set in bank keeper", acc), "ensure that blocked addresses %s are properly set in bank keeper",
// ) )
// } }
app.Commit() app.Commit()
logger2, _ := log.NewDefaultLogger("plain", "info", false)
// Making a new app object with the db, so that initchain hasn't been called // Making a new app object with the db, so that initchain hasn't been called
app2 := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{}) app2 := NewEthermintApp(logger2, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{})
require.NoError(t, app2.Init())
_, err := app2.ExportAppStateAndValidators(false, []string{}) _, err := app2.ExportAppStateAndValidators(false, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error") require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
} }

View File

@ -330,8 +330,8 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
ctx.Logger = logger ctx.Logger = logger
nodeDirName := fmt.Sprintf("node%d", i) nodeDirName := fmt.Sprintf("node%d", i)
nodeDir := filepath.Join(network.BaseDir, nodeDirName, "evmosd") nodeDir := filepath.Join(network.BaseDir, nodeDirName, "chibaclonkd")
clientDir := filepath.Join(network.BaseDir, nodeDirName, "evmoscli") clientDir := filepath.Join(network.BaseDir, nodeDirName, "chibaclonkcli")
gentxsDir := filepath.Join(network.BaseDir, "gentxs") gentxsDir := filepath.Join(network.BaseDir, "gentxs")
err := os.MkdirAll(filepath.Join(nodeDir, "config"), 0o750) err := os.MkdirAll(filepath.Join(nodeDir, "config"), 0o750)
@ -526,6 +526,13 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
l.Log("started test network") l.Log("started test network")
height, err := network.LatestHeight()
if err != nil {
return nil, err
}
l.Log("started test network at height:", height)
// Ensure we cleanup incase any test was abruptly halted (e.g. SIGINT) as any // Ensure we cleanup incase any test was abruptly halted (e.g. SIGINT) as any
// defer in a test would not be called. // defer in a test would not be called.
server.TrapSignal(network.Cleanup) server.TrapSignal(network.Cleanup)
@ -552,29 +559,29 @@ func (n *Network) LatestHeight() (int64, error) {
// committed after a given block. If that height is not reached within a timeout, // committed after a given block. If that height is not reached within a timeout,
// an error is returned. Regardless, the latest height queried is returned. // an error is returned. Regardless, the latest height queried is returned.
func (n *Network) WaitForHeight(h int64) (int64, error) { func (n *Network) WaitForHeight(h int64) (int64, error) {
return n.WaitForHeightWithTimeout(h, 10*time.Second) return n.WaitForHeightWithTimeout(h, 100*time.Second)
} }
// WaitForHeightWithTimeout is the same as WaitForHeight except the caller can // WaitForHeightWithTimeout is the same as WaitForHeight except the caller can
// provide a custom timeout. // provide a custom timeout.
func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, error) { func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, error) {
ticker := time.NewTicker(time.Second) ticker := time.NewTicker(time.Second)
timeout := time.After(t) defer ticker.Stop()
timeout := time.NewTimer(t)
defer timeout.Stop()
if len(n.Validators) == 0 { if len(n.Validators) == 0 {
return 0, errors.New("no validators available") return 0, errors.New("no validators available")
} }
var latestHeight int64 var latestHeight int64
val := n.Validators[0]
for { for {
select { select {
case <-timeout: case <-timeout.C:
ticker.Stop()
return latestHeight, errors.New("timeout exceeded waiting for block") return latestHeight, errors.New("timeout exceeded waiting for block")
case <-ticker.C: case <-ticker.C:
status, err := val.RPCClient.Status(context.Background()) status, err := n.Validators[0].RPCClient.Status(context.Background())
if err == nil && status != nil { if err == nil && status != nil {
latestHeight = status.SyncInfo.LatestBlockHeight latestHeight = status.SyncInfo.LatestBlockHeight
if latestHeight >= h { if latestHeight >= h {

View File

@ -150,7 +150,7 @@ func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error {
for i := 0; i < cfg.NumValidators; i++ { for i := 0; i < cfg.NumValidators; i++ {
tmCfg := vals[i].Ctx.Config tmCfg := vals[i].Ctx.Config
nodeDir := filepath.Join(outputDir, vals[i].Moniker, "evmosd") nodeDir := filepath.Join(outputDir, vals[i].Moniker, "chibaclonkd")
gentxsDir := filepath.Join(outputDir, "gentxs") gentxsDir := filepath.Join(outputDir, "gentxs")
tmCfg.Moniker = vals[i].Moniker tmCfg.Moniker = vals[i].Moniker

View File

@ -36,6 +36,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite") s.T().Log("setting up integration test suite")
var err error var err error
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg) s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err) s.Require().NoError(err)