ipld-eth-server/libraries/shared/mocks/event_transformer.go

59 lines
1.8 KiB
Go
Raw Normal View History

// 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/>.
2018-12-13 12:03:51 +00:00
package mocks
import (
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
"github.com/vulcanize/vulcanizedb/pkg/core"
2018-12-13 12:03:51 +00:00
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
2018-12-13 12:03:51 +00:00
)
type MockEventTransformer struct {
2018-12-13 12:03:51 +00:00
ExecuteWasCalled bool
ExecuteError error
PassedLogs []core.HeaderSyncLog
config transformer.EventTransformerConfig
2018-12-13 12:03:51 +00:00
}
func (t *MockEventTransformer) Execute(logs []core.HeaderSyncLog) error {
if t.ExecuteError != nil {
return t.ExecuteError
2018-12-13 12:03:51 +00:00
}
t.ExecuteWasCalled = true
t.PassedLogs = logs
2018-12-13 12:03:51 +00:00
return nil
}
func (t *MockEventTransformer) GetConfig() transformer.EventTransformerConfig {
return t.config
2018-12-13 12:03:51 +00:00
}
func (t *MockEventTransformer) SetTransformerConfig(config transformer.EventTransformerConfig) {
t.config = config
2018-12-13 12:03:51 +00:00
}
func (t *MockEventTransformer) FakeTransformerInitializer(db *postgres.DB) transformer.EventTransformer {
return t
2018-12-13 12:03:51 +00:00
}
var FakeTransformerConfig = transformer.EventTransformerConfig{
2018-12-13 12:03:51 +00:00
TransformerName: "FakeTransformer",
ContractAddresses: []string{fakes.FakeAddress.Hex()},
Topic: fakes.FakeHash.Hex(),
2018-12-13 12:03:51 +00:00
}