tvx extract: --ignore-sanity-checks flag.

This commit is contained in:
Raúl Kripalani 2020-10-23 10:46:56 +01:00
parent 92395745d3
commit 5301c416bc

View File

@ -40,6 +40,7 @@ type extractOpts struct {
file string
retain string
precursor string
ignoreSanityChecks bool
}
var extractFlags extractOpts
@ -95,10 +96,16 @@ var extractCmd = &cli.Command{
Value: "sender",
Destination: &extractFlags.precursor,
},
&cli.BoolFlag{
Name: "ignore-sanity-checks",
Usage: "generate vector even if sanity checks fail",
Value: false,
Destination: &extractFlags.ignoreSanityChecks,
},
},
}
func runExtract(c *cli.Context) error {
func runExtract(_ *cli.Context) error {
return doExtract(extractFlags)
}
@ -282,13 +289,20 @@ func doExtract(opts extractOpts) error {
ReturnValue: rec.Return,
GasUsed: rec.GasUsed,
}
reporter := new(conformance.LogReporter)
conformance.AssertMsgResult(reporter, receipt, applyret, "as locally executed")
if reporter.Failed() {
if opts.ignoreSanityChecks {
log.Println(color.YellowString("receipt sanity check failed; proceeding anyway"))
} else {
log.Println(color.RedString("receipt sanity check failed; aborting"))
return fmt.Errorf("vector generation aborted")
}
} else {
log.Println(color.GreenString("receipt sanity check succeeded"))
}
} else {
receipt = &schema.Receipt{
ExitCode: int64(applyret.ExitCode),