ipld-eth-server/libraries/shared/mocks/event_transformer.go
Rob Mulholand d496dad33c Decouple log extraction from transformer delegation
- limit missing headers results set to 100 so that extraction doesn't
  excessively block delegation
- wrap checked headers functions in repository struct
- move storage repository to factory, to correspond with event
  repository path
- remove unused files
- reformat sql
- remove line breaks in imports
2019-08-28 09:25:13 -05:00

59 lines
1.8 KiB
Go

// VulcanizeDB
// Copyright © 2019 Vulcanize
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package mocks
import (
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
)
type MockEventTransformer struct {
ExecuteWasCalled bool
ExecuteError error
PassedLogs []core.HeaderSyncLog
config transformer.EventTransformerConfig
}
func (t *MockEventTransformer) Execute(logs []core.HeaderSyncLog) error {
if t.ExecuteError != nil {
return t.ExecuteError
}
t.ExecuteWasCalled = true
t.PassedLogs = logs
return nil
}
func (t *MockEventTransformer) GetConfig() transformer.EventTransformerConfig {
return t.config
}
func (t *MockEventTransformer) SetTransformerConfig(config transformer.EventTransformerConfig) {
t.config = config
}
func (t *MockEventTransformer) FakeTransformerInitializer(db *postgres.DB) transformer.EventTransformer {
return t
}
var FakeTransformerConfig = transformer.EventTransformerConfig{
TransformerName: "FakeTransformer",
ContractAddresses: []string{fakes.FakeAddress.Hex()},
Topic: fakes.FakeHash.Hex(),
}