From 312fa3a5cc3b3f7d2180f3cda1dcc52093ea6f57 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Fri, 20 Sep 2024 18:32:54 +0200 Subject: [PATCH] Simplify code generation logic for a faster and better UX (#12493) The changes here simplify the string of targets executed as part of `make gen`. The simplifications include: * parallelised code generation whenever possible * re-implementation of documentation generation for a significant simplification and improved readability. * unified mocks generation to avoid multiple slow calls to `go run` per package. Note, the changes introduced here are purely mechanical and do not alter the Lotus node functionality. Fixes #8392 --- Makefile | 34 +- api/docgen-openrpc/cmd/docgen_openrpc.go | 54 +-- api/docgen-openrpc/openrpc.go | 33 ++ api/docgen/cmd/docgen.go | 121 +---- api/docgen/docgen.go | 156 +++++- chain/actors/agen/main.go | 40 +- conformance/chaos/actor.go | 2 - conformance/chaos/gen/gen.go | 23 - gen/api/proxygen.go | 32 +- gen/docs/main.go | 94 ++++ gen/inline-gen/main.go | 210 ++++---- gen/main.go | 224 +++++---- node/config/cfgdocgen/gen.go | 2 +- storage/paths/index.go | 2 - storage/paths/interface.go | 4 - storage/paths/mocks/index.go | 214 -------- storage/paths/mocks/mocks.go | 450 +++++++++++++++++ storage/paths/mocks/pf.go | 99 ---- storage/paths/mocks/store.go | 169 ------- storage/paths/mocks_gen.go | 3 + storage/pipeline/commit_batch.go | 2 - storage/pipeline/fsm.go | 2 - storage/pipeline/gen/main.go | 21 - storage/pipeline/mocks/mock_commit_batcher.go | 225 --------- .../pipeline/mocks/mock_precommit_batcher.go | 224 --------- storage/pipeline/mocks/{api.go => mocks.go} | 459 +++++++++++++++++- storage/pipeline/mocks/statemachine.go | 63 --- storage/pipeline/mocks_gen.go | 3 + storage/pipeline/precommit_batch.go | 2 - storage/pipeline/sealing.go | 2 - storage/pipeline/types.go | 2 - 31 files changed, 1503 insertions(+), 1468 deletions(-) delete mode 100644 conformance/chaos/gen/gen.go create mode 100644 gen/docs/main.go delete mode 100644 storage/paths/mocks/index.go create mode 100644 storage/paths/mocks/mocks.go delete mode 100644 storage/paths/mocks/pf.go delete mode 100644 storage/paths/mocks/store.go create mode 100644 storage/paths/mocks_gen.go delete mode 100644 storage/pipeline/gen/main.go delete mode 100644 storage/pipeline/mocks/mock_commit_batcher.go delete mode 100644 storage/pipeline/mocks/mock_precommit_batcher.go rename storage/pipeline/mocks/{api.go => mocks.go} (56%) delete mode 100644 storage/pipeline/mocks/statemachine.go create mode 100644 storage/pipeline/mocks_gen.go diff --git a/Makefile b/Makefile index 1a81ed4f08b..cb2751d42c1 100644 --- a/Makefile +++ b/Makefile @@ -311,7 +311,6 @@ bundle-gen: $(GOCC) fmt ./build/... .PHONY: bundle-gen - api-gen: $(GOCC) run ./gen/api goimports -w api @@ -330,38 +329,13 @@ appimage: lotus cp ./lotus AppDir/usr/bin/ appimage-builder -docsgen: docsgen-md docsgen-openrpc fiximports - -docsgen-md-bin: api-gen actors-gen - $(GOCC) build $(GOFLAGS) -o docgen-md ./api/docgen/cmd -docsgen-openrpc-bin: api-gen actors-gen - $(GOCC) build $(GOFLAGS) -o docgen-openrpc ./api/docgen-openrpc/cmd - -docsgen-md: docsgen-md-full docsgen-md-storage docsgen-md-worker - -docsgen-md-full: docsgen-md-bin - ./docgen-md "api/api_full.go" "FullNode" "api" "./api" > documentation/en/api-v1-unstable-methods.md - ./docgen-md "api/v0api/full.go" "FullNode" "v0api" "./api/v0api" > documentation/en/api-v0-methods.md -docsgen-md-storage: docsgen-md-bin - ./docgen-md "api/api_storage.go" "StorageMiner" "api" "./api" > documentation/en/api-v0-methods-miner.md -docsgen-md-worker: docsgen-md-bin - ./docgen-md "api/api_worker.go" "Worker" "api" "./api" > documentation/en/api-v0-methods-worker.md - -docsgen-openrpc: docsgen-openrpc-full docsgen-openrpc-storage docsgen-openrpc-worker docsgen-openrpc-gateway - -docsgen-openrpc-full: docsgen-openrpc-bin - ./docgen-openrpc "api/api_full.go" "FullNode" "api" "./api" > build/openrpc/full.json -docsgen-openrpc-storage: docsgen-openrpc-bin - ./docgen-openrpc "api/api_storage.go" "StorageMiner" "api" "./api" > build/openrpc/miner.json -docsgen-openrpc-worker: docsgen-openrpc-bin - ./docgen-openrpc "api/api_worker.go" "Worker" "api" "./api" > build/openrpc/worker.json -docsgen-openrpc-gateway: docsgen-openrpc-bin - ./docgen-openrpc "api/api_gateway.go" "Gateway" "api" "./api" > build/openrpc/gateway.json - -.PHONY: docsgen docsgen-md-bin docsgen-openrpc-bin +docsgen: fiximports + $(GOCC) run ./gen/docs +.PHONY: docsgen fiximports: $(GOCC) run ./scripts/fiximports +.PHONY: fiximports gen: actors-code-gen type-gen cfgdoc-gen docsgen api-gen $(GOCC) run ./scripts/fiximports diff --git a/api/docgen-openrpc/cmd/docgen_openrpc.go b/api/docgen-openrpc/cmd/docgen_openrpc.go index 5f6bc566f2b..3a87d856cdf 100644 --- a/api/docgen-openrpc/cmd/docgen_openrpc.go +++ b/api/docgen-openrpc/cmd/docgen_openrpc.go @@ -1,10 +1,7 @@ package main import ( - "compress/gzip" - "encoding/json" - "io" - "log" + "fmt" "os" "github.com/filecoin-project/lotus/api/docgen" @@ -29,45 +26,22 @@ Use: */ func main() { - Comments, GroupDocs := docgen.ParseApiASTInfo(os.Args[1], os.Args[2], os.Args[3], os.Args[4]) - - doc := docgen_openrpc.NewLotusOpenRPCDocument(Comments, GroupDocs) - - i, _, _ := docgen.GetAPIType(os.Args[2], os.Args[3]) - doc.RegisterReceiverName("Filecoin", i) - - out, err := doc.Discover() - if err != nil { - log.Fatalln(err) - } - - var jsonOut []byte - var writer io.WriteCloser - // Use os.Args to handle a somewhat hacky flag for the gzip option. // Could use flags package to handle this more cleanly, but that requires changes elsewhere // the scope of which just isn't warranted by this one use case which will usually be run // programmatically anyways. - if len(os.Args) > 5 && os.Args[5] == "-gzip" { - jsonOut, err = json.Marshal(out) - if err != nil { - log.Fatalln(err) - } - writer = gzip.NewWriter(os.Stdout) - } else { - jsonOut, err = json.MarshalIndent(out, "", " ") - if err != nil { - log.Fatalln(err) - } - writer = os.Stdout - } - - _, err = writer.Write(jsonOut) - if err != nil { - log.Fatalln(err) - } - err = writer.Close() - if err != nil { - log.Fatalln(err) + var ( + apiFile = os.Args[1] + iface = os.Args[2] + pkg = os.Args[3] + dir = os.Args[4] + outGzip = len(os.Args) > 5 && os.Args[5] == "-gzip" + ) + if ainfo, err := docgen.ParseApiASTInfo(apiFile, iface, pkg, dir); err != nil { + _, _ = fmt.Fprintf(os.Stderr, "Failed to parse API AST info: %v\n", err) + os.Exit(1) + } else if err := docgen_openrpc.Generate(os.Stdout, iface, pkg, ainfo, outGzip); err != nil { + _, _ = fmt.Fprintf(os.Stderr, "Failed to generate OpenRPC docs: %v\n", err) + os.Exit(1) } } diff --git a/api/docgen-openrpc/openrpc.go b/api/docgen-openrpc/openrpc.go index 52e37aec657..ec8744ab276 100644 --- a/api/docgen-openrpc/openrpc.go +++ b/api/docgen-openrpc/openrpc.go @@ -1,8 +1,10 @@ package docgenopenrpc import ( + "compress/gzip" "encoding/json" "go/ast" + "io" "net" "reflect" @@ -29,6 +31,37 @@ const integerD = `{ const cidCidD = `{"title": "Content Identifier", "type": "string", "description": "Cid represents a self-describing content addressed identifier. It is formed by a Version, a Codec (which indicates a multicodec-packed content type) and a Multihash."}` +func Generate(out io.Writer, iface, pkg string, ainfo docgen.ApiASTInfo, outGzip bool) error { + doc := NewLotusOpenRPCDocument(ainfo.Comments, ainfo.GroupComments) + i, _, _ := docgen.GetAPIType(iface, pkg) + doc.RegisterReceiverName("Filecoin", i) + + dout, err := doc.Discover() + if err != nil { + return err + } + + switch { + case outGzip: + jsonOut, err := json.Marshal(dout) + if err != nil { + return err + } + writer := gzip.NewWriter(out) + if _, err = writer.Write(jsonOut); err != nil { + return err + } + return writer.Close() + default: + jsonOut, err := json.MarshalIndent(dout, "", " ") + if err != nil { + return err + } + _, err = out.Write(jsonOut) + return err + } +} + func OpenRPCSchemaTypeMapper(ty reflect.Type) *jsonschema.Type { unmarshalJSONToJSONSchemaType := func(input string) *jsonschema.Type { var js jsonschema.Type diff --git a/api/docgen/cmd/docgen.go b/api/docgen/cmd/docgen.go index 9ae2df2e707..fd2bc0859c4 100644 --- a/api/docgen/cmd/docgen.go +++ b/api/docgen/cmd/docgen.go @@ -1,121 +1,24 @@ package main import ( - "encoding/json" "fmt" "os" - "reflect" - "sort" - "strings" "github.com/filecoin-project/lotus/api/docgen" ) func main() { - comments, groupComments := docgen.ParseApiASTInfo(os.Args[1], os.Args[2], os.Args[3], os.Args[4]) - - groups := make(map[string]*docgen.MethodGroup) - - _, t, permStruct := docgen.GetAPIType(os.Args[2], os.Args[3]) - - for i := 0; i < t.NumMethod(); i++ { - m := t.Method(i) - - groupName := docgen.MethodGroupFromName(m.Name) - - g, ok := groups[groupName] - if !ok { - g = new(docgen.MethodGroup) - g.Header = groupComments[groupName] - g.GroupName = groupName - groups[groupName] = g - } - - var args []interface{} - ft := m.Func.Type() - for j := 2; j < ft.NumIn(); j++ { - inp := ft.In(j) - args = append(args, docgen.ExampleValue(m.Name, inp, nil)) - } - - v, err := json.MarshalIndent(args, "", " ") - if err != nil { - panic(err) - } - - outv := docgen.ExampleValue(m.Name, ft.Out(0), nil) - - ov, err := json.MarshalIndent(outv, "", " ") - if err != nil { - panic(err) - } - - g.Methods = append(g.Methods, &docgen.Method{ - Name: m.Name, - Comment: comments[m.Name], - InputExample: string(v), - ResponseExample: string(ov), - }) - } - - var groupslice []*docgen.MethodGroup - for _, g := range groups { - groupslice = append(groupslice, g) - } - - sort.Slice(groupslice, func(i, j int) bool { - return groupslice[i].GroupName < groupslice[j].GroupName - }) - - fmt.Printf("# Groups\n") - - for _, g := range groupslice { - fmt.Printf("* [%s](#%s)\n", g.GroupName, g.GroupName) - for _, method := range g.Methods { - fmt.Printf(" * [%s](#%s)\n", method.Name, method.Name) - } - } - - for _, g := range groupslice { - g := g - fmt.Printf("## %s\n", g.GroupName) - fmt.Printf("%s\n\n", g.Header) - - sort.Slice(g.Methods, func(i, j int) bool { - return g.Methods[i].Name < g.Methods[j].Name - }) - - for _, m := range g.Methods { - fmt.Printf("### %s\n", m.Name) - fmt.Printf("%s\n\n", m.Comment) - - var meth reflect.StructField - var ok bool - for _, ps := range permStruct { - meth, ok = ps.FieldByName(m.Name) - if ok { - break - } - } - if !ok { - panic("no perms for method: " + m.Name) - } - - perms := meth.Tag.Get("perm") - - fmt.Printf("Perms: %s\n\n", perms) - - if strings.Count(m.InputExample, "\n") > 0 { - fmt.Printf("Inputs:\n```json\n%s\n```\n\n", m.InputExample) - } else { - fmt.Printf("Inputs: `%s`\n\n", m.InputExample) - } - - if strings.Count(m.ResponseExample, "\n") > 0 { - fmt.Printf("Response:\n```json\n%s\n```\n\n", m.ResponseExample) - } else { - fmt.Printf("Response: `%s`\n\n", m.ResponseExample) - } - } + var ( + apiFile = os.Args[1] + iface = os.Args[2] + pkg = os.Args[3] + dir = os.Args[4] + ) + if ainfo, err := docgen.ParseApiASTInfo(apiFile, iface, pkg, dir); err != nil { + _, _ = fmt.Fprintf(os.Stderr, "Failed to parse API AST info: %v\n", err) + os.Exit(1) + } else if err := docgen.Generate(os.Stdout, iface, pkg, ainfo); err != nil { + _, _ = fmt.Fprintf(os.Stderr, "Failed to generate docs: %v\n", err) + os.Exit(1) } } diff --git a/api/docgen/docgen.go b/api/docgen/docgen.go index 70f67d7207c..5e443518f91 100644 --- a/api/docgen/docgen.go +++ b/api/docgen/docgen.go @@ -6,9 +6,11 @@ import ( "go/ast" "go/parser" "go/token" + "io" "net/http" "path/filepath" "reflect" + "sort" "strings" "time" "unicode" @@ -552,22 +554,153 @@ func (v *Visitor) Visit(node ast.Node) ast.Visitor { const NoComment = "There are not yet any comments for this method." -func ParseApiASTInfo(apiFile, iface, pkg, dir string) (comments map[string]string, groupDocs map[string]string) { //nolint:golint +type ApiASTInfo struct { + Comments map[string]string + GroupComments map[string]string +} + +func Generate(out io.Writer, iface, pkg string, ainfo ApiASTInfo) error { + + groups := make(map[string]*MethodGroup) + + _, t, permStruct := GetAPIType(iface, pkg) + + for i := 0; i < t.NumMethod(); i++ { + m := t.Method(i) + + groupName := MethodGroupFromName(m.Name) + + g, ok := groups[groupName] + if !ok { + g = new(MethodGroup) + g.Header = ainfo.GroupComments[groupName] + g.GroupName = groupName + groups[groupName] = g + } + + var args []interface{} + ft := m.Func.Type() + for j := 2; j < ft.NumIn(); j++ { + inp := ft.In(j) + args = append(args, ExampleValue(m.Name, inp, nil)) + } + + v, err := json.MarshalIndent(args, "", " ") + if err != nil { + panic(err) + } + + outv := ExampleValue(m.Name, ft.Out(0), nil) + + ov, err := json.MarshalIndent(outv, "", " ") + if err != nil { + panic(err) + } + + g.Methods = append(g.Methods, &Method{ + Name: m.Name, + Comment: ainfo.Comments[m.Name], + InputExample: string(v), + ResponseExample: string(ov), + }) + } + + var groupslice []*MethodGroup + for _, g := range groups { + groupslice = append(groupslice, g) + } + + sort.Slice(groupslice, func(i, j int) bool { + return groupslice[i].GroupName < groupslice[j].GroupName + }) + + if _, err := fmt.Fprintf(out, "# Groups\n"); err != nil { + return err + } + + for _, g := range groupslice { + if _, err := fmt.Fprintf(out, "* [%s](#%s)\n", g.GroupName, g.GroupName); err != nil { + return err + } + for _, method := range g.Methods { + if _, err := fmt.Fprintf(out, " * [%s](#%s)\n", method.Name, method.Name); err != nil { + return err + } + } + } + + for _, g := range groupslice { + g := g + if _, err := fmt.Fprintf(out, "## %s\n", g.GroupName); err != nil { + return err + } + if _, err := fmt.Fprintf(out, "%s\n\n", g.Header); err != nil { + return err + } + + sort.Slice(g.Methods, func(i, j int) bool { + return g.Methods[i].Name < g.Methods[j].Name + }) + + for _, m := range g.Methods { + if _, err := fmt.Fprintf(out, "### %s\n", m.Name); err != nil { + return err + } + if _, err := fmt.Fprintf(out, "%s\n\n", m.Comment); err != nil { + return err + } + + var meth reflect.StructField + var ok bool + for _, ps := range permStruct { + meth, ok = ps.FieldByName(m.Name) + if ok { + break + } + } + if !ok { + return fmt.Errorf("no perms for method: %s", m.Name) + } + + perms := meth.Tag.Get("perm") + + if _, err := fmt.Fprintf(out, "Perms: %s\n\n", perms); err != nil { + return err + } + + if strings.Count(m.InputExample, "\n") > 0 { + if _, err := fmt.Fprintf(out, "Inputs:\n```json\n%s\n```\n\n", m.InputExample); err != nil { + return err + } + } else if _, err := fmt.Fprintf(out, "Inputs: `%s`\n\n", m.InputExample); err != nil { + return err + } + + if strings.Count(m.ResponseExample, "\n") > 0 { + if _, err := fmt.Fprintf(out, "Response:\n```json\n%s\n```\n\n", m.ResponseExample); err != nil { + return err + } + } else if _, err := fmt.Fprintf(out, "Response: `%s`\n\n", m.ResponseExample); err != nil { + return err + } + } + } + return nil +} + +func ParseApiASTInfo(apiFile, iface, pkg, dir string) (ApiASTInfo, error) { //nolint:golint fset := token.NewFileSet() apiDir, err := filepath.Abs(dir) if err != nil { - fmt.Println("./api filepath absolute error: ", err) - return + return ApiASTInfo{}, fmt.Errorf("./api filepath absolute error: %w", err) } apiFile, err = filepath.Abs(apiFile) if err != nil { - fmt.Println("filepath absolute error: ", err, "file:", apiFile) - return + return ApiASTInfo{}, fmt.Errorf("filepath absolute file: %s, err: %w", apiFile, err) } pkgs, err := parser.ParseDir(fset, apiDir, nil, parser.AllErrors|parser.ParseComments) if err != nil { - fmt.Println("parse error: ", err) - return + return ApiASTInfo{}, fmt.Errorf("parse error: %w", err) } ap := pkgs[pkg] @@ -579,8 +712,8 @@ func ParseApiASTInfo(apiFile, iface, pkg, dir string) (comments map[string]strin v := &Visitor{iface, make(map[string]ast.Node)} ast.Walk(v, ap) - comments = make(map[string]string) - groupDocs = make(map[string]string) + comments := make(map[string]string) + groupDocs := make(map[string]string) for mn, node := range v.Methods { filteredComments := cmap.Filter(node).Comments() if len(filteredComments) == 0 { @@ -609,7 +742,10 @@ func ParseApiASTInfo(apiFile, iface, pkg, dir string) (comments map[string]strin } } } - return comments, groupDocs + return ApiASTInfo{ + Comments: comments, + GroupComments: groupDocs, + }, nil } type MethodGroup struct { diff --git a/chain/actors/agen/main.go b/chain/actors/agen/main.go index 811ea27e982..f1e82237364 100644 --- a/chain/actors/agen/main.go +++ b/chain/actors/agen/main.go @@ -9,6 +9,7 @@ import ( "strconv" "text/template" + "golang.org/x/sync/errgroup" "golang.org/x/xerrors" lotusactors "github.com/filecoin-project/lotus/chain/actors" @@ -31,25 +32,16 @@ var actors = map[string][]int{ } func main() { - if err := generateAdapters(); err != nil { - fmt.Println(err) - return - } - - if err := generatePolicy("chain/actors/policy/policy.go"); err != nil { - fmt.Println(err) - return - } - - if err := generateBuiltin("chain/actors/builtin/builtin.go"); err != nil { - fmt.Println(err) - return - } - - if err := generateRegistry("chain/actors/builtin/registry.go"); err != nil { - fmt.Println(err) - return + var lets errgroup.Group + lets.Go(generateAdapters) + lets.Go(generatePolicy) + lets.Go(generateBuiltin) + lets.Go(generateRegistry) + if err := lets.Wait(); err != nil { + fmt.Println("Error:", err) + os.Exit(1) } + fmt.Println("All chain actor files generated successfully.") } func generateAdapters() error { @@ -162,8 +154,8 @@ func generateMessages(actDir string) error { return nil } -func generatePolicy(policyPath string) error { - +func generatePolicy() error { + const policyPath = "chain/actors/policy/policy.go" pf, err := os.ReadFile(policyPath + ".template") if err != nil { if os.IsNotExist(err) { @@ -193,8 +185,8 @@ func generatePolicy(policyPath string) error { return nil } -func generateBuiltin(builtinPath string) error { - +func generateBuiltin() error { + const builtinPath = "chain/actors/builtin/builtin.go" bf, err := os.ReadFile(builtinPath + ".template") if err != nil { if os.IsNotExist(err) { @@ -224,8 +216,8 @@ func generateBuiltin(builtinPath string) error { return nil } -func generateRegistry(registryPath string) error { - +func generateRegistry() error { + const registryPath = "chain/actors/builtin/registry.go" bf, err := os.ReadFile(registryPath + ".template") if err != nil { if os.IsNotExist(err) { diff --git a/conformance/chaos/actor.go b/conformance/chaos/actor.go index 125e3a4347c..fb1284ac284 100644 --- a/conformance/chaos/actor.go +++ b/conformance/chaos/actor.go @@ -14,8 +14,6 @@ import ( "github.com/filecoin-project/lotus/chain/actors/builtin" ) -//go:generate go run ./gen - // Actor is a chaos actor. It implements a variety of illegal behaviours that // trigger violations of VM invariants. These behaviours are not found in // production code, but are important to test that the VM constraints are diff --git a/conformance/chaos/gen/gen.go b/conformance/chaos/gen/gen.go deleted file mode 100644 index 20a1be64fb0..00000000000 --- a/conformance/chaos/gen/gen.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - gen "github.com/whyrusleeping/cbor-gen" - - "github.com/filecoin-project/lotus/conformance/chaos" -) - -func main() { - if err := gen.WriteTupleEncodersToFile("./cbor_gen.go", "chaos", - chaos.State{}, - chaos.CallerValidationArgs{}, - chaos.CreateActorArgs{}, - chaos.ResolveAddressResponse{}, - chaos.SendArgs{}, - chaos.SendReturn{}, - chaos.MutateStateArgs{}, - chaos.AbortWithArgs{}, - chaos.InspectRuntimeReturn{}, - ); err != nil { - panic(err) - } -} diff --git a/gen/api/proxygen.go b/gen/api/proxygen.go index fba276372db..2bf83b62f42 100644 --- a/gen/api/proxygen.go +++ b/gen/api/proxygen.go @@ -11,6 +11,7 @@ import ( "strings" "text/template" + "golang.org/x/sync/errgroup" "golang.org/x/xerrors" ) @@ -24,6 +25,25 @@ type Visitor struct { Include map[string][]string } +func main() { + var lets errgroup.Group + lets.Go(generateApi) + lets.Go(generateApiV0) + if err := lets.Wait(); err != nil { + fmt.Println("Error:", err) + os.Exit(1) + } + fmt.Println("All API proxy files generated successfully.") +} + +func generateApiV0() error { + return generate("./api/v0api", "v0api", "v0api", "./api/v0api/proxy_gen.go") +} + +func generateApi() error { + return generate("./api", "api", "api", "./api/proxy_gen.go") +} + func (v *Visitor) Visit(node ast.Node) ast.Visitor { st, ok := node.(*ast.TypeSpec) if !ok { @@ -52,18 +72,6 @@ func (v *Visitor) Visit(node ast.Node) ast.Visitor { return v } -func main() { - // latest (v1) - if err := generate("./api", "api", "api", "./api/proxy_gen.go"); err != nil { - fmt.Println("error: ", err) - } - - // v0 - if err := generate("./api/v0api", "v0api", "v0api", "./api/v0api/proxy_gen.go"); err != nil { - fmt.Println("error: ", err) - } -} - func typeName(e ast.Expr, pkg string) (string, error) { switch t := e.(type) { case *ast.SelectorExpr: diff --git a/gen/docs/main.go b/gen/docs/main.go new file mode 100644 index 00000000000..95a803f122c --- /dev/null +++ b/gen/docs/main.go @@ -0,0 +1,94 @@ +package main + +import ( + "fmt" + "os" + + "golang.org/x/sync/errgroup" + + "github.com/filecoin-project/lotus/api/docgen" + docgen_openrpc "github.com/filecoin-project/lotus/api/docgen-openrpc" +) + +func main() { + var lets errgroup.Group + lets.SetLimit(1) // TODO: Investigate why this can't run in parallel. + lets.Go(generateApiFull) + lets.Go(generateApiV0Methods) + lets.Go(generateStorage) + lets.Go(generateWorker) + lets.Go(generateOpenRpcGateway) + if err := lets.Wait(); err != nil { + fmt.Println("Error:", err) + os.Exit(1) + } + fmt.Println("All documentations generated successfully.") +} + +func generateWorker() error { + if ainfo, err := docgen.ParseApiASTInfo("api/api_worker.go", "Worker", "api", "./api"); err != nil { + return err + } else if err := generateMarkdown("documentation/en/api-v0-methods-worker.md", "Worker", "api", ainfo); err != nil { + return err + } else { + return generateOpenRpc("build/openrpc/worker.json", "Worker", "api", ainfo) + } +} + +func generateStorage() error { + if ainfo, err := docgen.ParseApiASTInfo("api/api_storage.go", "StorageMiner", "api", "./api"); err != nil { + return err + } else if err := generateMarkdown("documentation/en/api-v0-methods-miner.md", "StorageMiner", "api", ainfo); err != nil { + return err + } else { + return generateOpenRpc("build/openrpc/miner.json", "StorageMiner", "api", ainfo) + } +} + +func generateApiV0Methods() error { + if ainfo, err := docgen.ParseApiASTInfo("api/v0api/full.go", "FullNode", "v0api", "./api/v0api"); err != nil { + return err + } else { + return generateMarkdown("documentation/en/api-v0-methods.md", "FullNode", "v0api", ainfo) + } +} + +func generateApiFull() error { + if ainfo, err := docgen.ParseApiASTInfo("api/api_full.go", "FullNode", "api", "./api"); err != nil { + return err + } else if err := generateMarkdown("documentation/en/api-v1-unstable-methods.md", "FullNode", "api", ainfo); err != nil { + return err + } else { + return generateOpenRpc("build/openrpc/full.json", "FullNode", "api", ainfo) + } +} + +func generateOpenRpcGateway() error { + if ainfo, err := docgen.ParseApiASTInfo("api/api_gateway.go", "Gateway", "api", "./api"); err != nil { + return err + } else { + return generateOpenRpc("build/openrpc/gateway.json", "Gateway", "api", ainfo) + } +} + +func generateMarkdown(path, iface, pkg string, info docgen.ApiASTInfo) error { + out, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + if err != nil { + return err + } + defer func() { + _ = out.Close() + }() + return docgen.Generate(out, iface, pkg, info) +} + +func generateOpenRpc(path, iface, pkg string, info docgen.ApiASTInfo) error { + out, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + if err != nil { + return err + } + defer func() { + _ = out.Close() + }() + return docgen_openrpc.Generate(out, iface, pkg, info, false) +} diff --git a/gen/inline-gen/main.go b/gen/inline-gen/main.go index 4e55816f6b6..a2cf5c67ac7 100644 --- a/gen/inline-gen/main.go +++ b/gen/inline-gen/main.go @@ -9,6 +9,8 @@ import ( "path/filepath" "strings" "text/template" + + "golang.org/x/sync/errgroup" ) const ( @@ -18,105 +20,143 @@ const ( ) func main() { - db, err := os.ReadFile(os.Args[2]) - if err != nil { - panic(err) + if len(os.Args) < 2 { + fmt.Printf("Usage: %s \n", os.Args[0]) + os.Exit(1) } - var data map[string]interface{} - if err := json.Unmarshal(db, &data); err != nil { - panic(err) + rootDir := os.Args[1] + jsonDataPath := os.Args[2] + + data, err := readDataFromFile(jsonDataPath) + if err != nil { + fmt.Printf("Failed to read JSON data from %s: %v\n", jsonDataPath, err) + os.Exit(1) } - err = filepath.WalkDir(os.Args[1], func(path string, d fs.DirEntry, err error) error { - if err != nil { + var g errgroup.Group + if err := filepath.WalkDir(rootDir, func(path string, d fs.DirEntry, err error) error { + switch { + case err != nil: return err - } - if d.IsDir() { + case d.IsDir() || filepath.Ext(path) != ".go": return nil - } - if filepath.Ext(path) != ".go" { + default: + g.Go(func() error { + return processFile(path, data) + }) return nil } - fb, err := os.ReadFile(path) - if err != nil { - return err - } + }); err != nil { + fmt.Printf("Failed to walk path %s: %v\n", rootDir, err) + os.Exit(1) + } + if err := g.Wait(); err != nil { + fmt.Printf("Error: %v\n", err) + os.Exit(1) + } + fmt.Println("All inline-gen files processed successfully.") +} - lines := strings.Split(string(fb), "\n") - - outLines := make([]string, 0, len(lines)) - var templateLines []string - - state := stateGlobal - - rewrite := false - - for i, line := range lines { - ln := i + 1 - switch state { - case stateGlobal: - outLines = append(outLines, line) - if strings.TrimSpace(line) == `/* inline-gen template` { - state = stateTemplate - fmt.Printf("template section start %s:%d\n", path, ln) - } - case stateTemplate: - outLines = append(outLines, line) // output all template lines - - if strings.TrimSpace(line) == `/* inline-gen start */` { - state = stateGen - fmt.Printf("generated section start %s:%d\n", path, ln) - continue - } - templateLines = append(templateLines, line) - case stateGen: - if strings.TrimSpace(line) != `/* inline-gen end */` { - continue - } - fmt.Printf("generated section end %s:%d\n", path, ln) - - state = stateGlobal - rewrite = true - - tpl, err := template.New("").Funcs(template.FuncMap{ - "import": func(v float64) string { - if v == 0 { - return "/" - } - return fmt.Sprintf("/v%d/", int(v)) - }, - "add": func(a, b float64) float64 { - return a + b - }, - }).Parse(strings.Join(templateLines, "\n")) - if err != nil { - fmt.Printf("%s:%d: parsing template: %s\n", path, ln, err) - os.Exit(1) - } - - var b bytes.Buffer - err = tpl.Execute(&b, data) - if err != nil { - fmt.Printf("%s:%d: executing template: %s\n", path, ln, err) - os.Exit(1) - } - - outLines = append(outLines, strings.Split(b.String(), "\n")...) - outLines = append(outLines, line) - templateLines = nil +// readDataFromFile reads the JSON file and unmarshals it into a map. +func readDataFromFile(filePath string) (map[string]any, error) { + db, err := os.ReadFile(filePath) + if err != nil { + return nil, err + } + var data map[string]any + if err := json.Unmarshal(db, &data); err != nil { + return nil, err + } + return data, nil +} + +// processFile processes the Go file and applies inline template generation. +func processFile(path string, data map[string]any) error { + fb, err := os.ReadFile(path) + if err != nil { + return err + } + + lines := strings.Split(string(fb), "\n") + outLines := make([]string, 0, len(lines)) + var templateLines []string + state := stateGlobal + rewrite := false + + // Process each line in the file + for i, line := range lines { + ln := i + 1 + switch state { + case stateGlobal: + outLines = append(outLines, line) + if strings.TrimSpace(line) == `/* inline-gen template` { + state = stateTemplate + fmt.Printf("template section start %s:%d\n", path, ln) } - } + case stateTemplate: + outLines = append(outLines, line) // output all template lines - if rewrite { - fmt.Printf("write %s\n", path) - if err := os.WriteFile(path, []byte(strings.Join(outLines, "\n")), 0664); err != nil { + if strings.TrimSpace(line) == `/* inline-gen start */` { + state = stateGen + fmt.Printf("generated section start %s:%d\n", path, ln) + continue + } + templateLines = append(templateLines, line) + case stateGen: + if strings.TrimSpace(line) != `/* inline-gen end */` { + continue + } + fmt.Printf("generated section end %s:%d\n", path, ln) + + state = stateGlobal + rewrite = true + + // Generate template output + generated, err := generateFromTemplate(templateLines, data, path, ln) + if err != nil { return err } + outLines = append(outLines, generated...) + outLines = append(outLines, line) // Append end line + templateLines = nil } + } + + // If the file was modified, rewrite it + if rewrite { + fmt.Printf("write %s\n", path) + return writeFile(path, outLines) + } + return nil +} - return nil - }) +// generateFromTemplate parses and executes a template from lines +func generateFromTemplate(templateLines []string, data map[string]any, path string, ln int) ([]string, error) { + tpl, err := template.New("").Funcs(template.FuncMap{ + "import": func(v float64) string { + if v == 0 { + return "/" + } + return fmt.Sprintf("/v%d/", int(v)) + }, + "add": func(a, b float64) float64 { + return a + b + }, + }).Parse(strings.Join(templateLines, "\n")) if err != nil { - panic(err) + return nil, fmt.Errorf("%s:%d: parsing template: %w", path, ln, err) } + + var b bytes.Buffer + err = tpl.Execute(&b, data) + if err != nil { + return nil, fmt.Errorf("%s:%d: executing template: %w", path, ln, err) + } + + return strings.Split(b.String(), "\n"), nil +} + +// writeFile writes the modified file back to disk +func writeFile(path string, lines []string) error { + return os.WriteFile(path, []byte(strings.Join(lines, "\n")), 0664) } diff --git a/gen/main.go b/gen/main.go index f1fe3876ac0..da343ea03b4 100644 --- a/gen/main.go +++ b/gen/main.go @@ -5,6 +5,7 @@ import ( "os" gen "github.com/whyrusleeping/cbor-gen" + "golang.org/x/sync/errgroup" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/blockstore" @@ -12,136 +13,159 @@ import ( "github.com/filecoin-project/lotus/chain/market" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/cmd/lotus-shed/shedgen" + "github.com/filecoin-project/lotus/conformance/chaos" "github.com/filecoin-project/lotus/node/hello" "github.com/filecoin-project/lotus/paychmgr" + sealing "github.com/filecoin-project/lotus/storage/pipeline" "github.com/filecoin-project/lotus/storage/pipeline/piece" sectorstorage "github.com/filecoin-project/lotus/storage/sealer" "github.com/filecoin-project/lotus/storage/sealer/storiface" ) func main() { - err := gen.WriteTupleEncodersToFile("./chain/types/cbor_gen.go", "types", - types.BlockHeader{}, - types.Ticket{}, - types.ElectionProof{}, - types.Message{}, - types.SignedMessage{}, - types.MsgMeta{}, - types.ActorV4{}, - types.ActorV5{}, - // types.MessageReceipt{}, // Custom serde to deal with versioning. - types.BlockMsg{}, - types.ExpTipSet{}, - types.BeaconEntry{}, - types.StateRoot{}, - types.StateInfo0{}, - types.Event{}, - types.EventEntry{}, - // Tracing - types.GasTrace{}, - types.ActorTrace{}, - types.MessageTrace{}, - types.ReturnTrace{}, - types.ExecutionTrace{}, - ) - if err != nil { - fmt.Println(err) + var lets errgroup.Group + lets.Go(generateApi) + lets.Go(generateBlockstore) + lets.Go(generateChainExchange) + lets.Go(generateChainMarket) + lets.Go(generateChainTypes) + lets.Go(generateConformanceChaos) + lets.Go(generateLotusShed) + lets.Go(generateNodeHello) + lets.Go(generatePaychmgr) + lets.Go(generateStoragePipeline) + lets.Go(generateStoragePipelinePiece) + lets.Go(generateStorageSealer) + lets.Go(generateStorageSealerInterface) + if err := lets.Wait(); err != nil { + fmt.Println("Error:", err) os.Exit(1) } + fmt.Println("All CBOR encoders have been generated successfully.") +} - err = gen.WriteMapEncodersToFile("./paychmgr/cbor_gen.go", "paychmgr", - paychmgr.VoucherInfo{}, - paychmgr.ChannelInfo{}, - paychmgr.MsgInfo{}, +func generateBlockstore() error { + return gen.WriteTupleEncodersToFile("./blockstore/cbor_gen.go", "blockstore", + blockstore.NetRpcReq{}, + blockstore.NetRpcResp{}, + blockstore.NetRpcErr{}, ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } +} - err = gen.WriteMapEncodersToFile("./api/cbor_gen.go", "api", - api.PaymentInfo{}, - api.SealedRef{}, - api.SealedRefs{}, - api.SealTicket{}, - api.SealSeed{}, - api.SectorPiece{}, +func generateLotusShed() error { + return gen.WriteMapEncodersToFile("./cmd/lotus-shed/shedgen/cbor_gen.go", "shedgen", + shedgen.CarbNode{}, ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } +} - err = gen.WriteTupleEncodersToFile("./node/hello/cbor_gen.go", "hello", - hello.HelloMessage{}, - hello.LatencyMessage{}, +func generateStorageSealer() error { + return gen.WriteMapEncodersToFile("./storage/sealer/cbor_gen.go", "sealer", + sectorstorage.Call{}, + sectorstorage.WorkState{}, + sectorstorage.WorkID{}, ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } +} - err = gen.WriteTupleEncodersToFile("./chain/market/cbor_gen.go", "market", - market.FundedAddressState{}, +func generateStoragePipeline() error { + return gen.WriteMapEncodersToFile("./storage/pipeline/cbor_gen.go", "sealing", + sealing.SectorInfo{}, + sealing.Log{}, ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } +} + +func generateStoragePipelinePiece() error { + return gen.WriteMapEncodersToFile("./storage/pipeline/piece/cbor_gen.go", "piece", + piece.PieceDealInfo{}, + piece.DealSchedule{}, + ) +} + +func generateStorageSealerInterface() error { + return gen.WriteMapEncodersToFile("./storage/sealer/storiface/cbor_gen.go", "storiface", + storiface.CallID{}, + storiface.SecDataHttpHeader{}, + storiface.SectorLocation{}, + ) +} - err = gen.WriteTupleEncodersToFile("./chain/exchange/cbor_gen.go", "exchange", +func generateChainExchange() error { + return gen.WriteTupleEncodersToFile("./chain/exchange/cbor_gen.go", "exchange", exchange.Request{}, exchange.Response{}, exchange.CompactedMessagesCBOR{}, exchange.BSTipSet{}, ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } +} - err = gen.WriteMapEncodersToFile("./storage/sealer/storiface/cbor_gen.go", "storiface", - storiface.CallID{}, - storiface.SecDataHttpHeader{}, - storiface.SectorLocation{}, +func generateConformanceChaos() error { + return gen.WriteTupleEncodersToFile("./conformance/chaos/cbor_gen.go", "chaos", + chaos.State{}, + chaos.CallerValidationArgs{}, + chaos.CreateActorArgs{}, + chaos.ResolveAddressResponse{}, + chaos.SendArgs{}, + chaos.SendReturn{}, + chaos.MutateStateArgs{}, + chaos.AbortWithArgs{}, + chaos.InspectRuntimeReturn{}, ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } +} - err = gen.WriteMapEncodersToFile("./storage/pipeline/piece/cbor_gen.go", "piece", - piece.PieceDealInfo{}, - piece.DealSchedule{}, +func generateChainMarket() error { + return gen.WriteTupleEncodersToFile("./chain/market/cbor_gen.go", "market", + market.FundedAddressState{}, ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } +} - err = gen.WriteMapEncodersToFile("./storage/sealer/cbor_gen.go", "sealer", - sectorstorage.Call{}, - sectorstorage.WorkState{}, - sectorstorage.WorkID{}, +func generateNodeHello() error { + return gen.WriteTupleEncodersToFile("./node/hello/cbor_gen.go", "hello", + hello.HelloMessage{}, + hello.LatencyMessage{}, ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - err = gen.WriteMapEncodersToFile("./cmd/lotus-shed/shedgen/cbor_gen.go", "shedgen", - shedgen.CarbNode{}, +} + +func generateApi() error { + return gen.WriteMapEncodersToFile("./api/cbor_gen.go", "api", + api.PaymentInfo{}, + api.SealedRef{}, + api.SealedRefs{}, + api.SealTicket{}, + api.SealSeed{}, + api.SectorPiece{}, ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - err = gen.WriteTupleEncodersToFile("./blockstore/cbor_gen.go", "blockstore", - blockstore.NetRpcReq{}, - blockstore.NetRpcResp{}, - blockstore.NetRpcErr{}, +} + +func generatePaychmgr() error { + return gen.WriteMapEncodersToFile("./paychmgr/cbor_gen.go", "paychmgr", + paychmgr.VoucherInfo{}, + paychmgr.ChannelInfo{}, + paychmgr.MsgInfo{}, + ) +} + +func generateChainTypes() error { + return gen.WriteTupleEncodersToFile("./chain/types/cbor_gen.go", "types", + types.BlockHeader{}, + types.Ticket{}, + types.ElectionProof{}, + types.Message{}, + types.SignedMessage{}, + types.MsgMeta{}, + types.ActorV4{}, + types.ActorV5{}, + // types.MessageReceipt{}, // Custom serde to deal with versioning. + types.BlockMsg{}, + types.ExpTipSet{}, + types.BeaconEntry{}, + types.StateRoot{}, + types.StateInfo0{}, + types.Event{}, + types.EventEntry{}, + // Tracing + types.GasTrace{}, + types.ActorTrace{}, + types.MessageTrace{}, + types.ReturnTrace{}, + types.ExecutionTrace{}, ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } } diff --git a/node/config/cfgdocgen/gen.go b/node/config/cfgdocgen/gen.go index 6c7371a4082..a8857f584fe 100644 --- a/node/config/cfgdocgen/gen.go +++ b/node/config/cfgdocgen/gen.go @@ -129,7 +129,7 @@ var Doc = map[string][]DocField{ func main() { if err := run(); err != nil { - fmt.Println(err.Error()) + fmt.Printf("Error: %v\n", err) os.Exit(1) } } diff --git a/storage/paths/index.go b/storage/paths/index.go index e09b887e03d..92449707898 100644 --- a/storage/paths/index.go +++ b/storage/paths/index.go @@ -27,8 +27,6 @@ import ( var HeartbeatInterval = 10 * time.Second var SkippedHeartbeatThresh = HeartbeatInterval * 5 -//go:generate go run github.com/golang/mock/mockgen -destination=mocks/index.go -package=mocks . SectorIndex - type SectorIndex interface { // part of storage-miner api StorageAttach(context.Context, storiface.StorageInfo, fsutil.FsStat) error StorageDetach(ctx context.Context, id storiface.ID, url string) error diff --git a/storage/paths/interface.go b/storage/paths/interface.go index 088e2340b73..0eee12898b9 100644 --- a/storage/paths/interface.go +++ b/storage/paths/interface.go @@ -13,8 +13,6 @@ import ( "github.com/filecoin-project/lotus/storage/sealer/storiface" ) -//go:generate go run github.com/golang/mock/mockgen -destination=mocks/pf.go -package=mocks . PartialFileHandler - // PartialFileHandler helps mock out the partial file functionality during testing. type PartialFileHandler interface { // OpenPartialFile opens and returns a partial file at the given path and also verifies it has the given @@ -32,8 +30,6 @@ type PartialFileHandler interface { Close(pf *partialfile.PartialFile) error } -//go:generate go run github.com/golang/mock/mockgen -destination=mocks/store.go -package=mocks . Store - type Store interface { AcquireSector(ctx context.Context, s storiface.SectorRef, existing storiface.SectorFileType, allocate storiface.SectorFileType, sealing storiface.PathType, op storiface.AcquireMode, opts ...storiface.AcquireOption) (paths storiface.SectorPaths, stores storiface.SectorPaths, err error) Remove(ctx context.Context, s abi.SectorID, types storiface.SectorFileType, force bool, keepIn []storiface.ID) error diff --git a/storage/paths/mocks/index.go b/storage/paths/mocks/index.go deleted file mode 100644 index 1835661ff5c..00000000000 --- a/storage/paths/mocks/index.go +++ /dev/null @@ -1,214 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/filecoin-project/lotus/storage/paths (interfaces: SectorIndex) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" - - abi "github.com/filecoin-project/go-state-types/abi" - - fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" - storiface "github.com/filecoin-project/lotus/storage/sealer/storiface" -) - -// MockSectorIndex is a mock of SectorIndex interface. -type MockSectorIndex struct { - ctrl *gomock.Controller - recorder *MockSectorIndexMockRecorder -} - -// MockSectorIndexMockRecorder is the mock recorder for MockSectorIndex. -type MockSectorIndexMockRecorder struct { - mock *MockSectorIndex -} - -// NewMockSectorIndex creates a new mock instance. -func NewMockSectorIndex(ctrl *gomock.Controller) *MockSectorIndex { - mock := &MockSectorIndex{ctrl: ctrl} - mock.recorder = &MockSectorIndexMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockSectorIndex) EXPECT() *MockSectorIndexMockRecorder { - return m.recorder -} - -// StorageAttach mocks base method. -func (m *MockSectorIndex) StorageAttach(arg0 context.Context, arg1 storiface.StorageInfo, arg2 fsutil.FsStat) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageAttach", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// StorageAttach indicates an expected call of StorageAttach. -func (mr *MockSectorIndexMockRecorder) StorageAttach(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageAttach", reflect.TypeOf((*MockSectorIndex)(nil).StorageAttach), arg0, arg1, arg2) -} - -// StorageBestAlloc mocks base method. -func (m *MockSectorIndex) StorageBestAlloc(arg0 context.Context, arg1 storiface.SectorFileType, arg2 abi.SectorSize, arg3 storiface.PathType, arg4 abi.ActorID) ([]storiface.StorageInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageBestAlloc", arg0, arg1, arg2, arg3, arg4) - ret0, _ := ret[0].([]storiface.StorageInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StorageBestAlloc indicates an expected call of StorageBestAlloc. -func (mr *MockSectorIndexMockRecorder) StorageBestAlloc(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageBestAlloc", reflect.TypeOf((*MockSectorIndex)(nil).StorageBestAlloc), arg0, arg1, arg2, arg3, arg4) -} - -// StorageDeclareSector mocks base method. -func (m *MockSectorIndex) StorageDeclareSector(arg0 context.Context, arg1 storiface.ID, arg2 abi.SectorID, arg3 storiface.SectorFileType, arg4 bool) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageDeclareSector", arg0, arg1, arg2, arg3, arg4) - ret0, _ := ret[0].(error) - return ret0 -} - -// StorageDeclareSector indicates an expected call of StorageDeclareSector. -func (mr *MockSectorIndexMockRecorder) StorageDeclareSector(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageDeclareSector", reflect.TypeOf((*MockSectorIndex)(nil).StorageDeclareSector), arg0, arg1, arg2, arg3, arg4) -} - -// StorageDetach mocks base method. -func (m *MockSectorIndex) StorageDetach(arg0 context.Context, arg1 storiface.ID, arg2 string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageDetach", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// StorageDetach indicates an expected call of StorageDetach. -func (mr *MockSectorIndexMockRecorder) StorageDetach(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageDetach", reflect.TypeOf((*MockSectorIndex)(nil).StorageDetach), arg0, arg1, arg2) -} - -// StorageDropSector mocks base method. -func (m *MockSectorIndex) StorageDropSector(arg0 context.Context, arg1 storiface.ID, arg2 abi.SectorID, arg3 storiface.SectorFileType) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageDropSector", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(error) - return ret0 -} - -// StorageDropSector indicates an expected call of StorageDropSector. -func (mr *MockSectorIndexMockRecorder) StorageDropSector(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageDropSector", reflect.TypeOf((*MockSectorIndex)(nil).StorageDropSector), arg0, arg1, arg2, arg3) -} - -// StorageFindSector mocks base method. -func (m *MockSectorIndex) StorageFindSector(arg0 context.Context, arg1 abi.SectorID, arg2 storiface.SectorFileType, arg3 abi.SectorSize, arg4 bool) ([]storiface.SectorStorageInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageFindSector", arg0, arg1, arg2, arg3, arg4) - ret0, _ := ret[0].([]storiface.SectorStorageInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StorageFindSector indicates an expected call of StorageFindSector. -func (mr *MockSectorIndexMockRecorder) StorageFindSector(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageFindSector", reflect.TypeOf((*MockSectorIndex)(nil).StorageFindSector), arg0, arg1, arg2, arg3, arg4) -} - -// StorageGetLocks mocks base method. -func (m *MockSectorIndex) StorageGetLocks(arg0 context.Context) (storiface.SectorLocks, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageGetLocks", arg0) - ret0, _ := ret[0].(storiface.SectorLocks) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StorageGetLocks indicates an expected call of StorageGetLocks. -func (mr *MockSectorIndexMockRecorder) StorageGetLocks(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageGetLocks", reflect.TypeOf((*MockSectorIndex)(nil).StorageGetLocks), arg0) -} - -// StorageInfo mocks base method. -func (m *MockSectorIndex) StorageInfo(arg0 context.Context, arg1 storiface.ID) (storiface.StorageInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageInfo", arg0, arg1) - ret0, _ := ret[0].(storiface.StorageInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StorageInfo indicates an expected call of StorageInfo. -func (mr *MockSectorIndexMockRecorder) StorageInfo(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageInfo", reflect.TypeOf((*MockSectorIndex)(nil).StorageInfo), arg0, arg1) -} - -// StorageList mocks base method. -func (m *MockSectorIndex) StorageList(arg0 context.Context) (map[storiface.ID][]storiface.Decl, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageList", arg0) - ret0, _ := ret[0].(map[storiface.ID][]storiface.Decl) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StorageList indicates an expected call of StorageList. -func (mr *MockSectorIndexMockRecorder) StorageList(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageList", reflect.TypeOf((*MockSectorIndex)(nil).StorageList), arg0) -} - -// StorageLock mocks base method. -func (m *MockSectorIndex) StorageLock(arg0 context.Context, arg1 abi.SectorID, arg2, arg3 storiface.SectorFileType) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageLock", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(error) - return ret0 -} - -// StorageLock indicates an expected call of StorageLock. -func (mr *MockSectorIndexMockRecorder) StorageLock(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageLock", reflect.TypeOf((*MockSectorIndex)(nil).StorageLock), arg0, arg1, arg2, arg3) -} - -// StorageReportHealth mocks base method. -func (m *MockSectorIndex) StorageReportHealth(arg0 context.Context, arg1 storiface.ID, arg2 storiface.HealthReport) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageReportHealth", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// StorageReportHealth indicates an expected call of StorageReportHealth. -func (mr *MockSectorIndexMockRecorder) StorageReportHealth(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageReportHealth", reflect.TypeOf((*MockSectorIndex)(nil).StorageReportHealth), arg0, arg1, arg2) -} - -// StorageTryLock mocks base method. -func (m *MockSectorIndex) StorageTryLock(arg0 context.Context, arg1 abi.SectorID, arg2, arg3 storiface.SectorFileType) (bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StorageTryLock", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StorageTryLock indicates an expected call of StorageTryLock. -func (mr *MockSectorIndexMockRecorder) StorageTryLock(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageTryLock", reflect.TypeOf((*MockSectorIndex)(nil).StorageTryLock), arg0, arg1, arg2, arg3) -} diff --git a/storage/paths/mocks/mocks.go b/storage/paths/mocks/mocks.go new file mode 100644 index 00000000000..fb2bd750292 --- /dev/null +++ b/storage/paths/mocks/mocks.go @@ -0,0 +1,450 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/filecoin-project/lotus/storage/paths (interfaces: SectorIndex,PartialFileHandler,Store) + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + io "io" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + cid "github.com/ipfs/go-cid" + + abi "github.com/filecoin-project/go-state-types/abi" + + fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" + partialfile "github.com/filecoin-project/lotus/storage/sealer/partialfile" + storiface "github.com/filecoin-project/lotus/storage/sealer/storiface" +) + +// MockSectorIndex is a mock of SectorIndex interface. +type MockSectorIndex struct { + ctrl *gomock.Controller + recorder *MockSectorIndexMockRecorder +} + +// MockSectorIndexMockRecorder is the mock recorder for MockSectorIndex. +type MockSectorIndexMockRecorder struct { + mock *MockSectorIndex +} + +// NewMockSectorIndex creates a new mock instance. +func NewMockSectorIndex(ctrl *gomock.Controller) *MockSectorIndex { + mock := &MockSectorIndex{ctrl: ctrl} + mock.recorder = &MockSectorIndexMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSectorIndex) EXPECT() *MockSectorIndexMockRecorder { + return m.recorder +} + +// StorageAttach mocks base method. +func (m *MockSectorIndex) StorageAttach(arg0 context.Context, arg1 storiface.StorageInfo, arg2 fsutil.FsStat) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageAttach", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// StorageAttach indicates an expected call of StorageAttach. +func (mr *MockSectorIndexMockRecorder) StorageAttach(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageAttach", reflect.TypeOf((*MockSectorIndex)(nil).StorageAttach), arg0, arg1, arg2) +} + +// StorageBestAlloc mocks base method. +func (m *MockSectorIndex) StorageBestAlloc(arg0 context.Context, arg1 storiface.SectorFileType, arg2 abi.SectorSize, arg3 storiface.PathType, arg4 abi.ActorID) ([]storiface.StorageInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageBestAlloc", arg0, arg1, arg2, arg3, arg4) + ret0, _ := ret[0].([]storiface.StorageInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StorageBestAlloc indicates an expected call of StorageBestAlloc. +func (mr *MockSectorIndexMockRecorder) StorageBestAlloc(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageBestAlloc", reflect.TypeOf((*MockSectorIndex)(nil).StorageBestAlloc), arg0, arg1, arg2, arg3, arg4) +} + +// StorageDeclareSector mocks base method. +func (m *MockSectorIndex) StorageDeclareSector(arg0 context.Context, arg1 storiface.ID, arg2 abi.SectorID, arg3 storiface.SectorFileType, arg4 bool) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageDeclareSector", arg0, arg1, arg2, arg3, arg4) + ret0, _ := ret[0].(error) + return ret0 +} + +// StorageDeclareSector indicates an expected call of StorageDeclareSector. +func (mr *MockSectorIndexMockRecorder) StorageDeclareSector(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageDeclareSector", reflect.TypeOf((*MockSectorIndex)(nil).StorageDeclareSector), arg0, arg1, arg2, arg3, arg4) +} + +// StorageDetach mocks base method. +func (m *MockSectorIndex) StorageDetach(arg0 context.Context, arg1 storiface.ID, arg2 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageDetach", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// StorageDetach indicates an expected call of StorageDetach. +func (mr *MockSectorIndexMockRecorder) StorageDetach(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageDetach", reflect.TypeOf((*MockSectorIndex)(nil).StorageDetach), arg0, arg1, arg2) +} + +// StorageDropSector mocks base method. +func (m *MockSectorIndex) StorageDropSector(arg0 context.Context, arg1 storiface.ID, arg2 abi.SectorID, arg3 storiface.SectorFileType) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageDropSector", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(error) + return ret0 +} + +// StorageDropSector indicates an expected call of StorageDropSector. +func (mr *MockSectorIndexMockRecorder) StorageDropSector(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageDropSector", reflect.TypeOf((*MockSectorIndex)(nil).StorageDropSector), arg0, arg1, arg2, arg3) +} + +// StorageFindSector mocks base method. +func (m *MockSectorIndex) StorageFindSector(arg0 context.Context, arg1 abi.SectorID, arg2 storiface.SectorFileType, arg3 abi.SectorSize, arg4 bool) ([]storiface.SectorStorageInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageFindSector", arg0, arg1, arg2, arg3, arg4) + ret0, _ := ret[0].([]storiface.SectorStorageInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StorageFindSector indicates an expected call of StorageFindSector. +func (mr *MockSectorIndexMockRecorder) StorageFindSector(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageFindSector", reflect.TypeOf((*MockSectorIndex)(nil).StorageFindSector), arg0, arg1, arg2, arg3, arg4) +} + +// StorageGetLocks mocks base method. +func (m *MockSectorIndex) StorageGetLocks(arg0 context.Context) (storiface.SectorLocks, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageGetLocks", arg0) + ret0, _ := ret[0].(storiface.SectorLocks) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StorageGetLocks indicates an expected call of StorageGetLocks. +func (mr *MockSectorIndexMockRecorder) StorageGetLocks(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageGetLocks", reflect.TypeOf((*MockSectorIndex)(nil).StorageGetLocks), arg0) +} + +// StorageInfo mocks base method. +func (m *MockSectorIndex) StorageInfo(arg0 context.Context, arg1 storiface.ID) (storiface.StorageInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageInfo", arg0, arg1) + ret0, _ := ret[0].(storiface.StorageInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StorageInfo indicates an expected call of StorageInfo. +func (mr *MockSectorIndexMockRecorder) StorageInfo(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageInfo", reflect.TypeOf((*MockSectorIndex)(nil).StorageInfo), arg0, arg1) +} + +// StorageList mocks base method. +func (m *MockSectorIndex) StorageList(arg0 context.Context) (map[storiface.ID][]storiface.Decl, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageList", arg0) + ret0, _ := ret[0].(map[storiface.ID][]storiface.Decl) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StorageList indicates an expected call of StorageList. +func (mr *MockSectorIndexMockRecorder) StorageList(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageList", reflect.TypeOf((*MockSectorIndex)(nil).StorageList), arg0) +} + +// StorageLock mocks base method. +func (m *MockSectorIndex) StorageLock(arg0 context.Context, arg1 abi.SectorID, arg2, arg3 storiface.SectorFileType) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageLock", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(error) + return ret0 +} + +// StorageLock indicates an expected call of StorageLock. +func (mr *MockSectorIndexMockRecorder) StorageLock(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageLock", reflect.TypeOf((*MockSectorIndex)(nil).StorageLock), arg0, arg1, arg2, arg3) +} + +// StorageReportHealth mocks base method. +func (m *MockSectorIndex) StorageReportHealth(arg0 context.Context, arg1 storiface.ID, arg2 storiface.HealthReport) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageReportHealth", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// StorageReportHealth indicates an expected call of StorageReportHealth. +func (mr *MockSectorIndexMockRecorder) StorageReportHealth(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageReportHealth", reflect.TypeOf((*MockSectorIndex)(nil).StorageReportHealth), arg0, arg1, arg2) +} + +// StorageTryLock mocks base method. +func (m *MockSectorIndex) StorageTryLock(arg0 context.Context, arg1 abi.SectorID, arg2, arg3 storiface.SectorFileType) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StorageTryLock", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StorageTryLock indicates an expected call of StorageTryLock. +func (mr *MockSectorIndexMockRecorder) StorageTryLock(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageTryLock", reflect.TypeOf((*MockSectorIndex)(nil).StorageTryLock), arg0, arg1, arg2, arg3) +} + +// MockPartialFileHandler is a mock of PartialFileHandler interface. +type MockPartialFileHandler struct { + ctrl *gomock.Controller + recorder *MockPartialFileHandlerMockRecorder +} + +// MockPartialFileHandlerMockRecorder is the mock recorder for MockPartialFileHandler. +type MockPartialFileHandlerMockRecorder struct { + mock *MockPartialFileHandler +} + +// NewMockPartialFileHandler creates a new mock instance. +func NewMockPartialFileHandler(ctrl *gomock.Controller) *MockPartialFileHandler { + mock := &MockPartialFileHandler{ctrl: ctrl} + mock.recorder = &MockPartialFileHandlerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockPartialFileHandler) EXPECT() *MockPartialFileHandlerMockRecorder { + return m.recorder +} + +// Close mocks base method. +func (m *MockPartialFileHandler) Close(arg0 *partialfile.PartialFile) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockPartialFileHandlerMockRecorder) Close(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockPartialFileHandler)(nil).Close), arg0) +} + +// HasAllocated mocks base method. +func (m *MockPartialFileHandler) HasAllocated(arg0 *partialfile.PartialFile, arg1 storiface.UnpaddedByteIndex, arg2 abi.UnpaddedPieceSize) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasAllocated", arg0, arg1, arg2) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// HasAllocated indicates an expected call of HasAllocated. +func (mr *MockPartialFileHandlerMockRecorder) HasAllocated(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasAllocated", reflect.TypeOf((*MockPartialFileHandler)(nil).HasAllocated), arg0, arg1, arg2) +} + +// OpenPartialFile mocks base method. +func (m *MockPartialFileHandler) OpenPartialFile(arg0 abi.PaddedPieceSize, arg1 string) (*partialfile.PartialFile, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "OpenPartialFile", arg0, arg1) + ret0, _ := ret[0].(*partialfile.PartialFile) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// OpenPartialFile indicates an expected call of OpenPartialFile. +func (mr *MockPartialFileHandlerMockRecorder) OpenPartialFile(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenPartialFile", reflect.TypeOf((*MockPartialFileHandler)(nil).OpenPartialFile), arg0, arg1) +} + +// Reader mocks base method. +func (m *MockPartialFileHandler) Reader(arg0 *partialfile.PartialFile, arg1 storiface.PaddedByteIndex, arg2 abi.PaddedPieceSize) (io.Reader, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Reader", arg0, arg1, arg2) + ret0, _ := ret[0].(io.Reader) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Reader indicates an expected call of Reader. +func (mr *MockPartialFileHandlerMockRecorder) Reader(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reader", reflect.TypeOf((*MockPartialFileHandler)(nil).Reader), arg0, arg1, arg2) +} + +// MockStore is a mock of Store interface. +type MockStore struct { + ctrl *gomock.Controller + recorder *MockStoreMockRecorder +} + +// MockStoreMockRecorder is the mock recorder for MockStore. +type MockStoreMockRecorder struct { + mock *MockStore +} + +// NewMockStore creates a new mock instance. +func NewMockStore(ctrl *gomock.Controller) *MockStore { + mock := &MockStore{ctrl: ctrl} + mock.recorder = &MockStoreMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockStore) EXPECT() *MockStoreMockRecorder { + return m.recorder +} + +// AcquireSector mocks base method. +func (m *MockStore) AcquireSector(arg0 context.Context, arg1 storiface.SectorRef, arg2, arg3 storiface.SectorFileType, arg4 storiface.PathType, arg5 storiface.AcquireMode, arg6 ...storiface.AcquireOption) (storiface.SectorPaths, storiface.SectorPaths, error) { + m.ctrl.T.Helper() + varargs := []interface{}{arg0, arg1, arg2, arg3, arg4, arg5} + for _, a := range arg6 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "AcquireSector", varargs...) + ret0, _ := ret[0].(storiface.SectorPaths) + ret1, _ := ret[1].(storiface.SectorPaths) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// AcquireSector indicates an expected call of AcquireSector. +func (mr *MockStoreMockRecorder) AcquireSector(arg0, arg1, arg2, arg3, arg4, arg5 interface{}, arg6 ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5}, arg6...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcquireSector", reflect.TypeOf((*MockStore)(nil).AcquireSector), varargs...) +} + +// FsStat mocks base method. +func (m *MockStore) FsStat(arg0 context.Context, arg1 storiface.ID) (fsutil.FsStat, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FsStat", arg0, arg1) + ret0, _ := ret[0].(fsutil.FsStat) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FsStat indicates an expected call of FsStat. +func (mr *MockStoreMockRecorder) FsStat(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FsStat", reflect.TypeOf((*MockStore)(nil).FsStat), arg0, arg1) +} + +// GeneratePoRepVanillaProof mocks base method. +func (m *MockStore) GeneratePoRepVanillaProof(arg0 context.Context, arg1 storiface.SectorRef, arg2, arg3 cid.Cid, arg4 abi.SealRandomness, arg5 abi.InteractiveSealRandomness) ([]byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GeneratePoRepVanillaProof", arg0, arg1, arg2, arg3, arg4, arg5) + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GeneratePoRepVanillaProof indicates an expected call of GeneratePoRepVanillaProof. +func (mr *MockStoreMockRecorder) GeneratePoRepVanillaProof(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GeneratePoRepVanillaProof", reflect.TypeOf((*MockStore)(nil).GeneratePoRepVanillaProof), arg0, arg1, arg2, arg3, arg4, arg5) +} + +// GenerateSingleVanillaProof mocks base method. +func (m *MockStore) GenerateSingleVanillaProof(arg0 context.Context, arg1 abi.ActorID, arg2 storiface.PostSectorChallenge, arg3 abi.RegisteredPoStProof) ([]byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GenerateSingleVanillaProof", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GenerateSingleVanillaProof indicates an expected call of GenerateSingleVanillaProof. +func (mr *MockStoreMockRecorder) GenerateSingleVanillaProof(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenerateSingleVanillaProof", reflect.TypeOf((*MockStore)(nil).GenerateSingleVanillaProof), arg0, arg1, arg2, arg3) +} + +// MoveStorage mocks base method. +func (m *MockStore) MoveStorage(arg0 context.Context, arg1 storiface.SectorRef, arg2 storiface.SectorFileType, arg3 ...storiface.AcquireOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{arg0, arg1, arg2} + for _, a := range arg3 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "MoveStorage", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// MoveStorage indicates an expected call of MoveStorage. +func (mr *MockStoreMockRecorder) MoveStorage(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MoveStorage", reflect.TypeOf((*MockStore)(nil).MoveStorage), varargs...) +} + +// Remove mocks base method. +func (m *MockStore) Remove(arg0 context.Context, arg1 abi.SectorID, arg2 storiface.SectorFileType, arg3 bool, arg4 []storiface.ID) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Remove", arg0, arg1, arg2, arg3, arg4) + ret0, _ := ret[0].(error) + return ret0 +} + +// Remove indicates an expected call of Remove. +func (mr *MockStoreMockRecorder) Remove(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockStore)(nil).Remove), arg0, arg1, arg2, arg3, arg4) +} + +// RemoveCopies mocks base method. +func (m *MockStore) RemoveCopies(arg0 context.Context, arg1 abi.SectorID, arg2 storiface.SectorFileType) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveCopies", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// RemoveCopies indicates an expected call of RemoveCopies. +func (mr *MockStoreMockRecorder) RemoveCopies(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveCopies", reflect.TypeOf((*MockStore)(nil).RemoveCopies), arg0, arg1, arg2) +} + +// Reserve mocks base method. +func (m *MockStore) Reserve(arg0 context.Context, arg1 storiface.SectorRef, arg2 storiface.SectorFileType, arg3 storiface.SectorPaths, arg4 map[storiface.SectorFileType]int, arg5 float64) (func(), error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Reserve", arg0, arg1, arg2, arg3, arg4, arg5) + ret0, _ := ret[0].(func()) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Reserve indicates an expected call of Reserve. +func (mr *MockStoreMockRecorder) Reserve(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reserve", reflect.TypeOf((*MockStore)(nil).Reserve), arg0, arg1, arg2, arg3, arg4, arg5) +} diff --git a/storage/paths/mocks/pf.go b/storage/paths/mocks/pf.go deleted file mode 100644 index 43b3bc4896b..00000000000 --- a/storage/paths/mocks/pf.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/filecoin-project/lotus/storage/paths (interfaces: PartialFileHandler) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - io "io" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" - - abi "github.com/filecoin-project/go-state-types/abi" - - partialfile "github.com/filecoin-project/lotus/storage/sealer/partialfile" - storiface "github.com/filecoin-project/lotus/storage/sealer/storiface" -) - -// MockPartialFileHandler is a mock of PartialFileHandler interface. -type MockPartialFileHandler struct { - ctrl *gomock.Controller - recorder *MockPartialFileHandlerMockRecorder -} - -// MockPartialFileHandlerMockRecorder is the mock recorder for MockPartialFileHandler. -type MockPartialFileHandlerMockRecorder struct { - mock *MockPartialFileHandler -} - -// NewMockPartialFileHandler creates a new mock instance. -func NewMockPartialFileHandler(ctrl *gomock.Controller) *MockPartialFileHandler { - mock := &MockPartialFileHandler{ctrl: ctrl} - mock.recorder = &MockPartialFileHandlerMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockPartialFileHandler) EXPECT() *MockPartialFileHandlerMockRecorder { - return m.recorder -} - -// Close mocks base method. -func (m *MockPartialFileHandler) Close(arg0 *partialfile.PartialFile) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Close", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Close indicates an expected call of Close. -func (mr *MockPartialFileHandlerMockRecorder) Close(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockPartialFileHandler)(nil).Close), arg0) -} - -// HasAllocated mocks base method. -func (m *MockPartialFileHandler) HasAllocated(arg0 *partialfile.PartialFile, arg1 storiface.UnpaddedByteIndex, arg2 abi.UnpaddedPieceSize) (bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasAllocated", arg0, arg1, arg2) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// HasAllocated indicates an expected call of HasAllocated. -func (mr *MockPartialFileHandlerMockRecorder) HasAllocated(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasAllocated", reflect.TypeOf((*MockPartialFileHandler)(nil).HasAllocated), arg0, arg1, arg2) -} - -// OpenPartialFile mocks base method. -func (m *MockPartialFileHandler) OpenPartialFile(arg0 abi.PaddedPieceSize, arg1 string) (*partialfile.PartialFile, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OpenPartialFile", arg0, arg1) - ret0, _ := ret[0].(*partialfile.PartialFile) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// OpenPartialFile indicates an expected call of OpenPartialFile. -func (mr *MockPartialFileHandlerMockRecorder) OpenPartialFile(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenPartialFile", reflect.TypeOf((*MockPartialFileHandler)(nil).OpenPartialFile), arg0, arg1) -} - -// Reader mocks base method. -func (m *MockPartialFileHandler) Reader(arg0 *partialfile.PartialFile, arg1 storiface.PaddedByteIndex, arg2 abi.PaddedPieceSize) (io.Reader, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Reader", arg0, arg1, arg2) - ret0, _ := ret[0].(io.Reader) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Reader indicates an expected call of Reader. -func (mr *MockPartialFileHandlerMockRecorder) Reader(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reader", reflect.TypeOf((*MockPartialFileHandler)(nil).Reader), arg0, arg1, arg2) -} diff --git a/storage/paths/mocks/store.go b/storage/paths/mocks/store.go deleted file mode 100644 index 1303cf0690b..00000000000 --- a/storage/paths/mocks/store.go +++ /dev/null @@ -1,169 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/filecoin-project/lotus/storage/paths (interfaces: Store) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" - cid "github.com/ipfs/go-cid" - - abi "github.com/filecoin-project/go-state-types/abi" - - fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" - storiface "github.com/filecoin-project/lotus/storage/sealer/storiface" -) - -// MockStore is a mock of Store interface. -type MockStore struct { - ctrl *gomock.Controller - recorder *MockStoreMockRecorder -} - -// MockStoreMockRecorder is the mock recorder for MockStore. -type MockStoreMockRecorder struct { - mock *MockStore -} - -// NewMockStore creates a new mock instance. -func NewMockStore(ctrl *gomock.Controller) *MockStore { - mock := &MockStore{ctrl: ctrl} - mock.recorder = &MockStoreMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockStore) EXPECT() *MockStoreMockRecorder { - return m.recorder -} - -// AcquireSector mocks base method. -func (m *MockStore) AcquireSector(arg0 context.Context, arg1 storiface.SectorRef, arg2, arg3 storiface.SectorFileType, arg4 storiface.PathType, arg5 storiface.AcquireMode, arg6 ...storiface.AcquireOption) (storiface.SectorPaths, storiface.SectorPaths, error) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1, arg2, arg3, arg4, arg5} - for _, a := range arg6 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "AcquireSector", varargs...) - ret0, _ := ret[0].(storiface.SectorPaths) - ret1, _ := ret[1].(storiface.SectorPaths) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// AcquireSector indicates an expected call of AcquireSector. -func (mr *MockStoreMockRecorder) AcquireSector(arg0, arg1, arg2, arg3, arg4, arg5 interface{}, arg6 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1, arg2, arg3, arg4, arg5}, arg6...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcquireSector", reflect.TypeOf((*MockStore)(nil).AcquireSector), varargs...) -} - -// FsStat mocks base method. -func (m *MockStore) FsStat(arg0 context.Context, arg1 storiface.ID) (fsutil.FsStat, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FsStat", arg0, arg1) - ret0, _ := ret[0].(fsutil.FsStat) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// FsStat indicates an expected call of FsStat. -func (mr *MockStoreMockRecorder) FsStat(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FsStat", reflect.TypeOf((*MockStore)(nil).FsStat), arg0, arg1) -} - -// GeneratePoRepVanillaProof mocks base method. -func (m *MockStore) GeneratePoRepVanillaProof(arg0 context.Context, arg1 storiface.SectorRef, arg2, arg3 cid.Cid, arg4 abi.SealRandomness, arg5 abi.InteractiveSealRandomness) ([]byte, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GeneratePoRepVanillaProof", arg0, arg1, arg2, arg3, arg4, arg5) - ret0, _ := ret[0].([]byte) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GeneratePoRepVanillaProof indicates an expected call of GeneratePoRepVanillaProof. -func (mr *MockStoreMockRecorder) GeneratePoRepVanillaProof(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GeneratePoRepVanillaProof", reflect.TypeOf((*MockStore)(nil).GeneratePoRepVanillaProof), arg0, arg1, arg2, arg3, arg4, arg5) -} - -// GenerateSingleVanillaProof mocks base method. -func (m *MockStore) GenerateSingleVanillaProof(arg0 context.Context, arg1 abi.ActorID, arg2 storiface.PostSectorChallenge, arg3 abi.RegisteredPoStProof) ([]byte, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GenerateSingleVanillaProof", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].([]byte) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GenerateSingleVanillaProof indicates an expected call of GenerateSingleVanillaProof. -func (mr *MockStoreMockRecorder) GenerateSingleVanillaProof(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenerateSingleVanillaProof", reflect.TypeOf((*MockStore)(nil).GenerateSingleVanillaProof), arg0, arg1, arg2, arg3) -} - -// MoveStorage mocks base method. -func (m *MockStore) MoveStorage(arg0 context.Context, arg1 storiface.SectorRef, arg2 storiface.SectorFileType, arg3 ...storiface.AcquireOption) error { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1, arg2} - for _, a := range arg3 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "MoveStorage", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// MoveStorage indicates an expected call of MoveStorage. -func (mr *MockStoreMockRecorder) MoveStorage(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MoveStorage", reflect.TypeOf((*MockStore)(nil).MoveStorage), varargs...) -} - -// Remove mocks base method. -func (m *MockStore) Remove(arg0 context.Context, arg1 abi.SectorID, arg2 storiface.SectorFileType, arg3 bool, arg4 []storiface.ID) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Remove", arg0, arg1, arg2, arg3, arg4) - ret0, _ := ret[0].(error) - return ret0 -} - -// Remove indicates an expected call of Remove. -func (mr *MockStoreMockRecorder) Remove(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockStore)(nil).Remove), arg0, arg1, arg2, arg3, arg4) -} - -// RemoveCopies mocks base method. -func (m *MockStore) RemoveCopies(arg0 context.Context, arg1 abi.SectorID, arg2 storiface.SectorFileType) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RemoveCopies", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// RemoveCopies indicates an expected call of RemoveCopies. -func (mr *MockStoreMockRecorder) RemoveCopies(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveCopies", reflect.TypeOf((*MockStore)(nil).RemoveCopies), arg0, arg1, arg2) -} - -// Reserve mocks base method. -func (m *MockStore) Reserve(arg0 context.Context, arg1 storiface.SectorRef, arg2 storiface.SectorFileType, arg3 storiface.SectorPaths, arg4 map[storiface.SectorFileType]int, arg5 float64) (func(), error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Reserve", arg0, arg1, arg2, arg3, arg4, arg5) - ret0, _ := ret[0].(func()) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Reserve indicates an expected call of Reserve. -func (mr *MockStoreMockRecorder) Reserve(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reserve", reflect.TypeOf((*MockStore)(nil).Reserve), arg0, arg1, arg2, arg3, arg4, arg5) -} diff --git a/storage/paths/mocks_gen.go b/storage/paths/mocks_gen.go new file mode 100644 index 00000000000..a634b1958db --- /dev/null +++ b/storage/paths/mocks_gen.go @@ -0,0 +1,3 @@ +package paths + +//go:generate go run github.com/golang/mock/mockgen -destination=mocks/mocks.go -package=mocks . SectorIndex,PartialFileHandler,Store diff --git a/storage/pipeline/commit_batch.go b/storage/pipeline/commit_batch.go index d14b7c00b6d..6d752cfe7ad 100644 --- a/storage/pipeline/commit_batch.go +++ b/storage/pipeline/commit_batch.go @@ -33,8 +33,6 @@ import ( var aggFeeNum = big.NewInt(110) var aggFeeDen = big.NewInt(100) -//go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_commit_batcher.go -package=mocks . CommitBatcherApi - type CommitBatcherApi interface { MpoolPushMessage(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error) GasEstimateMessageGas(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error) diff --git a/storage/pipeline/fsm.go b/storage/pipeline/fsm.go index ced6867d198..55913b27994 100644 --- a/storage/pipeline/fsm.go +++ b/storage/pipeline/fsm.go @@ -1,5 +1,3 @@ -//go:generate go run ./gen - package sealing import ( diff --git a/storage/pipeline/gen/main.go b/storage/pipeline/gen/main.go deleted file mode 100644 index 578c81478d6..00000000000 --- a/storage/pipeline/gen/main.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -import ( - "fmt" - "os" - - gen "github.com/whyrusleeping/cbor-gen" - - sealing "github.com/filecoin-project/lotus/storage/pipeline" -) - -func main() { - err := gen.WriteMapEncodersToFile("./cbor_gen.go", "sealing", - sealing.SectorInfo{}, - sealing.Log{}, - ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } -} diff --git a/storage/pipeline/mocks/mock_commit_batcher.go b/storage/pipeline/mocks/mock_commit_batcher.go deleted file mode 100644 index aad1c332fb9..00000000000 --- a/storage/pipeline/mocks/mock_commit_batcher.go +++ /dev/null @@ -1,225 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/filecoin-project/lotus/storage/pipeline (interfaces: CommitBatcherApi) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" - - address "github.com/filecoin-project/go-address" - abi "github.com/filecoin-project/go-state-types/abi" - big "github.com/filecoin-project/go-state-types/big" - miner "github.com/filecoin-project/go-state-types/builtin/v9/miner" - verifreg "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" - network "github.com/filecoin-project/go-state-types/network" - - api "github.com/filecoin-project/lotus/api" - types "github.com/filecoin-project/lotus/chain/types" -) - -// MockCommitBatcherApi is a mock of CommitBatcherApi interface. -type MockCommitBatcherApi struct { - ctrl *gomock.Controller - recorder *MockCommitBatcherApiMockRecorder -} - -// MockCommitBatcherApiMockRecorder is the mock recorder for MockCommitBatcherApi. -type MockCommitBatcherApiMockRecorder struct { - mock *MockCommitBatcherApi -} - -// NewMockCommitBatcherApi creates a new mock instance. -func NewMockCommitBatcherApi(ctrl *gomock.Controller) *MockCommitBatcherApi { - mock := &MockCommitBatcherApi{ctrl: ctrl} - mock.recorder = &MockCommitBatcherApiMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockCommitBatcherApi) EXPECT() *MockCommitBatcherApiMockRecorder { - return m.recorder -} - -// ChainHead mocks base method. -func (m *MockCommitBatcherApi) ChainHead(arg0 context.Context) (*types.TipSet, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ChainHead", arg0) - ret0, _ := ret[0].(*types.TipSet) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ChainHead indicates an expected call of ChainHead. -func (mr *MockCommitBatcherApiMockRecorder) ChainHead(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainHead", reflect.TypeOf((*MockCommitBatcherApi)(nil).ChainHead), arg0) -} - -// GasEstimateMessageGas mocks base method. -func (m *MockCommitBatcherApi) GasEstimateMessageGas(arg0 context.Context, arg1 *types.Message, arg2 *api.MessageSendSpec, arg3 types.TipSetKey) (*types.Message, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GasEstimateMessageGas", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*types.Message) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GasEstimateMessageGas indicates an expected call of GasEstimateMessageGas. -func (mr *MockCommitBatcherApiMockRecorder) GasEstimateMessageGas(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GasEstimateMessageGas", reflect.TypeOf((*MockCommitBatcherApi)(nil).GasEstimateMessageGas), arg0, arg1, arg2, arg3) -} - -// MpoolPushMessage mocks base method. -func (m *MockCommitBatcherApi) MpoolPushMessage(arg0 context.Context, arg1 *types.Message, arg2 *api.MessageSendSpec) (*types.SignedMessage, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MpoolPushMessage", arg0, arg1, arg2) - ret0, _ := ret[0].(*types.SignedMessage) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// MpoolPushMessage indicates an expected call of MpoolPushMessage. -func (mr *MockCommitBatcherApiMockRecorder) MpoolPushMessage(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MpoolPushMessage", reflect.TypeOf((*MockCommitBatcherApi)(nil).MpoolPushMessage), arg0, arg1, arg2) -} - -// StateAccountKey mocks base method. -func (m *MockCommitBatcherApi) StateAccountKey(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (address.Address, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateAccountKey", arg0, arg1, arg2) - ret0, _ := ret[0].(address.Address) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateAccountKey indicates an expected call of StateAccountKey. -func (mr *MockCommitBatcherApiMockRecorder) StateAccountKey(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateAccountKey", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateAccountKey), arg0, arg1, arg2) -} - -// StateGetAllocation mocks base method. -func (m *MockCommitBatcherApi) StateGetAllocation(arg0 context.Context, arg1 address.Address, arg2 verifreg.AllocationId, arg3 types.TipSetKey) (*verifreg.Allocation, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateGetAllocation", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*verifreg.Allocation) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateGetAllocation indicates an expected call of StateGetAllocation. -func (mr *MockCommitBatcherApiMockRecorder) StateGetAllocation(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocation", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateGetAllocation), arg0, arg1, arg2, arg3) -} - -// StateLookupID mocks base method. -func (m *MockCommitBatcherApi) StateLookupID(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (address.Address, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateLookupID", arg0, arg1, arg2) - ret0, _ := ret[0].(address.Address) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateLookupID indicates an expected call of StateLookupID. -func (mr *MockCommitBatcherApiMockRecorder) StateLookupID(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateLookupID", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateLookupID), arg0, arg1, arg2) -} - -// StateMinerAvailableBalance mocks base method. -func (m *MockCommitBatcherApi) StateMinerAvailableBalance(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (big.Int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateMinerAvailableBalance", arg0, arg1, arg2) - ret0, _ := ret[0].(big.Int) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateMinerAvailableBalance indicates an expected call of StateMinerAvailableBalance. -func (mr *MockCommitBatcherApiMockRecorder) StateMinerAvailableBalance(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerAvailableBalance", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateMinerAvailableBalance), arg0, arg1, arg2) -} - -// StateMinerInfo mocks base method. -func (m *MockCommitBatcherApi) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (api.MinerInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2) - ret0, _ := ret[0].(api.MinerInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateMinerInfo indicates an expected call of StateMinerInfo. -func (mr *MockCommitBatcherApiMockRecorder) StateMinerInfo(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerInfo", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateMinerInfo), arg0, arg1, arg2) -} - -// StateNetworkVersion mocks base method. -func (m *MockCommitBatcherApi) StateNetworkVersion(arg0 context.Context, arg1 types.TipSetKey) (network.Version, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateNetworkVersion", arg0, arg1) - ret0, _ := ret[0].(network.Version) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateNetworkVersion indicates an expected call of StateNetworkVersion. -func (mr *MockCommitBatcherApiMockRecorder) StateNetworkVersion(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateNetworkVersion", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateNetworkVersion), arg0, arg1) -} - -// StateSectorPreCommitInfo mocks base method. -func (m *MockCommitBatcherApi) StateSectorPreCommitInfo(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateSectorPreCommitInfo", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*miner.SectorPreCommitOnChainInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateSectorPreCommitInfo indicates an expected call of StateSectorPreCommitInfo. -func (mr *MockCommitBatcherApiMockRecorder) StateSectorPreCommitInfo(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateSectorPreCommitInfo", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateSectorPreCommitInfo), arg0, arg1, arg2, arg3) -} - -// WalletBalance mocks base method. -func (m *MockCommitBatcherApi) WalletBalance(arg0 context.Context, arg1 address.Address) (big.Int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WalletBalance", arg0, arg1) - ret0, _ := ret[0].(big.Int) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WalletBalance indicates an expected call of WalletBalance. -func (mr *MockCommitBatcherApiMockRecorder) WalletBalance(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WalletBalance", reflect.TypeOf((*MockCommitBatcherApi)(nil).WalletBalance), arg0, arg1) -} - -// WalletHas mocks base method. -func (m *MockCommitBatcherApi) WalletHas(arg0 context.Context, arg1 address.Address) (bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WalletHas", arg0, arg1) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WalletHas indicates an expected call of WalletHas. -func (mr *MockCommitBatcherApiMockRecorder) WalletHas(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WalletHas", reflect.TypeOf((*MockCommitBatcherApi)(nil).WalletHas), arg0, arg1) -} diff --git a/storage/pipeline/mocks/mock_precommit_batcher.go b/storage/pipeline/mocks/mock_precommit_batcher.go deleted file mode 100644 index fd46f601b77..00000000000 --- a/storage/pipeline/mocks/mock_precommit_batcher.go +++ /dev/null @@ -1,224 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/filecoin-project/lotus/storage/pipeline (interfaces: PreCommitBatcherApi) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" - - address "github.com/filecoin-project/go-address" - abi "github.com/filecoin-project/go-state-types/abi" - big "github.com/filecoin-project/go-state-types/big" - verifreg "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" - network "github.com/filecoin-project/go-state-types/network" - - api "github.com/filecoin-project/lotus/api" - types "github.com/filecoin-project/lotus/chain/types" -) - -// MockPreCommitBatcherApi is a mock of PreCommitBatcherApi interface. -type MockPreCommitBatcherApi struct { - ctrl *gomock.Controller - recorder *MockPreCommitBatcherApiMockRecorder -} - -// MockPreCommitBatcherApiMockRecorder is the mock recorder for MockPreCommitBatcherApi. -type MockPreCommitBatcherApiMockRecorder struct { - mock *MockPreCommitBatcherApi -} - -// NewMockPreCommitBatcherApi creates a new mock instance. -func NewMockPreCommitBatcherApi(ctrl *gomock.Controller) *MockPreCommitBatcherApi { - mock := &MockPreCommitBatcherApi{ctrl: ctrl} - mock.recorder = &MockPreCommitBatcherApiMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockPreCommitBatcherApi) EXPECT() *MockPreCommitBatcherApiMockRecorder { - return m.recorder -} - -// ChainHead mocks base method. -func (m *MockPreCommitBatcherApi) ChainHead(arg0 context.Context) (*types.TipSet, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ChainHead", arg0) - ret0, _ := ret[0].(*types.TipSet) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ChainHead indicates an expected call of ChainHead. -func (mr *MockPreCommitBatcherApiMockRecorder) ChainHead(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainHead", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).ChainHead), arg0) -} - -// GasEstimateMessageGas mocks base method. -func (m *MockPreCommitBatcherApi) GasEstimateMessageGas(arg0 context.Context, arg1 *types.Message, arg2 *api.MessageSendSpec, arg3 types.TipSetKey) (*types.Message, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GasEstimateMessageGas", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*types.Message) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GasEstimateMessageGas indicates an expected call of GasEstimateMessageGas. -func (mr *MockPreCommitBatcherApiMockRecorder) GasEstimateMessageGas(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GasEstimateMessageGas", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).GasEstimateMessageGas), arg0, arg1, arg2, arg3) -} - -// MpoolPushMessage mocks base method. -func (m *MockPreCommitBatcherApi) MpoolPushMessage(arg0 context.Context, arg1 *types.Message, arg2 *api.MessageSendSpec) (*types.SignedMessage, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MpoolPushMessage", arg0, arg1, arg2) - ret0, _ := ret[0].(*types.SignedMessage) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// MpoolPushMessage indicates an expected call of MpoolPushMessage. -func (mr *MockPreCommitBatcherApiMockRecorder) MpoolPushMessage(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MpoolPushMessage", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).MpoolPushMessage), arg0, arg1, arg2) -} - -// StateAccountKey mocks base method. -func (m *MockPreCommitBatcherApi) StateAccountKey(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (address.Address, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateAccountKey", arg0, arg1, arg2) - ret0, _ := ret[0].(address.Address) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateAccountKey indicates an expected call of StateAccountKey. -func (mr *MockPreCommitBatcherApiMockRecorder) StateAccountKey(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateAccountKey", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateAccountKey), arg0, arg1, arg2) -} - -// StateGetAllocation mocks base method. -func (m *MockPreCommitBatcherApi) StateGetAllocation(arg0 context.Context, arg1 address.Address, arg2 verifreg.AllocationId, arg3 types.TipSetKey) (*verifreg.Allocation, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateGetAllocation", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*verifreg.Allocation) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateGetAllocation indicates an expected call of StateGetAllocation. -func (mr *MockPreCommitBatcherApiMockRecorder) StateGetAllocation(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocation", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateGetAllocation), arg0, arg1, arg2, arg3) -} - -// StateGetAllocationForPendingDeal mocks base method. -func (m *MockPreCommitBatcherApi) StateGetAllocationForPendingDeal(arg0 context.Context, arg1 abi.DealID, arg2 types.TipSetKey) (*verifreg.Allocation, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateGetAllocationForPendingDeal", arg0, arg1, arg2) - ret0, _ := ret[0].(*verifreg.Allocation) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateGetAllocationForPendingDeal indicates an expected call of StateGetAllocationForPendingDeal. -func (mr *MockPreCommitBatcherApiMockRecorder) StateGetAllocationForPendingDeal(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocationForPendingDeal", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateGetAllocationForPendingDeal), arg0, arg1, arg2) -} - -// StateLookupID mocks base method. -func (m *MockPreCommitBatcherApi) StateLookupID(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (address.Address, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateLookupID", arg0, arg1, arg2) - ret0, _ := ret[0].(address.Address) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateLookupID indicates an expected call of StateLookupID. -func (mr *MockPreCommitBatcherApiMockRecorder) StateLookupID(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateLookupID", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateLookupID), arg0, arg1, arg2) -} - -// StateMinerAvailableBalance mocks base method. -func (m *MockPreCommitBatcherApi) StateMinerAvailableBalance(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (big.Int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateMinerAvailableBalance", arg0, arg1, arg2) - ret0, _ := ret[0].(big.Int) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateMinerAvailableBalance indicates an expected call of StateMinerAvailableBalance. -func (mr *MockPreCommitBatcherApiMockRecorder) StateMinerAvailableBalance(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerAvailableBalance", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateMinerAvailableBalance), arg0, arg1, arg2) -} - -// StateMinerInfo mocks base method. -func (m *MockPreCommitBatcherApi) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (api.MinerInfo, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2) - ret0, _ := ret[0].(api.MinerInfo) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateMinerInfo indicates an expected call of StateMinerInfo. -func (mr *MockPreCommitBatcherApiMockRecorder) StateMinerInfo(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerInfo", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateMinerInfo), arg0, arg1, arg2) -} - -// StateNetworkVersion mocks base method. -func (m *MockPreCommitBatcherApi) StateNetworkVersion(arg0 context.Context, arg1 types.TipSetKey) (network.Version, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateNetworkVersion", arg0, arg1) - ret0, _ := ret[0].(network.Version) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateNetworkVersion indicates an expected call of StateNetworkVersion. -func (mr *MockPreCommitBatcherApiMockRecorder) StateNetworkVersion(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateNetworkVersion", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateNetworkVersion), arg0, arg1) -} - -// WalletBalance mocks base method. -func (m *MockPreCommitBatcherApi) WalletBalance(arg0 context.Context, arg1 address.Address) (big.Int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WalletBalance", arg0, arg1) - ret0, _ := ret[0].(big.Int) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WalletBalance indicates an expected call of WalletBalance. -func (mr *MockPreCommitBatcherApiMockRecorder) WalletBalance(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WalletBalance", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).WalletBalance), arg0, arg1) -} - -// WalletHas mocks base method. -func (m *MockPreCommitBatcherApi) WalletHas(arg0 context.Context, arg1 address.Address) (bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WalletHas", arg0, arg1) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WalletHas indicates an expected call of WalletHas. -func (mr *MockPreCommitBatcherApiMockRecorder) WalletHas(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WalletHas", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).WalletHas), arg0, arg1) -} diff --git a/storage/pipeline/mocks/api.go b/storage/pipeline/mocks/mocks.go similarity index 56% rename from storage/pipeline/mocks/api.go rename to storage/pipeline/mocks/mocks.go index 3990f1a2fd3..b6be57f208e 100644 --- a/storage/pipeline/mocks/api.go +++ b/storage/pipeline/mocks/mocks.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/filecoin-project/lotus/storage/pipeline (interfaces: SealingAPI) +// Source: github.com/filecoin-project/lotus/storage/pipeline (interfaces: CommitBatcherApi,PreCommitBatcherApi,SealingAPI,Context) // Package mocks is a generated GoMock package. package mocks @@ -28,6 +28,412 @@ import ( types "github.com/filecoin-project/lotus/chain/types" ) +// MockCommitBatcherApi is a mock of CommitBatcherApi interface. +type MockCommitBatcherApi struct { + ctrl *gomock.Controller + recorder *MockCommitBatcherApiMockRecorder +} + +// MockCommitBatcherApiMockRecorder is the mock recorder for MockCommitBatcherApi. +type MockCommitBatcherApiMockRecorder struct { + mock *MockCommitBatcherApi +} + +// NewMockCommitBatcherApi creates a new mock instance. +func NewMockCommitBatcherApi(ctrl *gomock.Controller) *MockCommitBatcherApi { + mock := &MockCommitBatcherApi{ctrl: ctrl} + mock.recorder = &MockCommitBatcherApiMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockCommitBatcherApi) EXPECT() *MockCommitBatcherApiMockRecorder { + return m.recorder +} + +// ChainHead mocks base method. +func (m *MockCommitBatcherApi) ChainHead(arg0 context.Context) (*types.TipSet, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ChainHead", arg0) + ret0, _ := ret[0].(*types.TipSet) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ChainHead indicates an expected call of ChainHead. +func (mr *MockCommitBatcherApiMockRecorder) ChainHead(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainHead", reflect.TypeOf((*MockCommitBatcherApi)(nil).ChainHead), arg0) +} + +// GasEstimateMessageGas mocks base method. +func (m *MockCommitBatcherApi) GasEstimateMessageGas(arg0 context.Context, arg1 *types.Message, arg2 *api.MessageSendSpec, arg3 types.TipSetKey) (*types.Message, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GasEstimateMessageGas", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(*types.Message) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GasEstimateMessageGas indicates an expected call of GasEstimateMessageGas. +func (mr *MockCommitBatcherApiMockRecorder) GasEstimateMessageGas(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GasEstimateMessageGas", reflect.TypeOf((*MockCommitBatcherApi)(nil).GasEstimateMessageGas), arg0, arg1, arg2, arg3) +} + +// MpoolPushMessage mocks base method. +func (m *MockCommitBatcherApi) MpoolPushMessage(arg0 context.Context, arg1 *types.Message, arg2 *api.MessageSendSpec) (*types.SignedMessage, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MpoolPushMessage", arg0, arg1, arg2) + ret0, _ := ret[0].(*types.SignedMessage) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// MpoolPushMessage indicates an expected call of MpoolPushMessage. +func (mr *MockCommitBatcherApiMockRecorder) MpoolPushMessage(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MpoolPushMessage", reflect.TypeOf((*MockCommitBatcherApi)(nil).MpoolPushMessage), arg0, arg1, arg2) +} + +// StateAccountKey mocks base method. +func (m *MockCommitBatcherApi) StateAccountKey(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (address.Address, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateAccountKey", arg0, arg1, arg2) + ret0, _ := ret[0].(address.Address) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateAccountKey indicates an expected call of StateAccountKey. +func (mr *MockCommitBatcherApiMockRecorder) StateAccountKey(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateAccountKey", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateAccountKey), arg0, arg1, arg2) +} + +// StateGetAllocation mocks base method. +func (m *MockCommitBatcherApi) StateGetAllocation(arg0 context.Context, arg1 address.Address, arg2 verifreg.AllocationId, arg3 types.TipSetKey) (*verifreg.Allocation, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetAllocation", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(*verifreg.Allocation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetAllocation indicates an expected call of StateGetAllocation. +func (mr *MockCommitBatcherApiMockRecorder) StateGetAllocation(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocation", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateGetAllocation), arg0, arg1, arg2, arg3) +} + +// StateLookupID mocks base method. +func (m *MockCommitBatcherApi) StateLookupID(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (address.Address, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateLookupID", arg0, arg1, arg2) + ret0, _ := ret[0].(address.Address) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateLookupID indicates an expected call of StateLookupID. +func (mr *MockCommitBatcherApiMockRecorder) StateLookupID(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateLookupID", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateLookupID), arg0, arg1, arg2) +} + +// StateMinerAvailableBalance mocks base method. +func (m *MockCommitBatcherApi) StateMinerAvailableBalance(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (big.Int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateMinerAvailableBalance", arg0, arg1, arg2) + ret0, _ := ret[0].(big.Int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateMinerAvailableBalance indicates an expected call of StateMinerAvailableBalance. +func (mr *MockCommitBatcherApiMockRecorder) StateMinerAvailableBalance(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerAvailableBalance", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateMinerAvailableBalance), arg0, arg1, arg2) +} + +// StateMinerInfo mocks base method. +func (m *MockCommitBatcherApi) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (api.MinerInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2) + ret0, _ := ret[0].(api.MinerInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateMinerInfo indicates an expected call of StateMinerInfo. +func (mr *MockCommitBatcherApiMockRecorder) StateMinerInfo(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerInfo", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateMinerInfo), arg0, arg1, arg2) +} + +// StateNetworkVersion mocks base method. +func (m *MockCommitBatcherApi) StateNetworkVersion(arg0 context.Context, arg1 types.TipSetKey) (network.Version, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateNetworkVersion", arg0, arg1) + ret0, _ := ret[0].(network.Version) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateNetworkVersion indicates an expected call of StateNetworkVersion. +func (mr *MockCommitBatcherApiMockRecorder) StateNetworkVersion(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateNetworkVersion", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateNetworkVersion), arg0, arg1) +} + +// StateSectorPreCommitInfo mocks base method. +func (m *MockCommitBatcherApi) StateSectorPreCommitInfo(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner0.SectorPreCommitOnChainInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateSectorPreCommitInfo", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(*miner0.SectorPreCommitOnChainInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateSectorPreCommitInfo indicates an expected call of StateSectorPreCommitInfo. +func (mr *MockCommitBatcherApiMockRecorder) StateSectorPreCommitInfo(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateSectorPreCommitInfo", reflect.TypeOf((*MockCommitBatcherApi)(nil).StateSectorPreCommitInfo), arg0, arg1, arg2, arg3) +} + +// WalletBalance mocks base method. +func (m *MockCommitBatcherApi) WalletBalance(arg0 context.Context, arg1 address.Address) (big.Int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WalletBalance", arg0, arg1) + ret0, _ := ret[0].(big.Int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WalletBalance indicates an expected call of WalletBalance. +func (mr *MockCommitBatcherApiMockRecorder) WalletBalance(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WalletBalance", reflect.TypeOf((*MockCommitBatcherApi)(nil).WalletBalance), arg0, arg1) +} + +// WalletHas mocks base method. +func (m *MockCommitBatcherApi) WalletHas(arg0 context.Context, arg1 address.Address) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WalletHas", arg0, arg1) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WalletHas indicates an expected call of WalletHas. +func (mr *MockCommitBatcherApiMockRecorder) WalletHas(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WalletHas", reflect.TypeOf((*MockCommitBatcherApi)(nil).WalletHas), arg0, arg1) +} + +// MockPreCommitBatcherApi is a mock of PreCommitBatcherApi interface. +type MockPreCommitBatcherApi struct { + ctrl *gomock.Controller + recorder *MockPreCommitBatcherApiMockRecorder +} + +// MockPreCommitBatcherApiMockRecorder is the mock recorder for MockPreCommitBatcherApi. +type MockPreCommitBatcherApiMockRecorder struct { + mock *MockPreCommitBatcherApi +} + +// NewMockPreCommitBatcherApi creates a new mock instance. +func NewMockPreCommitBatcherApi(ctrl *gomock.Controller) *MockPreCommitBatcherApi { + mock := &MockPreCommitBatcherApi{ctrl: ctrl} + mock.recorder = &MockPreCommitBatcherApiMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockPreCommitBatcherApi) EXPECT() *MockPreCommitBatcherApiMockRecorder { + return m.recorder +} + +// ChainHead mocks base method. +func (m *MockPreCommitBatcherApi) ChainHead(arg0 context.Context) (*types.TipSet, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ChainHead", arg0) + ret0, _ := ret[0].(*types.TipSet) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ChainHead indicates an expected call of ChainHead. +func (mr *MockPreCommitBatcherApiMockRecorder) ChainHead(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainHead", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).ChainHead), arg0) +} + +// GasEstimateMessageGas mocks base method. +func (m *MockPreCommitBatcherApi) GasEstimateMessageGas(arg0 context.Context, arg1 *types.Message, arg2 *api.MessageSendSpec, arg3 types.TipSetKey) (*types.Message, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GasEstimateMessageGas", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(*types.Message) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GasEstimateMessageGas indicates an expected call of GasEstimateMessageGas. +func (mr *MockPreCommitBatcherApiMockRecorder) GasEstimateMessageGas(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GasEstimateMessageGas", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).GasEstimateMessageGas), arg0, arg1, arg2, arg3) +} + +// MpoolPushMessage mocks base method. +func (m *MockPreCommitBatcherApi) MpoolPushMessage(arg0 context.Context, arg1 *types.Message, arg2 *api.MessageSendSpec) (*types.SignedMessage, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MpoolPushMessage", arg0, arg1, arg2) + ret0, _ := ret[0].(*types.SignedMessage) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// MpoolPushMessage indicates an expected call of MpoolPushMessage. +func (mr *MockPreCommitBatcherApiMockRecorder) MpoolPushMessage(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MpoolPushMessage", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).MpoolPushMessage), arg0, arg1, arg2) +} + +// StateAccountKey mocks base method. +func (m *MockPreCommitBatcherApi) StateAccountKey(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (address.Address, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateAccountKey", arg0, arg1, arg2) + ret0, _ := ret[0].(address.Address) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateAccountKey indicates an expected call of StateAccountKey. +func (mr *MockPreCommitBatcherApiMockRecorder) StateAccountKey(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateAccountKey", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateAccountKey), arg0, arg1, arg2) +} + +// StateGetAllocation mocks base method. +func (m *MockPreCommitBatcherApi) StateGetAllocation(arg0 context.Context, arg1 address.Address, arg2 verifreg.AllocationId, arg3 types.TipSetKey) (*verifreg.Allocation, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetAllocation", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(*verifreg.Allocation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetAllocation indicates an expected call of StateGetAllocation. +func (mr *MockPreCommitBatcherApiMockRecorder) StateGetAllocation(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocation", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateGetAllocation), arg0, arg1, arg2, arg3) +} + +// StateGetAllocationForPendingDeal mocks base method. +func (m *MockPreCommitBatcherApi) StateGetAllocationForPendingDeal(arg0 context.Context, arg1 abi.DealID, arg2 types.TipSetKey) (*verifreg.Allocation, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetAllocationForPendingDeal", arg0, arg1, arg2) + ret0, _ := ret[0].(*verifreg.Allocation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetAllocationForPendingDeal indicates an expected call of StateGetAllocationForPendingDeal. +func (mr *MockPreCommitBatcherApiMockRecorder) StateGetAllocationForPendingDeal(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocationForPendingDeal", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateGetAllocationForPendingDeal), arg0, arg1, arg2) +} + +// StateLookupID mocks base method. +func (m *MockPreCommitBatcherApi) StateLookupID(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (address.Address, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateLookupID", arg0, arg1, arg2) + ret0, _ := ret[0].(address.Address) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateLookupID indicates an expected call of StateLookupID. +func (mr *MockPreCommitBatcherApiMockRecorder) StateLookupID(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateLookupID", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateLookupID), arg0, arg1, arg2) +} + +// StateMinerAvailableBalance mocks base method. +func (m *MockPreCommitBatcherApi) StateMinerAvailableBalance(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (big.Int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateMinerAvailableBalance", arg0, arg1, arg2) + ret0, _ := ret[0].(big.Int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateMinerAvailableBalance indicates an expected call of StateMinerAvailableBalance. +func (mr *MockPreCommitBatcherApiMockRecorder) StateMinerAvailableBalance(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerAvailableBalance", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateMinerAvailableBalance), arg0, arg1, arg2) +} + +// StateMinerInfo mocks base method. +func (m *MockPreCommitBatcherApi) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (api.MinerInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2) + ret0, _ := ret[0].(api.MinerInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateMinerInfo indicates an expected call of StateMinerInfo. +func (mr *MockPreCommitBatcherApiMockRecorder) StateMinerInfo(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerInfo", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateMinerInfo), arg0, arg1, arg2) +} + +// StateNetworkVersion mocks base method. +func (m *MockPreCommitBatcherApi) StateNetworkVersion(arg0 context.Context, arg1 types.TipSetKey) (network.Version, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateNetworkVersion", arg0, arg1) + ret0, _ := ret[0].(network.Version) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateNetworkVersion indicates an expected call of StateNetworkVersion. +func (mr *MockPreCommitBatcherApiMockRecorder) StateNetworkVersion(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateNetworkVersion", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).StateNetworkVersion), arg0, arg1) +} + +// WalletBalance mocks base method. +func (m *MockPreCommitBatcherApi) WalletBalance(arg0 context.Context, arg1 address.Address) (big.Int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WalletBalance", arg0, arg1) + ret0, _ := ret[0].(big.Int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WalletBalance indicates an expected call of WalletBalance. +func (mr *MockPreCommitBatcherApiMockRecorder) WalletBalance(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WalletBalance", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).WalletBalance), arg0, arg1) +} + +// WalletHas mocks base method. +func (m *MockPreCommitBatcherApi) WalletHas(arg0 context.Context, arg1 address.Address) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WalletHas", arg0, arg1) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WalletHas indicates an expected call of WalletHas. +func (mr *MockPreCommitBatcherApiMockRecorder) WalletHas(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WalletHas", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).WalletHas), arg0, arg1) +} + // MockSealingAPI is a mock of SealingAPI interface. type MockSealingAPI struct { ctrl *gomock.Controller @@ -559,3 +965,54 @@ func (mr *MockSealingAPIMockRecorder) WalletHas(arg0, arg1 interface{}) *gomock. mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WalletHas", reflect.TypeOf((*MockSealingAPI)(nil).WalletHas), arg0, arg1) } + +// MockContext is a mock of Context interface. +type MockContext struct { + ctrl *gomock.Controller + recorder *MockContextMockRecorder +} + +// MockContextMockRecorder is the mock recorder for MockContext. +type MockContextMockRecorder struct { + mock *MockContext +} + +// NewMockContext creates a new mock instance. +func NewMockContext(ctrl *gomock.Controller) *MockContext { + mock := &MockContext{ctrl: ctrl} + mock.recorder = &MockContextMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockContext) EXPECT() *MockContextMockRecorder { + return m.recorder +} + +// Context mocks base method. +func (m *MockContext) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockContextMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockContext)(nil).Context)) +} + +// Send mocks base method. +func (m *MockContext) Send(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Send", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Send indicates an expected call of Send. +func (mr *MockContextMockRecorder) Send(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockContext)(nil).Send), arg0) +} diff --git a/storage/pipeline/mocks/statemachine.go b/storage/pipeline/mocks/statemachine.go deleted file mode 100644 index 8ed7cc625a0..00000000000 --- a/storage/pipeline/mocks/statemachine.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/filecoin-project/lotus/storage/pipeline (interfaces: Context) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" -) - -// MockContext is a mock of Context interface. -type MockContext struct { - ctrl *gomock.Controller - recorder *MockContextMockRecorder -} - -// MockContextMockRecorder is the mock recorder for MockContext. -type MockContextMockRecorder struct { - mock *MockContext -} - -// NewMockContext creates a new mock instance. -func NewMockContext(ctrl *gomock.Controller) *MockContext { - mock := &MockContext{ctrl: ctrl} - mock.recorder = &MockContextMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockContext) EXPECT() *MockContextMockRecorder { - return m.recorder -} - -// Context mocks base method. -func (m *MockContext) Context() context.Context { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Context") - ret0, _ := ret[0].(context.Context) - return ret0 -} - -// Context indicates an expected call of Context. -func (mr *MockContextMockRecorder) Context() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockContext)(nil).Context)) -} - -// Send mocks base method. -func (m *MockContext) Send(arg0 interface{}) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Send", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Send indicates an expected call of Send. -func (mr *MockContextMockRecorder) Send(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockContext)(nil).Send), arg0) -} diff --git a/storage/pipeline/mocks_gen.go b/storage/pipeline/mocks_gen.go new file mode 100644 index 00000000000..328ec9d7448 --- /dev/null +++ b/storage/pipeline/mocks_gen.go @@ -0,0 +1,3 @@ +package sealing + +//go:generate go run github.com/golang/mock/mockgen -destination=mocks/mocks.go -package=mocks . CommitBatcherApi,PreCommitBatcherApi,SealingAPI,Context diff --git a/storage/pipeline/precommit_batch.go b/storage/pipeline/precommit_batch.go index 18b4b5a6241..492f3ffdd77 100644 --- a/storage/pipeline/precommit_batch.go +++ b/storage/pipeline/precommit_batch.go @@ -26,8 +26,6 @@ import ( "github.com/filecoin-project/lotus/storage/pipeline/sealiface" ) -//go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_precommit_batcher.go -package=mocks . PreCommitBatcherApi - type PreCommitBatcherApi interface { MpoolPushMessage(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error) GasEstimateMessageGas(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error) diff --git a/storage/pipeline/sealing.go b/storage/pipeline/sealing.go index 4ef0323ff1f..c9927d172e8 100644 --- a/storage/pipeline/sealing.go +++ b/storage/pipeline/sealing.go @@ -46,8 +46,6 @@ var ErrTooManySectorsSealing = xerrors.New("too many sectors sealing") var log = logging.Logger("sectors") -//go:generate go run github.com/golang/mock/mockgen -destination=mocks/api.go -package=mocks . SealingAPI - type SealingAPI interface { StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) StateSearchMsg(ctx context.Context, from types.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) diff --git a/storage/pipeline/types.go b/storage/pipeline/types.go index dd0c81ebb18..ffc500a15d2 100644 --- a/storage/pipeline/types.go +++ b/storage/pipeline/types.go @@ -20,8 +20,6 @@ import ( "github.com/filecoin-project/lotus/storage/sealer/storiface" ) -//go:generate go run github.com/golang/mock/mockgen -destination=mocks/statemachine.go -package=mocks . Context - // Context is a go-statemachine context type Context interface { Context() context.Context