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{},
})
// for acc := range maccPerms {
// fmt.Println(acc)
// require.True(
// t,
// app.BankKeeper.BlockedAddr(app.AccountKeeper.GetModuleAddress(acc)),
// fmt.Sprintf("ensure that blocked addresses %s are properly set in bank keeper", acc),
// )
// }
for acc := range allowedReceivingModAcc {
// check module account is not blocked in bank
require.False(
t,
app.BankKeeper.BlockedAddr(app.AccountKeeper.GetModuleAddress(acc)),
"ensure that blocked addresses %s are properly set in bank keeper",
)
}
app.Commit()
logger2, _ := log.NewDefaultLogger("plain", "info", false)
// 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{})
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
nodeDirName := fmt.Sprintf("node%d", i)
nodeDir := filepath.Join(network.BaseDir, nodeDirName, "evmosd")
clientDir := filepath.Join(network.BaseDir, nodeDirName, "evmoscli")
nodeDir := filepath.Join(network.BaseDir, nodeDirName, "chibaclonkd")
clientDir := filepath.Join(network.BaseDir, nodeDirName, "chibaclonkcli")
gentxsDir := filepath.Join(network.BaseDir, "gentxs")
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")
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
// defer in a test would not be called.
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,
// an error is returned. Regardless, the latest height queried is returned.
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
// provide a custom timeout.
func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, error) {
ticker := time.NewTicker(time.Second)
timeout := time.After(t)
defer ticker.Stop()
timeout := time.NewTimer(t)
defer timeout.Stop()
if len(n.Validators) == 0 {
return 0, errors.New("no validators available")
}
var latestHeight int64
val := n.Validators[0]
for {
select {
case <-timeout:
ticker.Stop()
case <-timeout.C:
return latestHeight, errors.New("timeout exceeded waiting for block")
case <-ticker.C:
status, err := val.RPCClient.Status(context.Background())
status, err := n.Validators[0].RPCClient.Status(context.Background())
if err == nil && status != nil {
latestHeight = status.SyncInfo.LatestBlockHeight
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++ {
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")
tmCfg.Moniker = vals[i].Moniker

View File

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