2019-01-31 23:14:42 +00:00
|
|
|
// VulcanizeDB
|
2019-03-12 15:46:42 +00:00
|
|
|
// Copyright © 2019 Vulcanize
|
2019-01-31 23:14:42 +00:00
|
|
|
|
|
|
|
// 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/ethereum/go-ethereum/core/types"
|
2019-01-25 08:59:23 +00:00
|
|
|
|
2019-01-31 23:14:42 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
|
2019-01-25 08:59:23 +00:00
|
|
|
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
2018-12-13 12:03:51 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MockTransformer struct {
|
|
|
|
ExecuteWasCalled bool
|
|
|
|
ExecuteError error
|
|
|
|
PassedLogs []types.Log
|
|
|
|
PassedHeader core.Header
|
2019-03-14 16:59:39 +00:00
|
|
|
config shared_t.EventTransformerConfig
|
2018-12-13 12:03:51 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-03-14 16:59:39 +00:00
|
|
|
func (mh *MockTransformer) GetConfig() shared_t.EventTransformerConfig {
|
2018-12-13 12:03:51 +00:00
|
|
|
return mh.config
|
|
|
|
}
|
|
|
|
|
2019-03-14 16:59:39 +00:00
|
|
|
func (mh *MockTransformer) SetTransformerConfig(config shared_t.EventTransformerConfig) {
|
2018-12-13 12:03:51 +00:00
|
|
|
mh.config = config
|
|
|
|
}
|
|
|
|
|
2019-01-31 23:14:42 +00:00
|
|
|
func (mh *MockTransformer) FakeTransformerInitializer(db *postgres.DB) shared_t.EventTransformer {
|
2018-12-13 12:03:51 +00:00
|
|
|
return mh
|
|
|
|
}
|
|
|
|
|
2019-03-14 16:59:39 +00:00
|
|
|
var FakeTransformerConfig = shared_t.EventTransformerConfig{
|
2018-12-13 12:03:51 +00:00
|
|
|
TransformerName: "FakeTransformer",
|
|
|
|
ContractAddresses: []string{"FakeAddress"},
|
|
|
|
Topic: "FakeTopic",
|
|
|
|
}
|