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

@ -33,13 +33,14 @@ const (
) )
type extractOpts struct { type extractOpts struct {
id string id string
block string block string
class string class string
cid string cid string
file string file string
retain string retain string
precursor string precursor string
ignoreSanityChecks bool
} }
var extractFlags extractOpts var extractFlags extractOpts
@ -95,10 +96,16 @@ var extractCmd = &cli.Command{
Value: "sender", Value: "sender",
Destination: &extractFlags.precursor, 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) return doExtract(extractFlags)
} }
@ -282,13 +289,20 @@ func doExtract(opts extractOpts) error {
ReturnValue: rec.Return, ReturnValue: rec.Return,
GasUsed: rec.GasUsed, GasUsed: rec.GasUsed,
} }
reporter := new(conformance.LogReporter) reporter := new(conformance.LogReporter)
conformance.AssertMsgResult(reporter, receipt, applyret, "as locally executed") conformance.AssertMsgResult(reporter, receipt, applyret, "as locally executed")
if reporter.Failed() { if reporter.Failed() {
log.Println(color.RedString("receipt sanity check failed; aborting")) if opts.ignoreSanityChecks {
return fmt.Errorf("vector generation aborted") 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"))
} }
log.Println(color.GreenString("receipt sanity check succeeded"))
} else { } else {
receipt = &schema.Receipt{ receipt = &schema.Receipt{
ExitCode: int64(applyret.ExitCode), ExitCode: int64(applyret.ExitCode),