diff --git a/tests/fixture/tmpnet/node_process.go b/tests/fixture/tmpnet/node_process.go index d7d95a697dd..b33fe32f073 100644 --- a/tests/fixture/tmpnet/node_process.go +++ b/tests/fixture/tmpnet/node_process.go @@ -77,14 +77,12 @@ func (p *NodeProcess) setProcessContext(processContext node.NodeProcessContext) func (p *NodeProcess) readState() error { path := p.getProcessContextPath() - if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) { + bytes, err := os.ReadFile(path) + if errors.Is(err, fs.ErrNotExist) { // The absence of the process context file indicates the node is not running p.setProcessContext(node.NodeProcessContext{}) return nil - } - - bytes, err := os.ReadFile(path) - if err != nil { + } else if err != nil { return fmt.Errorf("failed to read node process context: %w", err) } processContext := node.NodeProcessContext{} diff --git a/tests/fixture/tmpnet/subnet.go b/tests/fixture/tmpnet/subnet.go index a9062f2fb5c..1e1d3c749c7 100644 --- a/tests/fixture/tmpnet/subnet.go +++ b/tests/fixture/tmpnet/subnet.go @@ -6,6 +6,7 @@ package tmpnet import ( "context" "encoding/json" + "errors" "fmt" "io" "os" @@ -339,14 +340,10 @@ func WaitForActiveValidators( // Reads subnets from [network dir]/subnets/[subnet name].json func readSubnets(subnetDir string) ([]*Subnet, error) { - if _, err := os.Stat(subnetDir); os.IsNotExist(err) { + entries, err := os.ReadDir(subnetDir) + if errors.Is(err, os.ErrNotExist) { return nil, nil } else if err != nil { - return nil, err - } - - entries, err := os.ReadDir(subnetDir) - if err != nil { return nil, fmt.Errorf("failed to read subnet dir: %w", err) }