remove pkg/transformers; extract shared files needed to
libraries/shared; work on automated db migration management
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
// VulcanizeDB
|
||||
// Copyright © 2018 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/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
)
|
||||
|
||||
type MockWatcherRepository struct {
|
||||
ReturnCheckedColumnNames []string
|
||||
GetCheckedColumnNamesError error
|
||||
GetCheckedColumnNamesCalled bool
|
||||
|
||||
ReturnNotCheckedSQL string
|
||||
CreateNotCheckedSQLCalled bool
|
||||
|
||||
ReturnMissingHeaders []core.Header
|
||||
MissingHeadersError error
|
||||
MissingHeadersCalled bool
|
||||
}
|
||||
|
||||
func (repository *MockWatcherRepository) GetCheckedColumnNames(db *postgres.DB) ([]string, error) {
|
||||
repository.GetCheckedColumnNamesCalled = true
|
||||
if repository.GetCheckedColumnNamesError != nil {
|
||||
return []string{}, repository.GetCheckedColumnNamesError
|
||||
}
|
||||
|
||||
return repository.ReturnCheckedColumnNames, nil
|
||||
}
|
||||
|
||||
func (repository *MockWatcherRepository) SetCheckedColumnNames(checkedColumnNames []string) {
|
||||
repository.ReturnCheckedColumnNames = checkedColumnNames
|
||||
}
|
||||
|
||||
func (repository *MockWatcherRepository) CreateNotCheckedSQL(boolColumns []string) string {
|
||||
repository.CreateNotCheckedSQLCalled = true
|
||||
return repository.ReturnNotCheckedSQL
|
||||
}
|
||||
|
||||
func (repository *MockWatcherRepository) SetNotCheckedSQL(notCheckedSql string) {
|
||||
repository.ReturnNotCheckedSQL = notCheckedSql
|
||||
}
|
||||
|
||||
func (repository *MockWatcherRepository) MissingHeaders(startingBlockNumber int64, endingBlockNumber int64, db *postgres.DB, notCheckedSQL string) ([]core.Header, error) {
|
||||
if repository.MissingHeadersError != nil {
|
||||
return []core.Header{}, repository.MissingHeadersError
|
||||
}
|
||||
repository.MissingHeadersCalled = true
|
||||
return repository.ReturnMissingHeaders, nil
|
||||
}
|
||||
|
||||
func (repository *MockWatcherRepository) SetMissingHeaders(headers []core.Header) {
|
||||
repository.ReturnMissingHeaders = headers
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// VulcanizeDB
|
||||
// Copyright © 2018 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/utils"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
)
|
||||
|
||||
type MockStorageRepository struct {
|
||||
CreateErr error
|
||||
PassedBlockNumber int
|
||||
PassedBlockHash string
|
||||
PassedMetadata utils.StorageValueMetadata
|
||||
PassedValue interface{}
|
||||
}
|
||||
|
||||
func (repository *MockStorageRepository) Create(blockNumber int, blockHash string, metadata utils.StorageValueMetadata, value interface{}) error {
|
||||
repository.PassedBlockNumber = blockNumber
|
||||
repository.PassedBlockHash = blockHash
|
||||
repository.PassedMetadata = metadata
|
||||
repository.PassedValue = value
|
||||
return repository.CreateErr
|
||||
}
|
||||
|
||||
func (*MockStorageRepository) SetDB(db *postgres.DB) {
|
||||
panic("implement me")
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// VulcanizeDB
|
||||
// Copyright © 2018 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/ethereum/go-ethereum/common"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/utils"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
)
|
||||
|
||||
type MockStorageTransformer struct {
|
||||
Address common.Address
|
||||
ExecuteErr error
|
||||
PassedRow utils.StorageDiffRow
|
||||
}
|
||||
|
||||
func (transformer *MockStorageTransformer) Execute(row utils.StorageDiffRow) error {
|
||||
transformer.PassedRow = row
|
||||
return transformer.ExecuteErr
|
||||
}
|
||||
|
||||
func (transformer *MockStorageTransformer) ContractAddress() common.Address {
|
||||
return transformer.Address
|
||||
}
|
||||
|
||||
func (transformer *MockStorageTransformer) FakeTransformerInitializer(db *postgres.DB) transformer.StorageTransformer {
|
||||
return transformer
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// VulcanizeDB
|
||||
// Copyright © 2018 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/ethereum/go-ethereum/core/types"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"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
|
||||
config shared_t.TransformerConfig
|
||||
}
|
||||
|
||||
func (mh *MockTransformer) Execute(logs []types.Log, header core.Header, recheckHeaders constants.TransformerExecution) error {
|
||||
if mh.ExecuteError != nil {
|
||||
return mh.ExecuteError
|
||||
}
|
||||
mh.ExecuteWasCalled = true
|
||||
mh.PassedLogs = logs
|
||||
mh.PassedHeader = header
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mh *MockTransformer) GetConfig() shared_t.TransformerConfig {
|
||||
return mh.config
|
||||
}
|
||||
|
||||
func (mh *MockTransformer) SetTransformerConfig(config shared_t.TransformerConfig) {
|
||||
mh.config = config
|
||||
}
|
||||
|
||||
func (mh *MockTransformer) FakeTransformerInitializer(db *postgres.DB) shared_t.EventTransformer {
|
||||
return mh
|
||||
}
|
||||
|
||||
var FakeTransformerConfig = shared_t.TransformerConfig{
|
||||
TransformerName: "FakeTransformer",
|
||||
ContractAddresses: []string{"FakeAddress"},
|
||||
Topic: "FakeTopic",
|
||||
}
|
||||
Reference in New Issue
Block a user