2018-12-13 12:03:51 +00:00
|
|
|
package mocks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
2019-02-08 16:35:46 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
2018-12-13 12:03:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type MockTransformer struct {
|
|
|
|
ExecuteWasCalled bool
|
|
|
|
ExecuteError error
|
|
|
|
PassedLogs []types.Log
|
|
|
|
PassedHeader core.Header
|
|
|
|
config shared.TransformerConfig
|
|
|
|
}
|
|
|
|
|
2019-02-08 16:35:46 +00:00
|
|
|
func (mh *MockTransformer) Execute(logs []types.Log, header core.Header, recheckHeaders constants.TransformerExecution) error {
|
2018-12-13 12:03:51 +00:00
|
|
|
if mh.ExecuteError != nil {
|
|
|
|
return mh.ExecuteError
|
|
|
|
}
|
|
|
|
mh.ExecuteWasCalled = true
|
|
|
|
mh.PassedLogs = logs
|
|
|
|
mh.PassedHeader = header
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mh *MockTransformer) GetConfig() shared.TransformerConfig {
|
|
|
|
return mh.config
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mh *MockTransformer) SetTransformerConfig(config shared.TransformerConfig) {
|
|
|
|
mh.config = config
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mh *MockTransformer) FakeTransformerInitializer(db *postgres.DB) shared.Transformer {
|
|
|
|
return mh
|
|
|
|
}
|
|
|
|
|
|
|
|
var FakeTransformerConfig = shared.TransformerConfig{
|
|
|
|
TransformerName: "FakeTransformer",
|
|
|
|
ContractAddresses: []string{"FakeAddress"},
|
|
|
|
Topic: "FakeTopic",
|
|
|
|
}
|