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
+16 -9
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 {
+1 -1
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