fix tvx init.

This commit is contained in:
Raúl Kripalani 2020-10-23 13:30:04 +01:00
parent 5301c416bc
commit 39d9150175
4 changed files with 14 additions and 10 deletions

View File

@ -49,6 +49,8 @@ var extractCmd = &cli.Command{
Name: "extract", Name: "extract",
Description: "generate a test vector by extracting it from a live chain", Description: "generate a test vector by extracting it from a live chain",
Action: runExtract, Action: runExtract,
Before: initialize,
After: destroy,
Flags: []cli.Flag{ Flags: []cli.Flag{
&repoFlag, &repoFlag,
&cli.StringFlag{ &cli.StringFlag{

View File

@ -43,6 +43,8 @@ var extractManyCmd = &cli.Command{
after these compulsory seven. after these compulsory seven.
`, `,
Action: runExtractMany, Action: runExtractMany,
Before: initialize,
After: destroy,
Flags: []cli.Flag{ Flags: []cli.Flag{
&repoFlag, &repoFlag,
&cli.StringFlag{ &cli.StringFlag{

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"log" "log"
"os" "os"
"sort" "sort"
@ -47,11 +48,6 @@ func main() {
tvx extract-many performs a batch extraction of many messages, supplied in a tvx extract-many performs a batch extraction of many messages, supplied in a
CSV file. Refer to the help of that subcommand for more info. CSV file. Refer to the help of that subcommand for more info.
tvx project projects an existing test vector against a different protocol
version, reporting the result, optionally appending a new variant to the
vector in place if deemed equivalent, or producing a new vector if
non-equivalent.
tvx simulate takes a raw message and simulates it on top of the supplied tvx simulate takes a raw message and simulates it on top of the supplied
epoch, reporting the result on stderr and writing a test vector on stdout epoch, reporting the result on stderr and writing a test vector on stdout
or into the specified file. or into the specified file.
@ -80,8 +76,6 @@ func main() {
extractManyCmd, extractManyCmd,
simulateCmd, simulateCmd,
}, },
Before: initialize,
After: destroy,
} }
sort.Sort(cli.CommandsByName(app.Commands)) sort.Sort(cli.CommandsByName(app.Commands))
@ -107,7 +101,9 @@ func initialize(c *cli.Context) error {
// Make the API client. // Make the API client.
var err error var err error
FullAPI, Closer, err = lcli.GetFullNodeAPI(c) if FullAPI, Closer, err = lcli.GetFullNodeAPI(c); err != nil {
err = fmt.Errorf("failed to locate Lotus node; ")
}
return err return err
} }

View File

@ -29,15 +29,19 @@ var simulateFlags struct {
var simulateCmd = &cli.Command{ var simulateCmd = &cli.Command{
Name: "simulate", Name: "simulate",
Description: "simulate a raw message on top of the supplied" + Description: "simulate a raw message on top of the supplied epoch (or HEAD), " +
"epoch, reporting the result on stderr and writing a test vector on stdout" + "reporting the result on stderr and writing a test vector on stdout " +
"or into the specified file", "or into the specified file",
Action: runSimulateCmd, Action: runSimulateCmd,
Before: initialize,
After: destroy,
Flags: []cli.Flag{ Flags: []cli.Flag{
&repoFlag,
&cli.StringFlag{ &cli.StringFlag{
Name: "msg", Name: "msg",
Usage: "base64 cbor-encoded message", Usage: "base64 cbor-encoded message",
Destination: &simulateFlags.msg, Destination: &simulateFlags.msg,
Required: true,
}, },
&cli.Int64Flag{ &cli.Int64Flag{
Name: "at-epoch", Name: "at-epoch",