diff --git a/manifest/package.go b/manifest/package.go index fdeeb6160..72f434c69 100644 --- a/manifest/package.go +++ b/manifest/package.go @@ -81,8 +81,14 @@ func (r *manifestConverter) validateManifest(manif *Manifest) error { return fmt.Errorf("stream %q: 'use' is not allowed for kind 'store'", s.Name) } case ModuleKindBlockIndex: - if s.Inputs != nil { - return fmt.Errorf("stream %q: block index module cannot have inputs", s.Name) + if s.Inputs == nil { + return fmt.Errorf("stream %q: block index module should have inputs", s.Name) + } + + for _, input := range s.Inputs { + if input.IsParams() { + return fmt.Errorf("stream %q: block index module cannot have params input", s.Name) + } } if s.InitialBlock != nil { diff --git a/manifest/package_test.go b/manifest/package_test.go index ae88b9a6f..3a1b2969f 100644 --- a/manifest/package_test.go +++ b/manifest/package_test.go @@ -184,7 +184,7 @@ func TestValidateManifest(t *testing.T) { manifest: &Manifest{ SpecVersion: "v0.1.0", Modules: []*Module{ - {Name: "basic_index", Kind: "blockIndex", Output: StreamOutput{"proto:sf.substreams.index.v1.Keys"}}, + {Name: "basic_index", Kind: "blockIndex", Inputs: []*Input{{Map: "proto:sf.database.v1.changes"}}, Output: StreamOutput{"proto:sf.substreams.index.v1.Keys"}}, }, }, expectedError: "", @@ -194,27 +194,37 @@ func TestValidateManifest(t *testing.T) { manifest: &Manifest{ SpecVersion: "v0.1.0", Modules: []*Module{ - {Name: "basic_index", Kind: "blockIndex", Output: StreamOutput{"proto:sf.substreams.test"}}, + {Name: "basic_index", Kind: "blockIndex", Inputs: []*Input{{Map: "proto:sf.database.v1.changes"}}, Output: StreamOutput{"proto:sf.substreams.test"}}, }, }, expectedError: "stream \"basic_index\": block index module must have output type 'proto:sf.substreams.index.v1.Keys'", }, { - name: "block index with inputs", + name: "block index with params input", manifest: &Manifest{ SpecVersion: "v0.1.0", Modules: []*Module{ - {Name: "basic_index", Kind: "blockIndex", Inputs: []*Input{{Source: "proto:sf.database.v1.changes"}}, Output: StreamOutput{"proto:sf.substreams.index.v1.Keys"}}, + {Name: "basic_index", Kind: "blockIndex", Inputs: []*Input{{Params: "proto:sf.database.v1.changes"}}, Output: StreamOutput{"proto:sf.substreams.index.v1.Keys"}}, + }, + }, + expectedError: "stream \"basic_index\": block index module cannot have params input", + }, + { + name: "block index without input", + manifest: &Manifest{ + SpecVersion: "v0.1.0", + Modules: []*Module{ + {Name: "basic_index", Kind: "blockIndex", Output: StreamOutput{"proto:sf.substreams.index.v1.Keys"}}, }, }, - expectedError: "stream \"basic_index\": block index module cannot have inputs", + expectedError: "stream \"basic_index\": block index module should have inputs", }, { name: "block index with initialBlock", manifest: &Manifest{ SpecVersion: "v0.1.0", Modules: []*Module{ - {Name: "basic_index", Kind: "blockIndex", InitialBlock: &initialBlock, Output: StreamOutput{"proto:sf.substreams.index.v1.Keys"}}, + {Name: "basic_index", Kind: "blockIndex", Inputs: []*Input{{Map: "proto:sf.database.v1.changes"}}, InitialBlock: &initialBlock, Output: StreamOutput{"proto:sf.substreams.index.v1.Keys"}}, }, }, expectedError: "stream \"basic_index\": block index module cannot have initial block", @@ -227,7 +237,7 @@ func TestValidateManifest(t *testing.T) { {Name: "basic_index", Kind: "blockIndex", BlockFilter: &BlockFilter{ Module: "my_module", Query: "test query", - }, Output: StreamOutput{"proto:sf.substreams.index.v1.Keys"}}, + }, Inputs: []*Input{{Map: "proto:sf.database.v1.changes"}}, Output: StreamOutput{"proto:sf.substreams.index.v1.Keys"}}, }, }, expectedError: "stream \"basic_index\": block index module cannot have block filter",