Merge pull request #1672 from filecoin-project/feat/bisect-errors

Some chain-bisect improvements / fixes
This commit is contained in:
Łukasz Magiera 2020-05-08 22:14:19 +02:00 committed by GitHub
commit 85dc2eb36f

View File

@ -692,7 +692,7 @@ var chainBisectCmd = &cli.Command{
highest, err := api.ChainGetTipSetByHeight(ctx, abi.ChainEpoch(end), types.EmptyTSK) highest, err := api.ChainGetTipSetByHeight(ctx, abi.ChainEpoch(end), types.EmptyTSK)
if err != nil { if err != nil {
return err return xerrors.Errorf("getting end tipset: %w", err)
} }
prev := highest.Height() prev := highest.Height()
@ -717,7 +717,7 @@ var chainBisectCmd = &cli.Command{
return err return err
} }
b, err := json.MarshalIndent(nd, "", "\t") b, err := json.MarshalIndent(nd.Obj, "", "\t")
if err != nil { if err != nil {
return err return err
} }
@ -726,15 +726,32 @@ var chainBisectCmd = &cli.Command{
cmd.Stdin = bytes.NewReader(b) cmd.Stdin = bytes.NewReader(b)
var out bytes.Buffer var out bytes.Buffer
var serr bytes.Buffer
cmd.Stdout = &out cmd.Stdout = &out
cmd.Stderr = &serr
switch cmd.Run().(type) { switch cmd.Run().(type) {
case nil: case nil:
// it's lower // it's lower
if strings.TrimSpace(out.String()) != "false" {
end = mid end = mid
highest = midTs highest = midTs
fmt.Println("true") fmt.Println("true")
} else {
start = mid
fmt.Printf("false (cli)\n")
}
case *exec.ExitError: case *exec.ExitError:
if len(serr.String()) > 0 {
fmt.Println("error")
fmt.Printf("> Command: %s\n---->\n", strings.Join(cctx.Args().Slice()[3:], " "))
fmt.Println(string(b))
fmt.Println("<----")
return xerrors.Errorf("error running bisect check: %s", serr.String())
}
start = mid start = mid
fmt.Println("false") fmt.Println("false")
default: default: