From d1ee501f12fe2e92599612c2fdda5bff5e81f5cb Mon Sep 17 00:00:00 2001 From: Rob Mulholand Date: Fri, 26 Oct 2018 13:26:10 -0500 Subject: [PATCH] Use transformer factory for Bite (#89) * Use transformer factory for Bite - introduces separate transformer factory for non-LogNote events - converter includes `ToEntities` for events defined via ABI * Updates after rebasing with staging --- pkg/transformers/bite/config.go | 5 +- pkg/transformers/bite/converter.go | 39 +++---- pkg/transformers/bite/converter_test.go | 14 +-- pkg/transformers/bite/repository.go | 27 ++--- pkg/transformers/bite/repository_test.go | 48 ++++++-- pkg/transformers/bite/transformer.go | 97 ---------------- ...ransfromer_test.go => transformer_test.go} | 55 ++++++--- .../cat_file/chop_lump/transformer_test.go | 8 +- .../cat_file/flip/transformer_test.go | 8 +- .../cat_file/pit_vow/transformer_test.go | 8 +- pkg/transformers/deal/transformer_test.go | 8 +- .../drip_file/ilk/transformer_test.go | 8 +- .../drip_file/repo/transformer_test.go | 8 +- .../drip_file/vow/transformer_test.go | 8 +- pkg/transformers/factories/converter.go | 22 ++++ .../factories/log_note_converter.go | 21 ++++ .../factories/log_note_transformer.go | 85 ++++++++++++++ pkg/transformers/factories/repository.go | 27 +++++ pkg/transformers/factories/transformer.go | 45 +++----- pkg/transformers/flog/transformer_test.go | 4 +- pkg/transformers/integration_tests/bite.go | 11 +- .../integration_tests/cat_file.go | 12 +- pkg/transformers/integration_tests/deal.go | 4 +- .../integration_tests/drip_file_vow.go | 6 +- .../pit_file_debt_ceiling.go | 6 +- .../integration_tests/pit_file_ilk.go | 6 +- .../pit_file_stability_fee.go | 6 +- .../integration_tests/price_feeds.go | 12 +- pkg/transformers/integration_tests/tend.go | 10 +- .../integration_tests/vat_flux.go | 6 +- .../integration_tests/vat_fold.go | 4 +- .../integration_tests/vat_grab.go | 4 +- .../integration_tests/vat_heal.go | 4 +- .../integration_tests/vat_init.go | 6 +- .../integration_tests/vat_move.go | 6 +- .../integration_tests/vat_slip.go | 4 +- .../integration_tests/vat_tune.go | 6 +- .../pit_file/debt_ceiling/transformer_test.go | 8 +- .../pit_file/ilk/transformer_test.go | 8 +- .../stability_fee/transformer_test.go | 8 +- .../price_feeds/transformer_test.go | 8 +- pkg/transformers/tend/transformer_test.go | 10 +- .../test_data/mocks/bite/converter.go | 44 -------- .../test_data/mocks/bite/repository.go | 72 ------------ pkg/transformers/test_data/mocks/converter.go | 26 +++-- .../test_data/mocks/log_note_converter.go | 24 ++++ pkg/transformers/transformers.go | 104 ++++++++++-------- pkg/transformers/vat_flux/transformer_test.go | 8 +- pkg/transformers/vat_fold/transformer_test.go | 8 +- pkg/transformers/vat_grab/converter_test.go | 3 +- pkg/transformers/vat_grab/transformer_test.go | 8 +- pkg/transformers/vat_heal/transformer_test.go | 8 +- pkg/transformers/vat_init/transformer_test.go | 8 +- pkg/transformers/vat_move/transformer_test.go | 8 +- pkg/transformers/vat_slip/transformer_test.go | 8 +- pkg/transformers/vat_toll/transformer_test.go | 8 +- pkg/transformers/vat_tune/transformer_test.go | 8 +- 57 files changed, 539 insertions(+), 506 deletions(-) delete mode 100644 pkg/transformers/bite/transformer.go rename pkg/transformers/bite/{transfromer_test.go => transformer_test.go} (74%) create mode 100644 pkg/transformers/factories/converter.go create mode 100644 pkg/transformers/factories/log_note_converter.go create mode 100644 pkg/transformers/factories/log_note_transformer.go create mode 100644 pkg/transformers/factories/repository.go delete mode 100644 pkg/transformers/test_data/mocks/bite/converter.go delete mode 100644 pkg/transformers/test_data/mocks/bite/repository.go create mode 100644 pkg/transformers/test_data/mocks/log_note_converter.go diff --git a/pkg/transformers/bite/config.go b/pkg/transformers/bite/config.go index 10b7785d..063d6266 100644 --- a/pkg/transformers/bite/config.go +++ b/pkg/transformers/bite/config.go @@ -20,10 +20,11 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" ) -var BiteConfig = shared.TransformerConfig{ +var BiteConfig = shared.SingleTransformerConfig{ + TransformerName: shared.BiteLabel, ContractAddresses: []string{shared.CatContractAddress}, ContractAbi: shared.CatABI, - Topics: []string{shared.BiteSignature}, + Topic: shared.BiteSignature, StartingBlockNumber: 0, EndingBlockNumber: 10000000, } diff --git a/pkg/transformers/bite/converter.go b/pkg/transformers/bite/converter.go index 3dd3f4b0..fe0007a9 100644 --- a/pkg/transformers/bite/converter.go +++ b/pkg/transformers/bite/converter.go @@ -19,6 +19,7 @@ package bite import ( "bytes" "encoding/json" + "fmt" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -26,15 +27,10 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" ) -type Converter interface { - ToEntities(contractAbi string, ethLogs []types.Log) ([]BiteEntity, error) - ToModels(biteEntities []BiteEntity) ([]BiteModel, error) -} - type BiteConverter struct{} -func (BiteConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]BiteEntity, error) { - var entities []BiteEntity +func (BiteConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]interface{}, error) { + var entities []interface{} for _, ethLog := range ethLogs { entity := &BiteEntity{} address := ethLog.Address @@ -60,19 +56,24 @@ func (BiteConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]Bite return entities, nil } -func (converter BiteConverter) ToModels(entities []BiteEntity) ([]BiteModel, error) { - var models []BiteModel +func (converter BiteConverter) ToModels(entities []interface{}) ([]interface{}, error) { + var models []interface{} for _, entity := range entities { - ilk := string(bytes.Trim(entity.Ilk[:], "\x00")) - urn := common.BytesToAddress(entity.Urn[:]).String() - ink := entity.Ink - art := entity.Art - iArt := entity.IArt - tab := entity.Tab - flip := entity.Flip - logIdx := entity.LogIndex - txIdx := entity.TransactionIndex - rawLogJson, err := json.Marshal(entity.Raw) + biteEntity, ok := entity.(BiteEntity) + if !ok { + return nil, fmt.Errorf("entity of type %T, not %T", entity, BiteEntity{}) + } + + ilk := string(bytes.Trim(biteEntity.Ilk[:], "\x00")) + urn := common.BytesToAddress(biteEntity.Urn[:]).String() + ink := biteEntity.Ink + art := biteEntity.Art + iArt := biteEntity.IArt + tab := biteEntity.Tab + flip := biteEntity.Flip + logIdx := biteEntity.LogIndex + txIdx := biteEntity.TransactionIndex + rawLogJson, err := json.Marshal(biteEntity.Raw) rawLogString := string(rawLogJson) if err != nil { return nil, err diff --git a/pkg/transformers/bite/converter_test.go b/pkg/transformers/bite/converter_test.go index 3c42bdb4..07d80e3e 100644 --- a/pkg/transformers/bite/converter_test.go +++ b/pkg/transformers/bite/converter_test.go @@ -37,15 +37,7 @@ var _ = Describe("Bite Converter", func() { Expect(err).NotTo(HaveOccurred()) Expect(len(entities)).To(Equal(1)) entity := entities[0] - Expect(entity.Ilk).To(Equal(test_data.BiteEntity.Ilk)) - Expect(entity.Urn).To(Equal(test_data.BiteEntity.Urn)) - Expect(entity.Ink).To(Equal(test_data.BiteEntity.Ink)) - Expect(entity.Art).To(Equal(test_data.BiteEntity.Art)) - Expect(entity.Tab).To(Equal(test_data.BiteEntity.Tab)) - Expect(entity.Flip).To(Equal(test_data.BiteEntity.Flip)) - Expect(entity.IArt).To(Equal(test_data.BiteEntity.IArt)) - Expect(entity.TransactionIndex).To(Equal(test_data.BiteEntity.TransactionIndex)) - Expect(entity.Raw).To(Equal(test_data.BiteEntity.Raw)) + Expect(entity).To(Equal(test_data.BiteEntity)) }) It("returns an error if converting log to entity fails", func() { @@ -59,7 +51,7 @@ var _ = Describe("Bite Converter", func() { var emptyEntity = bite.BiteEntity{} It("converts an Entity to a Model", func() { - models, err := converter.ToModels([]bite.BiteEntity{test_data.BiteEntity}) + models, err := converter.ToModels([]interface{}{test_data.BiteEntity}) Expect(err).NotTo(HaveOccurred()) Expect(len(models)).To(Equal(1)) @@ -81,7 +73,7 @@ var _ = Describe("Bite Converter", func() { TransactionIndex: 0, Raw: string(emptyLog), } - models, err := converter.ToModels([]bite.BiteEntity{emptyEntity}) + models, err := converter.ToModels([]interface{}{emptyEntity}) Expect(err).NotTo(HaveOccurred()) Expect(len(models)).To(Equal(1)) diff --git a/pkg/transformers/bite/repository.go b/pkg/transformers/bite/repository.go index ddb5a4c8..f5417d54 100644 --- a/pkg/transformers/bite/repository.go +++ b/pkg/transformers/bite/repository.go @@ -15,34 +15,34 @@ package bite import ( + "fmt" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" ) -type Repository interface { - Create(headerID int64, models []BiteModel) error - MarkHeaderChecked(headerID int64) error - MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) -} - type BiteRepository struct { db *postgres.DB } -func NewBiteRepository(db *postgres.DB) Repository { - return BiteRepository{db: db} +func (repository *BiteRepository) SetDB(db *postgres.DB) { + repository.db = db } -func (repository BiteRepository) Create(headerID int64, models []BiteModel) error { +func (repository BiteRepository) Create(headerID int64, models []interface{}) error { tx, err := repository.db.Begin() if err != nil { return err } for _, model := range models { + biteModel, ok := model.(BiteModel) + if !ok { + tx.Rollback() + return fmt.Errorf("model of type %T, not %T", model, BiteModel{}) + } _, err := tx.Exec( `INSERT into maker.bite (header_id, ilk, urn, ink, art, iart, tab, nflip, log_idx, tx_idx, raw_log) VALUES($1, $2, $3, $4::NUMERIC, $5::NUMERIC, $6::NUMERIC, $7::NUMERIC, $8::NUMERIC, $9, $10, $11)`, - headerID, model.Ilk, model.Urn, model.Ink, model.Art, model.IArt, model.Tab, model.NFlip, model.LogIndex, model.TransactionIndex, model.Raw, + headerID, biteModel.Ilk, biteModel.Urn, biteModel.Ink, biteModel.Art, biteModel.IArt, biteModel.Tab, biteModel.NFlip, biteModel.LogIndex, biteModel.TransactionIndex, biteModel.Raw, ) if err != nil { tx.Rollback() @@ -50,13 +50,14 @@ func (repository BiteRepository) Create(headerID int64, models []BiteModel) erro } } _, err = tx.Exec(`INSERT INTO public.checked_headers (header_id, bite_checked) - VALUES ($1, $2) - ON CONFLICT (header_id) DO - UPDATE SET bite_checked = $2`, headerID, true) + VALUES ($1, $2) + ON CONFLICT (header_id) DO + UPDATE SET bite_checked = $2`, headerID, true) if err != nil { tx.Rollback() return err } + return tx.Commit() } diff --git a/pkg/transformers/bite/repository_test.go b/pkg/transformers/bite/repository_test.go index d6958ea4..eb899f0a 100644 --- a/pkg/transformers/bite/repository_test.go +++ b/pkg/transformers/bite/repository_test.go @@ -16,6 +16,7 @@ package bite_test import ( "database/sql" + "math/rand" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -26,13 +27,14 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/transformers/bite" + "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" "github.com/vulcanize/vulcanizedb/test_config" ) var _ = Describe("Bite repository", func() { var ( - biteRepository bite.Repository + biteRepository factories.Repository db *postgres.DB err error headerRepository datastore.HeaderRepository @@ -42,7 +44,8 @@ var _ = Describe("Bite repository", func() { db = test_config.NewTestDB(test_config.NewTestNode()) test_config.CleanTestDB(db) headerRepository = repositories.NewHeaderRepository(db) - biteRepository = bite.NewBiteRepository(db) + biteRepository = &bite.BiteRepository{} + biteRepository.SetDB(db) }) Describe("Create", func() { @@ -51,12 +54,12 @@ var _ = Describe("Bite repository", func() { BeforeEach(func() { headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) Expect(err).NotTo(HaveOccurred()) - - err = biteRepository.Create(headerID, []bite.BiteModel{test_data.BiteModel}) - Expect(err).NotTo(HaveOccurred()) }) It("persists a bite record", func() { + err = biteRepository.Create(headerID, []interface{}{test_data.BiteModel}) + + Expect(err).NotTo(HaveOccurred()) var dbBite bite.BiteModel err = db.Get(&dbBite, `SELECT ilk, urn, ink, art, tab, nflip, iart, log_idx, tx_idx, raw_log FROM maker.bite WHERE header_id = $1`, headerID) Expect(err).NotTo(HaveOccurred()) @@ -73,6 +76,21 @@ var _ = Describe("Bite repository", func() { }) It("marks header as checked for logs", func() { + err = biteRepository.Create(headerID, []interface{}{test_data.BiteModel}) + + Expect(err).NotTo(HaveOccurred()) + var headerChecked bool + err = db.Get(&headerChecked, `SELECT bite_checked FROM public.checked_headers WHERE header_id = $1`, headerID) + Expect(err).NotTo(HaveOccurred()) + Expect(headerChecked).To(BeTrue()) + }) + + It("updates a header as checked if row already exists", func() { + _, err = db.Exec(`INSERT INTO public.checked_headers (header_id) VALUES ($1)`, headerID) + Expect(err).NotTo(HaveOccurred()) + err = biteRepository.Create(headerID, []interface{}{test_data.BiteModel}) + + Expect(err).NotTo(HaveOccurred()) var headerChecked bool err = db.Get(&headerChecked, `SELECT bite_checked FROM public.checked_headers WHERE header_id = $1`, headerID) Expect(err).NotTo(HaveOccurred()) @@ -80,13 +98,19 @@ var _ = Describe("Bite repository", func() { }) It("does not duplicate bite events", func() { - err = biteRepository.Create(headerID, []bite.BiteModel{test_data.BiteModel}) + err = biteRepository.Create(headerID, []interface{}{test_data.BiteModel}) + Expect(err).NotTo(HaveOccurred()) + + err = biteRepository.Create(headerID, []interface{}{test_data.BiteModel}) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint")) }) It("removes bite if corresponding header is deleted", func() { + err = biteRepository.Create(headerID, []interface{}{test_data.BiteModel}) + Expect(err).NotTo(HaveOccurred()) + _, err = db.Exec(`DELETE FROM headers WHERE id = $1`, headerID) Expect(err).NotTo(HaveOccurred()) @@ -95,6 +119,13 @@ var _ = Describe("Bite repository", func() { Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(sql.ErrNoRows)) }) + + It("returns an error if the model type is not a Bite", func() { + err = biteRepository.Create(headerID, []interface{}{test_data.WrongModel{}}) + + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("model of type test_data.WrongModel, not bite.BiteModel")) + }) }) Describe("MarkHeaderChecked", func() { @@ -135,7 +166,7 @@ var _ = Describe("Bite repository", func() { ) BeforeEach(func() { - startingBlock = GinkgoRandomSeed() + startingBlock = rand.Int63() biteBlock = startingBlock + 1 endingBlock = startingBlock + 2 @@ -183,7 +214,8 @@ var _ = Describe("Bite repository", func() { _, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n)) Expect(err).NotTo(HaveOccurred()) } - biteRepositoryTwo := bite.NewBiteRepository(dbTwo) + biteRepositoryTwo := bite.BiteRepository{} + biteRepositoryTwo.SetDB(dbTwo) nodeOneMissingHeaders, err := biteRepository.MissingHeaders(blockNumbers[0], blockNumbers[len(blockNumbers)-1]) Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/bite/transformer.go b/pkg/transformers/bite/transformer.go deleted file mode 100644 index 101b7d44..00000000 --- a/pkg/transformers/bite/transformer.go +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2018 Vulcanize - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package bite - -import ( - "log" - - "github.com/ethereum/go-ethereum/common" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -) - -type BiteTransformer struct { - Repository Repository - Fetcher shared.LogFetcher - Converter Converter - Config shared.TransformerConfig -} - -type BiteTransformerInitializer struct { - Config shared.TransformerConfig -} - -func (i BiteTransformerInitializer) NewBiteTransformer(db *postgres.DB, blockChain core.BlockChain) shared.Transformer { - fetcher := shared.NewFetcher(blockChain) - repository := NewBiteRepository(db) - transformer := BiteTransformer{ - Fetcher: fetcher, - Repository: repository, - Converter: BiteConverter{}, - Config: i.Config, - } - - return transformer -} - -func (b BiteTransformer) Execute() error { - config := b.Config - topics := [][]common.Hash{{common.HexToHash(shared.BiteSignature)}} - - missingHeaders, err := b.Repository.MissingHeaders(config.StartingBlockNumber, config.EndingBlockNumber) - if err != nil { - log.Println("Error fetching missing headers:", err) - return err - } - - log.Printf("Fetching bite event logs for %d headers \n", len(missingHeaders)) - for _, header := range missingHeaders { - ethLogs, err := b.Fetcher.FetchLogs(config.ContractAddresses, topics, header.BlockNumber) - if err != nil { - log.Println("Error fetching matching logs:", err) - return err - } - if len(ethLogs) < 1 { - err = b.Repository.MarkHeaderChecked(header.Id) - if err != nil { - return err - } - } - entities, err := b.Converter.ToEntities(config.ContractAbi, ethLogs) - if err != nil { - return err - } - model, err := b.Converter.ToModels(entities) - if err != nil { - log.Println("Error converting logs:", err) - return err - } - - err = b.Repository.Create(header.Id, model) - if err != nil { - log.Println("Error persisting bite record:", err) - return err - } - } - - return nil -} -func (b BiteTransformer) SetConfig(config shared.TransformerConfig) { - b.Config = config -} diff --git a/pkg/transformers/bite/transfromer_test.go b/pkg/transformers/bite/transformer_test.go similarity index 74% rename from pkg/transformers/bite/transfromer_test.go rename to pkg/transformers/bite/transformer_test.go index 49960739..f40ee8aa 100644 --- a/pkg/transformers/bite/transfromer_test.go +++ b/pkg/transformers/bite/transformer_test.go @@ -27,33 +27,36 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/transformers/bite" + "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks" - bite_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/bite" ) var _ = Describe("Bite Transformer", func() { - var repository bite_mocks.MockBiteRepository + var repository mocks.MockRepository var fetcher mocks.MockLogFetcher - var converter bite_mocks.MockBiteConverter - var transformer bite.BiteTransformer + var converter mocks.MockConverter + var transformer shared.Transformer var blockNumber1 = rand.Int63() var blockNumber2 = rand.Int63() BeforeEach(func() { - repository = bite_mocks.MockBiteRepository{} + repository = mocks.MockRepository{} fetcher = mocks.MockLogFetcher{} - converter = bite_mocks.MockBiteConverter{} + converter = mocks.MockConverter{} - transformer = bite.BiteTransformer{ + transformer = factories.Transformer{ Repository: &repository, Fetcher: &fetcher, Converter: &converter, Config: bite.BiteConfig, - } + }.NewTransformer(nil, nil) + }) - transformer.SetConfig(bite.BiteConfig) + It("sets the blockchain and db", func() { + Expect(fetcher.SetBcCalled).To(BeTrue()) + Expect(repository.SetDbCalled).To(BeTrue()) }) It("gets missing headers for blocks in the configured range", func() { @@ -65,7 +68,7 @@ var _ = Describe("Bite Transformer", func() { }) It("returns an error if it fails to get missing headers", func() { - repository.SetMissingHeadersErr(fakes.FakeError) + repository.SetMissingHeadersError(fakes.FakeError) err := transformer.Execute() Expect(err).To(HaveOccurred()) @@ -103,7 +106,7 @@ var _ = Describe("Bite Transformer", func() { It("returns error if marking header checked returns err", func() { repository.SetMissingHeaders([]core.Header{{Id: int64(123)}}) - repository.SetMarkHeaderCheckedErr(fakes.FakeError) + repository.SetMarkHeaderCheckedError(fakes.FakeError) err := transformer.Execute() @@ -117,7 +120,7 @@ var _ = Describe("Bite Transformer", func() { err := transformer.Execute() Expect(err).NotTo(HaveOccurred()) - Expect(converter.ConverterAbi).To(Equal(bite.BiteConfig.ContractAbi)) + Expect(converter.ContractAbi).To(Equal(bite.BiteConfig.ContractAbi)) Expect(converter.LogsToConvert).To(Equal([]types.Log{test_data.EthBiteLog})) }) @@ -125,7 +128,30 @@ var _ = Describe("Bite Transformer", func() { headerId := int64(1) repository.SetMissingHeaders([]core.Header{{BlockNumber: blockNumber1, Id: headerId}}) fetcher.SetFetchedLogs([]types.Log{test_data.EthBiteLog}) - converter.SetConverterError(fakes.FakeError) + converter.ToEntitiesError = fakes.FakeError + + err := transformer.Execute() + + Expect(err).To(HaveOccurred()) + Expect(err).To(MatchError(fakes.FakeError)) + }) + + It("converts an entity to a BiteModel", func() { + repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}}) + fetcher.SetFetchedLogs([]types.Log{test_data.EthBiteLog}) + converter.EntitiesToReturn = []interface{}{test_data.BiteEntity} + + err := transformer.Execute() + + Expect(err).NotTo(HaveOccurred()) + Expect(converter.EntitiesToConvert[0]).To(Equal(test_data.BiteEntity)) + }) + + It("returns an error if converting to models fails", func() { + repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}}) + fetcher.SetFetchedLogs([]types.Log{test_data.EthBiteLog}) + converter.EntitiesToReturn = []interface{}{test_data.BiteEntity} + converter.ToModelsError = fakes.FakeError err := transformer.Execute() @@ -137,12 +163,13 @@ var _ = Describe("Bite Transformer", func() { headerId := int64(1) repository.SetMissingHeaders([]core.Header{{BlockNumber: blockNumber1, Id: headerId}}) fetcher.SetFetchedLogs([]types.Log{test_data.EthBiteLog}) + converter.ModelsToReturn = []interface{}{test_data.BiteModel} err := transformer.Execute() Expect(err).NotTo(HaveOccurred()) Expect(repository.PassedHeaderID).To(Equal(headerId)) - Expect(repository.PassedBiteModels).To(Equal([]bite.BiteModel{test_data.BiteModel})) + Expect(repository.PassedModels[0]).To(Equal(test_data.BiteModel)) }) It("returns error if persisting bite record fails", func() { diff --git a/pkg/transformers/cat_file/chop_lump/transformer_test.go b/pkg/transformers/cat_file/chop_lump/transformer_test.go index 62b61ea6..76de7fd8 100644 --- a/pkg/transformers/cat_file/chop_lump/transformer_test.go +++ b/pkg/transformers/cat_file/chop_lump/transformer_test.go @@ -34,7 +34,7 @@ var _ = Describe("Cat file chop lump transformer", func() { var ( config = chop_lump.CatFileChopLumpConfig repository mocks.MockRepository - converter mocks.MockConverter + converter mocks.MockLogNoteConverter fetcher mocks.MockLogFetcher transformer shared.Transformer headerOne core.Header @@ -43,14 +43,14 @@ var _ = Describe("Cat file chop lump transformer", func() { BeforeEach(func() { repository = mocks.MockRepository{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} fetcher = mocks.MockLogFetcher{} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Repository: &repository, Fetcher: &fetcher, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} }) diff --git a/pkg/transformers/cat_file/flip/transformer_test.go b/pkg/transformers/cat_file/flip/transformer_test.go index 6bba1e1f..d26298b8 100644 --- a/pkg/transformers/cat_file/flip/transformer_test.go +++ b/pkg/transformers/cat_file/flip/transformer_test.go @@ -34,7 +34,7 @@ var _ = Describe("Cat file flip transformer", func() { var ( config = flip.CatFileFlipConfig repository mocks.MockRepository - converter mocks.MockConverter + converter mocks.MockLogNoteConverter fetcher mocks.MockLogFetcher transformer shared.Transformer headerOne core.Header @@ -43,14 +43,14 @@ var _ = Describe("Cat file flip transformer", func() { BeforeEach(func() { repository = mocks.MockRepository{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} fetcher = mocks.MockLogFetcher{} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Repository: &repository, Fetcher: &fetcher, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} }) diff --git a/pkg/transformers/cat_file/pit_vow/transformer_test.go b/pkg/transformers/cat_file/pit_vow/transformer_test.go index 4dd69f64..e9e0b289 100644 --- a/pkg/transformers/cat_file/pit_vow/transformer_test.go +++ b/pkg/transformers/cat_file/pit_vow/transformer_test.go @@ -34,7 +34,7 @@ var _ = Describe("Cat file pit vow transformer", func() { var ( config = pit_vow.CatFilePitVowConfig repository mocks.MockRepository - converter mocks.MockConverter + converter mocks.MockLogNoteConverter fetcher mocks.MockLogFetcher transformer shared.Transformer headerOne core.Header @@ -43,14 +43,14 @@ var _ = Describe("Cat file pit vow transformer", func() { BeforeEach(func() { repository = mocks.MockRepository{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} fetcher = mocks.MockLogFetcher{} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Repository: &repository, Fetcher: &fetcher, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} }) diff --git a/pkg/transformers/deal/transformer_test.go b/pkg/transformers/deal/transformer_test.go index 3ab554c9..f70c0c53 100644 --- a/pkg/transformers/deal/transformer_test.go +++ b/pkg/transformers/deal/transformer_test.go @@ -34,7 +34,7 @@ var _ = Describe("DealTransformer", func() { var config = deal.DealConfig var repository mocks.MockRepository var fetcher mocks.MockLogFetcher - var converter mocks.MockConverter + var converter mocks.MockLogNoteConverter var transformer shared.Transformer var headerOne core.Header var headerTwo core.Header @@ -42,13 +42,13 @@ var _ = Describe("DealTransformer", func() { BeforeEach(func() { repository = mocks.MockRepository{} fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} - transformer = factories.Transformer{ + converter = mocks.MockLogNoteConverter{} + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Repository: &repository, Fetcher: &fetcher, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) headerOne = core.Header{BlockNumber: rand.Int63(), Id: rand.Int63()} headerTwo = core.Header{BlockNumber: rand.Int63(), Id: rand.Int63()} }) diff --git a/pkg/transformers/drip_file/ilk/transformer_test.go b/pkg/transformers/drip_file/ilk/transformer_test.go index 58b472a6..85712bf3 100644 --- a/pkg/transformers/drip_file/ilk/transformer_test.go +++ b/pkg/transformers/drip_file/ilk/transformer_test.go @@ -35,7 +35,7 @@ var _ = Describe("Drip file ilk transformer", func() { var ( config = ilk.DripFileIlkConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -44,14 +44,14 @@ var _ = Describe("Drip file ilk transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Fetcher: &fetcher, Converter: &converter, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) headerOne = core.Header{BlockNumber: rand.Int63(), Id: rand.Int63()} headerTwo = core.Header{BlockNumber: rand.Int63(), Id: rand.Int63()} }) diff --git a/pkg/transformers/drip_file/repo/transformer_test.go b/pkg/transformers/drip_file/repo/transformer_test.go index c68f68b0..6c4e47f3 100644 --- a/pkg/transformers/drip_file/repo/transformer_test.go +++ b/pkg/transformers/drip_file/repo/transformer_test.go @@ -35,7 +35,7 @@ var _ = Describe("Drip file repo transformer", func() { var ( config = repo.DripFileRepoConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -44,14 +44,14 @@ var _ = Describe("Drip file repo transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Fetcher: &fetcher, Converter: &converter, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) headerOne = core.Header{BlockNumber: rand.Int63(), Id: rand.Int63()} headerTwo = core.Header{BlockNumber: rand.Int63(), Id: rand.Int63()} }) diff --git a/pkg/transformers/drip_file/vow/transformer_test.go b/pkg/transformers/drip_file/vow/transformer_test.go index d7d9d4ec..2af4ba8a 100644 --- a/pkg/transformers/drip_file/vow/transformer_test.go +++ b/pkg/transformers/drip_file/vow/transformer_test.go @@ -35,7 +35,7 @@ var _ = Describe("Drip file vow transformer", func() { var ( config = vow.DripFileVowConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -44,14 +44,14 @@ var _ = Describe("Drip file vow transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Fetcher: &fetcher, Converter: &converter, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) headerOne = core.Header{BlockNumber: rand.Int63(), Id: rand.Int63()} headerTwo = core.Header{BlockNumber: rand.Int63(), Id: rand.Int63()} }) diff --git a/pkg/transformers/factories/converter.go b/pkg/transformers/factories/converter.go new file mode 100644 index 00000000..458b4388 --- /dev/null +++ b/pkg/transformers/factories/converter.go @@ -0,0 +1,22 @@ +// Copyright 2018 Vulcanize +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package factories + +import "github.com/ethereum/go-ethereum/core/types" + +type Converter interface { + ToEntities(contractAbi string, ethLog []types.Log) ([]interface{}, error) + ToModels([]interface{}) ([]interface{}, error) +} diff --git a/pkg/transformers/factories/log_note_converter.go b/pkg/transformers/factories/log_note_converter.go new file mode 100644 index 00000000..52e994da --- /dev/null +++ b/pkg/transformers/factories/log_note_converter.go @@ -0,0 +1,21 @@ +// Copyright 2018 Vulcanize +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package factories + +import "github.com/ethereum/go-ethereum/core/types" + +type LogNoteConverter interface { + ToModels(ethLog []types.Log) ([]interface{}, error) +} diff --git a/pkg/transformers/factories/log_note_transformer.go b/pkg/transformers/factories/log_note_transformer.go new file mode 100644 index 00000000..68f8e459 --- /dev/null +++ b/pkg/transformers/factories/log_note_transformer.go @@ -0,0 +1,85 @@ +// Copyright 2018 Vulcanize +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package factories + +import ( + "log" + + "github.com/ethereum/go-ethereum/common" + + "github.com/vulcanize/vulcanizedb/pkg/core" + "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" + "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" +) + +type LogNoteTransformer struct { + Config shared.SingleTransformerConfig + Converter LogNoteConverter + Repository Repository + Fetcher shared.SettableLogFetcher +} + +func (transformer LogNoteTransformer) NewLogNoteTransformer(db *postgres.DB, bc core.BlockChain) shared.Transformer { + transformer.Repository.SetDB(db) + transformer.Fetcher.SetBC(bc) + return transformer +} + +func (transformer LogNoteTransformer) Execute() error { + transformerName := transformer.Config.TransformerName + missingHeaders, err := transformer.Repository.MissingHeaders(transformer.Config.StartingBlockNumber, transformer.Config.EndingBlockNumber) + if err != nil { + log.Printf("Error fetching mising headers in %v transformer: %v \n", transformerName, err) + return err + } + + // Grab event signature from transformer config + // (Double-array structure required for go-ethereum FilterQuery) + var topic = [][]common.Hash{{common.HexToHash(transformer.Config.Topic)}} + + log.Printf("Fetching %v event logs for %d headers \n", transformerName, len(missingHeaders)) + for _, header := range missingHeaders { + // Fetch the missing logs for a given header + matchingLogs, err := transformer.Fetcher.FetchLogs(transformer.Config.ContractAddresses, topic, header.BlockNumber) + if err != nil { + log.Printf("Error fetching matching logs in %v transformer: %v", transformerName, err) + return err + } + + // No matching logs, mark the header as checked for this type of logs + if len(matchingLogs) < 1 { + err := transformer.Repository.MarkHeaderChecked(header.Id) + if err != nil { + log.Printf("Error marking header as checked in %v: %v", transformerName, err) + return err + } + // Continue with the next header; nothing to persist + continue + } + + models, err := transformer.Converter.ToModels(matchingLogs) + if err != nil { + log.Printf("Error converting logs in %v: %v", transformerName, err) + return err + } + + err = transformer.Repository.Create(header.Id, models) + if err != nil { + log.Printf("Error persisting %v record: %v", transformerName, err) + return err + } + } + return nil +} diff --git a/pkg/transformers/factories/repository.go b/pkg/transformers/factories/repository.go new file mode 100644 index 00000000..015fe49f --- /dev/null +++ b/pkg/transformers/factories/repository.go @@ -0,0 +1,27 @@ +// Copyright 2018 Vulcanize +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package factories + +import ( + "github.com/vulcanize/vulcanizedb/pkg/core" + "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" +) + +type Repository interface { + Create(headerID int64, models []interface{}) error + MarkHeaderChecked(headerID int64) error + MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) + SetDB(db *postgres.DB) +} diff --git a/pkg/transformers/factories/transformer.go b/pkg/transformers/factories/transformer.go index f625c1e0..0c67a993 100644 --- a/pkg/transformers/factories/transformer.go +++ b/pkg/transformers/factories/transformer.go @@ -15,13 +15,12 @@ package factories import ( - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "log" "github.com/ethereum/go-ethereum/common" "github.com/vulcanize/vulcanizedb/pkg/core" + "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" ) @@ -32,17 +31,6 @@ type Transformer struct { Fetcher shared.SettableLogFetcher } -type Converter interface { - ToModels(ethLog []types.Log) ([]interface{}, error) -} - -type Repository interface { - Create(headerID int64, models []interface{}) error - MarkHeaderChecked(headerID int64) error - MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) - SetDB(db *postgres.DB) -} - func (transformer Transformer) NewTransformer(db *postgres.DB, bc core.BlockChain) shared.Transformer { transformer.Repository.SetDB(db) transformer.Fetcher.SetBC(bc) @@ -51,39 +39,40 @@ func (transformer Transformer) NewTransformer(db *postgres.DB, bc core.BlockChai func (transformer Transformer) Execute() error { transformerName := transformer.Config.TransformerName - missingHeaders, err := transformer.Repository.MissingHeaders(transformer.Config.StartingBlockNumber, transformer.Config.EndingBlockNumber) + config := transformer.Config + topics := [][]common.Hash{{common.HexToHash(config.Topic)}} + missingHeaders, err := transformer.Repository.MissingHeaders(config.StartingBlockNumber, config.EndingBlockNumber) if err != nil { log.Printf("Error fetching missing headers in %v transformer: %v \n", transformerName, err) return err } - - // Grab event signature from transformer config - // (Double-array structure required for go-ethereum FilterQuery) - var topic = [][]common.Hash{{common.HexToHash(transformer.Config.Topic)}} - log.Printf("Fetching %v event logs for %d headers \n", transformerName, len(missingHeaders)) for _, header := range missingHeaders { - // Fetch the missing logs for a given header - matchingLogs, err := transformer.Fetcher.FetchLogs(transformer.Config.ContractAddresses, topic, header.BlockNumber) + logs, err := transformer.Fetcher.FetchLogs(config.ContractAddresses, topics, header.BlockNumber) if err != nil { log.Printf("Error fetching matching logs in %v transformer: %v", transformerName, err) return err } - // No matching logs, mark the header as checked for this type of logs - if len(matchingLogs) < 1 { - err := transformer.Repository.MarkHeaderChecked(header.Id) + if len(logs) < 1 { + err = transformer.Repository.MarkHeaderChecked(header.Id) if err != nil { log.Printf("Error marking header as checked in %v: %v", transformerName, err) return err } - // Continue with the next header; nothing to persist + continue } - models, err := transformer.Converter.ToModels(matchingLogs) + entities, err := transformer.Converter.ToEntities(config.ContractAbi, logs) if err != nil { - log.Printf("Error converting logs in %v: %v", transformerName, err) + log.Printf("Error converting logs to entities in %v: %v", transformerName, err) + return err + } + + models, err := transformer.Converter.ToModels(entities) + if err != nil { + log.Printf("Error converting entities to models in %v: %v", transformerName, err) return err } @@ -92,6 +81,8 @@ func (transformer Transformer) Execute() error { log.Printf("Error persisting %v record: %v", transformerName, err) return err } + } + return nil } diff --git a/pkg/transformers/flog/transformer_test.go b/pkg/transformers/flog/transformer_test.go index 120215c0..36ef491d 100644 --- a/pkg/transformers/flog/transformer_test.go +++ b/pkg/transformers/flog/transformer_test.go @@ -45,12 +45,12 @@ var _ = Describe("Flog transformer", func() { repository = flog_mocks.MockFlogRepository{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Fetcher: &fetcher, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/integration_tests/bite.go b/pkg/transformers/integration_tests/bite.go index 5b98b58b..7e12c0f9 100644 --- a/pkg/transformers/integration_tests/bite.go +++ b/pkg/transformers/integration_tests/bite.go @@ -19,6 +19,8 @@ import ( . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/transformers/bite" + "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" + "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" "github.com/vulcanize/vulcanizedb/test_config" ) @@ -40,8 +42,13 @@ var _ = Describe("Bite Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := bite.BiteTransformerInitializer{Config: config} - transformer := initializer.NewBiteTransformer(db, blockchain) + initializer := factories.Transformer{ + Config: config, + Converter: &bite.BiteConverter{}, + Repository: &bite.BiteRepository{}, + Fetcher: &shared.Fetcher{}, + } + transformer := initializer.NewTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/cat_file.go b/pkg/transformers/integration_tests/cat_file.go index b53c0a56..26b03e80 100644 --- a/pkg/transformers/integration_tests/cat_file.go +++ b/pkg/transformers/integration_tests/cat_file.go @@ -61,13 +61,13 @@ var _ = Describe("Cat File transformer", func() { config.StartingBlockNumber = chopLumpBlockNumber config.EndingBlockNumber = chopLumpBlockNumber - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Converter: &chop_lump.CatFileChopLumpConverter{}, Repository: &chop_lump.CatFileChopLumpRepository{}, Fetcher: &shared.Fetcher{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err := transformer.Execute() Expect(err).NotTo(HaveOccurred()) @@ -99,13 +99,13 @@ var _ = Describe("Cat File transformer", func() { config.StartingBlockNumber = flipBlockNumber config.EndingBlockNumber = flipBlockNumber - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Converter: &flip.CatFileFlipConverter{}, Repository: &flip.CatFileFlipRepository{}, Fetcher: &shared.Fetcher{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err := transformer.Execute() Expect(err).NotTo(HaveOccurred()) @@ -129,13 +129,13 @@ var _ = Describe("Cat File transformer", func() { config.StartingBlockNumber = pitVowBlockNumber config.EndingBlockNumber = pitVowBlockNumber - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Converter: &pit_vow.CatFilePitVowConverter{}, Repository: &pit_vow.CatFilePitVowRepository{}, Fetcher: &shared.Fetcher{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err := transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/deal.go b/pkg/transformers/integration_tests/deal.go index 6604fa24..c90784ac 100644 --- a/pkg/transformers/integration_tests/deal.go +++ b/pkg/transformers/integration_tests/deal.go @@ -56,13 +56,13 @@ var _ = Describe("Deal transformer", func() { config.StartingBlockNumber = flipBlockNumber config.EndingBlockNumber = flipBlockNumber - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Converter: &deal.DealConverter{}, Repository: &deal.DealRepository{}, Fetcher: &shared.Fetcher{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err := transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/drip_file_vow.go b/pkg/transformers/integration_tests/drip_file_vow.go index c2b15d6f..f6aae07c 100644 --- a/pkg/transformers/integration_tests/drip_file_vow.go +++ b/pkg/transformers/integration_tests/drip_file_vow.go @@ -24,7 +24,7 @@ import ( "github.com/vulcanize/vulcanizedb/test_config" ) -var _ = Describe("Drip File Vow Transformer", func() { +var _ = Describe("Drip File Vow LogNoteTransformer", func() { It("transforms DripFileVow log events", func() { blockNumber := int64(8762197) config := vow.DripFileVowConfig @@ -42,13 +42,13 @@ var _ = Describe("Drip File Vow Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &vow.DripFileVowConverter{}, Repository: &vow.DripFileVowRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/pit_file_debt_ceiling.go b/pkg/transformers/integration_tests/pit_file_debt_ceiling.go index ffe2a98f..1a9c3507 100644 --- a/pkg/transformers/integration_tests/pit_file_debt_ceiling.go +++ b/pkg/transformers/integration_tests/pit_file_debt_ceiling.go @@ -24,7 +24,7 @@ import ( "github.com/vulcanize/vulcanizedb/test_config" ) -var _ = Describe("PitFileDebtCeiling Transformer", func() { +var _ = Describe("PitFileDebtCeiling LogNoteTransformer", func() { It("fetches and transforms a PitFileDebtCeiling event from Kovan chain", func() { blockNumber := int64(8535578) config := debt_ceiling.DebtCeilingFileConfig @@ -42,13 +42,13 @@ var _ = Describe("PitFileDebtCeiling Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &debt_ceiling.PitFileDebtCeilingConverter{}, Repository: &debt_ceiling.PitFileDebtCeilingRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/pit_file_ilk.go b/pkg/transformers/integration_tests/pit_file_ilk.go index dc64b6ac..be174871 100644 --- a/pkg/transformers/integration_tests/pit_file_ilk.go +++ b/pkg/transformers/integration_tests/pit_file_ilk.go @@ -24,7 +24,7 @@ import ( "github.com/vulcanize/vulcanizedb/test_config" ) -var _ = Describe("PitFileIlk Transformer", func() { +var _ = Describe("PitFileIlk LogNoteTransformer", func() { It("fetches and transforms a PitFileIlk event from Kovan chain", func() { blockNumber := int64(9103223) config := ilk.IlkFileConfig @@ -42,13 +42,13 @@ var _ = Describe("PitFileIlk Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &ilk.PitFileIlkConverter{}, Repository: &ilk.PitFileIlkRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/pit_file_stability_fee.go b/pkg/transformers/integration_tests/pit_file_stability_fee.go index 41ed688f..446000cb 100644 --- a/pkg/transformers/integration_tests/pit_file_stability_fee.go +++ b/pkg/transformers/integration_tests/pit_file_stability_fee.go @@ -24,7 +24,7 @@ import ( "github.com/vulcanize/vulcanizedb/test_config" ) -var _ = Describe("PitFileStabilityFee Transformer", func() { +var _ = Describe("PitFileStabilityFee LogNoteTransformer", func() { It("fetches and transforms a PitFileStabilityFee event from Kovan chain", func() { blockNumber := int64(8535544) config := stability_fee.StabilityFeeFileConfig @@ -42,13 +42,13 @@ var _ = Describe("PitFileStabilityFee Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &stability_fee.PitFileStabilityFeeConverter{}, Repository: &stability_fee.PitFileStabilityFeeRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/price_feeds.go b/pkg/transformers/integration_tests/price_feeds.go index 3178058e..3d04cb52 100644 --- a/pkg/transformers/integration_tests/price_feeds.go +++ b/pkg/transformers/integration_tests/price_feeds.go @@ -50,13 +50,13 @@ var _ = Describe("Price feeds transformer", func() { config.StartingBlockNumber = blockNumber config.EndingBlockNumber = blockNumber - transformerInitializer := factories.Transformer{ + transformerInitializer := factories.LogNoteTransformer{ Config: config, Converter: &price_feeds.PriceFeedConverter{}, Repository: &price_feeds.PriceFeedRepository{}, Fetcher: &shared.Fetcher{}, } - transformer := transformerInitializer.NewTransformer(db, blockChain) + transformer := transformerInitializer.NewLogNoteTransformer(db, blockChain) err = transformer.Execute() @@ -77,13 +77,13 @@ var _ = Describe("Price feeds transformer", func() { config.StartingBlockNumber = blockNumber config.EndingBlockNumber = blockNumber - transformerInitializer := factories.Transformer{ + transformerInitializer := factories.LogNoteTransformer{ Config: config, Converter: &price_feeds.PriceFeedConverter{}, Repository: &price_feeds.PriceFeedRepository{}, Fetcher: &shared.Fetcher{}, } - transformer := transformerInitializer.NewTransformer(db, blockChain) + transformer := transformerInitializer.NewLogNoteTransformer(db, blockChain) err = transformer.Execute() @@ -104,13 +104,13 @@ var _ = Describe("Price feeds transformer", func() { config.StartingBlockNumber = blockNumber config.EndingBlockNumber = blockNumber - transformerInitializer := factories.Transformer{ + transformerInitializer := factories.LogNoteTransformer{ Config: config, Converter: &price_feeds.PriceFeedConverter{}, Repository: &price_feeds.PriceFeedRepository{}, Fetcher: &shared.Fetcher{}, } - transformer := transformerInitializer.NewTransformer(db, blockChain) + transformer := transformerInitializer.NewLogNoteTransformer(db, blockChain) err = transformer.Execute() diff --git a/pkg/transformers/integration_tests/tend.go b/pkg/transformers/integration_tests/tend.go index f54f2c86..6295440e 100644 --- a/pkg/transformers/integration_tests/tend.go +++ b/pkg/transformers/integration_tests/tend.go @@ -24,7 +24,7 @@ import ( "github.com/vulcanize/vulcanizedb/test_config" ) -var _ = Describe("Tend Transformer", func() { +var _ = Describe("Tend LogNoteTransformer", func() { It("fetches and transforms a Tend event from Kovan chain", func() { blockNumber := int64(8935601) config := tend.TendConfig @@ -42,13 +42,13 @@ var _ = Describe("Tend Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &tend.TendConverter{}, Repository: &tend.TendRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) @@ -81,13 +81,13 @@ var _ = Describe("Tend Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &tend.TendConverter{}, Repository: &tend.TendRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/vat_flux.go b/pkg/transformers/integration_tests/vat_flux.go index 025ae23a..2cd8ae17 100644 --- a/pkg/transformers/integration_tests/vat_flux.go +++ b/pkg/transformers/integration_tests/vat_flux.go @@ -24,7 +24,7 @@ import ( "github.com/vulcanize/vulcanizedb/test_config" ) -var _ = Describe("VatFlux Transformer", func() { +var _ = Describe("VatFlux LogNoteTransformer", func() { It("transforms VatFlux log events", func() { blockNumber := int64(9004474) config := vat_flux.VatFluxConfig @@ -42,13 +42,13 @@ var _ = Describe("VatFlux Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &vat_flux.VatFluxConverter{}, Repository: &vat_flux.VatFluxRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/vat_fold.go b/pkg/transformers/integration_tests/vat_fold.go index cfbfa4e4..ddb699d8 100644 --- a/pkg/transformers/integration_tests/vat_fold.go +++ b/pkg/transformers/integration_tests/vat_fold.go @@ -43,13 +43,13 @@ var _ = Describe("VatFold Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &vat_fold.VatFoldConverter{}, Repository: &vat_fold.VatFoldRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/vat_grab.go b/pkg/transformers/integration_tests/vat_grab.go index 5cde028d..a942cbc5 100644 --- a/pkg/transformers/integration_tests/vat_grab.go +++ b/pkg/transformers/integration_tests/vat_grab.go @@ -44,12 +44,12 @@ var _ = Describe("Vat Grab Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - transformer := factories.Transformer{ + transformer := factories.LogNoteTransformer{ Config: vat_grab.VatGrabConfig, Converter: &vat_grab.VatGrabConverter{}, Repository: &vat_grab.VatGrabRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer(db, blockchain) + }.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/vat_heal.go b/pkg/transformers/integration_tests/vat_heal.go index 0a2609e3..de98fbb3 100644 --- a/pkg/transformers/integration_tests/vat_heal.go +++ b/pkg/transformers/integration_tests/vat_heal.go @@ -43,12 +43,12 @@ var _ = Describe("VatHeal Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - transformer := factories.Transformer{ + transformer := factories.LogNoteTransformer{ Config: vat_heal.VatHealConfig, Converter: &vat_heal.VatHealConverter{}, Repository: &vat_heal.VatHealRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer(db, blockchain) + }.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/vat_init.go b/pkg/transformers/integration_tests/vat_init.go index fba3d380..fa4f2d8d 100644 --- a/pkg/transformers/integration_tests/vat_init.go +++ b/pkg/transformers/integration_tests/vat_init.go @@ -24,7 +24,7 @@ import ( "github.com/vulcanize/vulcanizedb/test_config" ) -var _ = Describe("VatInit Transformer", func() { +var _ = Describe("VatInit LogNoteTransformer", func() { It("transforms VatInit log events", func() { blockNumber := int64(8535561) config := vat_init.VatInitConfig @@ -42,13 +42,13 @@ var _ = Describe("VatInit Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &vat_init.VatInitConverter{}, Repository: &vat_init.VatInitRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/vat_move.go b/pkg/transformers/integration_tests/vat_move.go index 5819c989..ab1bec54 100644 --- a/pkg/transformers/integration_tests/vat_move.go +++ b/pkg/transformers/integration_tests/vat_move.go @@ -25,7 +25,7 @@ import ( "github.com/vulcanize/vulcanizedb/test_config" ) -var _ = Describe("VatMove Transformer", func() { +var _ = Describe("VatMove LogNoteTransformer", func() { It("transforms VatMove log events", func() { blockNumber := int64(9004628) config := vat_move.VatMoveConfig @@ -43,13 +43,13 @@ var _ = Describe("VatMove Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &vat_move.VatMoveConverter{}, Repository: &vat_move.VatMoveRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/integration_tests/vat_slip.go b/pkg/transformers/integration_tests/vat_slip.go index 68cb9673..0dcc6494 100644 --- a/pkg/transformers/integration_tests/vat_slip.go +++ b/pkg/transformers/integration_tests/vat_slip.go @@ -34,13 +34,13 @@ var _ = Describe("Vat slip transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &vat_slip.VatSlipConverter{}, Repository: &vat_slip.VatSlipRepository{}, } - transformer := initializer.NewTransformer(db, blockChain) + transformer := initializer.NewLogNoteTransformer(db, blockChain) err = transformer.Execute() diff --git a/pkg/transformers/integration_tests/vat_tune.go b/pkg/transformers/integration_tests/vat_tune.go index e09446af..44480210 100644 --- a/pkg/transformers/integration_tests/vat_tune.go +++ b/pkg/transformers/integration_tests/vat_tune.go @@ -26,7 +26,7 @@ import ( "github.com/vulcanize/vulcanizedb/test_config" ) -var _ = Describe("VatTune Transformer", func() { +var _ = Describe("VatTune LogNoteTransformer", func() { It("transforms VatTune log events", func() { blockNumber := int64(8761670) config := vat_tune.VatTuneConfig @@ -44,13 +44,13 @@ var _ = Describe("VatTune Transformer", func() { err = persistHeader(db, blockNumber) Expect(err).NotTo(HaveOccurred()) - initializer := factories.Transformer{ + initializer := factories.LogNoteTransformer{ Config: config, Fetcher: &shared.Fetcher{}, Converter: &vat_tune.VatTuneConverter{}, Repository: &vat_tune.VatTuneRepository{}, } - transformer := initializer.NewTransformer(db, blockchain) + transformer := initializer.NewLogNoteTransformer(db, blockchain) err = transformer.Execute() Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/pit_file/debt_ceiling/transformer_test.go b/pkg/transformers/pit_file/debt_ceiling/transformer_test.go index 6f9e6104..8f6466c2 100644 --- a/pkg/transformers/pit_file/debt_ceiling/transformer_test.go +++ b/pkg/transformers/pit_file/debt_ceiling/transformer_test.go @@ -35,7 +35,7 @@ var _ = Describe("Pit file debt ceiling transformer", func() { var ( config = debt_ceiling.DebtCeilingFileConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -44,16 +44,16 @@ var _ = Describe("Pit file debt ceiling transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Fetcher: &fetcher, Converter: &converter, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/pit_file/ilk/transformer_test.go b/pkg/transformers/pit_file/ilk/transformer_test.go index 5f3114cb..6e5b866a 100644 --- a/pkg/transformers/pit_file/ilk/transformer_test.go +++ b/pkg/transformers/pit_file/ilk/transformer_test.go @@ -35,7 +35,7 @@ var _ = Describe("Pit file ilk transformer", func() { var ( config = ilk.IlkFileConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -44,16 +44,16 @@ var _ = Describe("Pit file ilk transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Repository: &repository, Fetcher: &fetcher, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/pit_file/stability_fee/transformer_test.go b/pkg/transformers/pit_file/stability_fee/transformer_test.go index b7a9c78d..65768ae6 100644 --- a/pkg/transformers/pit_file/stability_fee/transformer_test.go +++ b/pkg/transformers/pit_file/stability_fee/transformer_test.go @@ -35,7 +35,7 @@ var _ = Describe("Pit file stability fee transformer", func() { var ( config = stability_fee.StabilityFeeFileConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -44,14 +44,14 @@ var _ = Describe("Pit file stability fee transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Fetcher: &fetcher, Converter: &converter, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} }) diff --git a/pkg/transformers/price_feeds/transformer_test.go b/pkg/transformers/price_feeds/transformer_test.go index 9810a048..f8a94a38 100644 --- a/pkg/transformers/price_feeds/transformer_test.go +++ b/pkg/transformers/price_feeds/transformer_test.go @@ -34,7 +34,7 @@ var _ = Describe("Price feed transformer", func() { var ( config = price_feeds.PriceFeedConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -43,16 +43,16 @@ var _ = Describe("Price feed transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Fetcher: &fetcher, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and db", func() { diff --git a/pkg/transformers/tend/transformer_test.go b/pkg/transformers/tend/transformer_test.go index 06d89d66..20135c69 100644 --- a/pkg/transformers/tend/transformer_test.go +++ b/pkg/transformers/tend/transformer_test.go @@ -31,10 +31,10 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks" ) -var _ = Describe("Tend Transformer", func() { +var _ = Describe("Tend LogNoteTransformer", func() { var ( config = tend.TendConfig - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository fetcher mocks.MockLogFetcher transformer shared.Transformer @@ -43,17 +43,17 @@ var _ = Describe("Tend Transformer", func() { ) BeforeEach(func() { - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} fetcher = mocks.MockLogFetcher{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Fetcher: &fetcher, Converter: &converter, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/test_data/mocks/bite/converter.go b/pkg/transformers/test_data/mocks/bite/converter.go deleted file mode 100644 index 690ea408..00000000 --- a/pkg/transformers/test_data/mocks/bite/converter.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2018 Vulcanize -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package bite - -import ( - "github.com/ethereum/go-ethereum/core/types" - - . "github.com/vulcanize/vulcanizedb/pkg/transformers/bite" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -type MockBiteConverter struct { - ConverterAbi string - LogsToConvert []types.Log - EntitiesToConvert []BiteEntity - ConverterError error -} - -func (mbc *MockBiteConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]BiteEntity, error) { - mbc.ConverterAbi = contractAbi - mbc.LogsToConvert = append(mbc.LogsToConvert, ethLogs...) - return []BiteEntity{test_data.BiteEntity}, mbc.ConverterError -} - -func (mbc *MockBiteConverter) ToModels(entities []BiteEntity) ([]BiteModel, error) { - mbc.EntitiesToConvert = append(mbc.EntitiesToConvert, entities...) - return []BiteModel{test_data.BiteModel}, mbc.ConverterError -} - -func (mbc *MockBiteConverter) SetConverterError(err error) { - mbc.ConverterError = err -} diff --git a/pkg/transformers/test_data/mocks/bite/repository.go b/pkg/transformers/test_data/mocks/bite/repository.go deleted file mode 100644 index 3dea5239..00000000 --- a/pkg/transformers/test_data/mocks/bite/repository.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2018 Vulcanize -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package bite - -import ( - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/transformers/bite" -) - -type MockBiteRepository struct { - createError error - PassedEndingBlockNumber int64 - PassedBiteModels []bite.BiteModel - PassedHeaderID int64 - PassedStartingBlockNumber int64 - PassedTransactionIndex uint - markHeaderCheckedErr error - markHeaderCheckedPassedHeaderID int64 - missingHeaders []core.Header - missingHeadersErr error -} - -func (repository *MockBiteRepository) SetCreateError(err error) { - repository.createError = err -} - -func (repository *MockBiteRepository) SetMissingHeadersErr(err error) { - repository.missingHeadersErr = err -} - -func (repository *MockBiteRepository) SetMissingHeaders(headers []core.Header) { - repository.missingHeaders = headers -} - -func (repository *MockBiteRepository) Create(headerID int64, models []bite.BiteModel) error { - repository.PassedHeaderID = headerID - repository.PassedBiteModels = models - return repository.createError -} - -func (repository *MockBiteRepository) MarkHeaderChecked(headerID int64) error { - repository.markHeaderCheckedPassedHeaderID = headerID - return repository.markHeaderCheckedErr -} - -func (repository *MockBiteRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - repository.PassedStartingBlockNumber = startingBlockNumber - repository.PassedEndingBlockNumber = endingBlockNumber - return repository.missingHeaders, repository.missingHeadersErr -} - -func (repository *MockBiteRepository) SetMarkHeaderCheckedErr(e error) { - repository.markHeaderCheckedErr = e -} - -func (repository *MockBiteRepository) AssertMarkHeaderCheckedCalledWith(i int64) { - Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i)) -} diff --git a/pkg/transformers/test_data/mocks/converter.go b/pkg/transformers/test_data/mocks/converter.go index 85670bc1..b6572bb2 100644 --- a/pkg/transformers/test_data/mocks/converter.go +++ b/pkg/transformers/test_data/mocks/converter.go @@ -5,20 +5,22 @@ import ( ) type MockConverter struct { - err error - returnModels []interface{} - PassedLogs []types.Log + ToEntitiesError error + ToModelsError error + ContractAbi string + LogsToConvert []types.Log + EntitiesToConvert []interface{} + EntitiesToReturn []interface{} + ModelsToReturn []interface{} } -func (converter *MockConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - converter.PassedLogs = ethLogs - return converter.returnModels, converter.err +func (converter *MockConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]interface{}, error) { + converter.ContractAbi = contractAbi + converter.LogsToConvert = ethLogs + return converter.EntitiesToReturn, converter.ToEntitiesError } -func (converter *MockConverter) SetConverterError(e error) { - converter.err = e -} - -func (converter *MockConverter) SetReturnModels(models []interface{}) { - converter.returnModels = models +func (converter *MockConverter) ToModels(entities []interface{}) ([]interface{}, error) { + converter.EntitiesToConvert = entities + return converter.ModelsToReturn, converter.ToModelsError } diff --git a/pkg/transformers/test_data/mocks/log_note_converter.go b/pkg/transformers/test_data/mocks/log_note_converter.go new file mode 100644 index 00000000..08369a7d --- /dev/null +++ b/pkg/transformers/test_data/mocks/log_note_converter.go @@ -0,0 +1,24 @@ +package mocks + +import ( + "github.com/ethereum/go-ethereum/core/types" +) + +type MockLogNoteConverter struct { + err error + returnModels []interface{} + PassedLogs []types.Log +} + +func (converter *MockLogNoteConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { + converter.PassedLogs = ethLogs + return converter.returnModels, converter.err +} + +func (converter *MockLogNoteConverter) SetConverterError(e error) { + converter.err = e +} + +func (converter *MockLogNoteConverter) SetReturnModels(models []interface{}) { + converter.returnModels = models +} diff --git a/pkg/transformers/transformers.go b/pkg/transformers/transformers.go index 2bf9393c..9f78ae57 100644 --- a/pkg/transformers/transformers.go +++ b/pkg/transformers/transformers.go @@ -48,158 +48,172 @@ import ( ) var ( - BiteTransformerInitializer = bite.BiteTransformerInitializer{Config: bite.BiteConfig}.NewBiteTransformer + BiteTransformerInitializer = factories.Transformer{ + Config: bite.BiteConfig, + Converter: &bite.BiteConverter{}, + Repository: &bite.BiteRepository{}, + Fetcher: &shared.Fetcher{}, + }.NewTransformer - CatFileChopLumpTransformerInitializer = factories.Transformer{ + CatFileChopLumpTransformerInitializer = factories.LogNoteTransformer{ Config: chop_lump.CatFileChopLumpConfig, Converter: &chop_lump.CatFileChopLumpConverter{}, Repository: &chop_lump.CatFileChopLumpRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer - CatFileFlipTransformerInitializer = factories.Transformer{ + CatFileFlipTransformerInitializer = factories.LogNoteTransformer{ Config: flip.CatFileFlipConfig, Converter: &flip.CatFileFlipConverter{}, Repository: &flip.CatFileFlipRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer - CatFilePitVowTransformerInitializer = factories.Transformer{ + CatFilePitVowTransformerInitializer = factories.LogNoteTransformer{ Config: pit_vow.CatFilePitVowConfig, Converter: &pit_vow.CatFilePitVowConverter{}, Repository: &pit_vow.CatFilePitVowRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer - DealTransformerInitializer = factories.Transformer{ + DealTransformerInitializer = factories.LogNoteTransformer{ Config: deal.DealConfig, Converter: &deal.DealConverter{}, Repository: &deal.DealRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer DentTransformerInitializer = dent.DentTransformerInitializer{Config: dent.DentConfig}.NewDentTransformer DripDripTransformerInitializer = drip_drip.DripDripTransformerInitializer{Config: drip_drip.DripDripConfig}.NewDripDripTransformer - DripFileIlkTransformerInitializer = factories.Transformer{ + + DripFileIlkTransformerInitializer = factories.LogNoteTransformer{ Config: ilk2.DripFileIlkConfig, Converter: &ilk2.DripFileIlkConverter{}, Repository: &ilk2.DripFileIlkRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer - DripFileRepoTransformerInitializer = factories.Transformer{ + DripFileRepoTransformerInitializer = factories.LogNoteTransformer{ Config: repo.DripFileRepoConfig, Converter: &repo.DripFileRepoConverter{}, Repository: &repo.DripFileRepoRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer - DripFileVowTransfromerInitializer = factories.Transformer{ + DripFileVowTransfromerInitializer = factories.LogNoteTransformer{ Config: vow.DripFileVowConfig, Converter: &vow.DripFileVowConverter{}, Repository: &vow.DripFileVowRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer FlipKickTransformerInitializer = flip_kick.FlipKickTransformerInitializer{Config: flip_kick.FlipKickConfig}.NewFlipKickTransformer - FlogTransformerInitializer = factories.Transformer{ + FlogTransformerInitializer = factories.LogNoteTransformer{ Config: flog.FlogConfig, Converter: &flog.FlogConverter{}, Repository: &flog.FlogRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer FlopKickTransformerInitializer = flop_kick.FlopKickTransformerInitializer{Config: flop_kick.Config}.NewFlopKickTransformer FrobTransformerInitializer = frob.FrobTransformerInitializer{Config: frob.FrobConfig}.NewFrobTransformer - PitFileDebtCeilingTransformerInitializer = factories.Transformer{ + PitFileDebtCeilingTransformerInitializer = factories.LogNoteTransformer{ Config: debt_ceiling.DebtCeilingFileConfig, Converter: &debt_ceiling.PitFileDebtCeilingConverter{}, Repository: &debt_ceiling.PitFileDebtCeilingRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer - PitFileIlkTransformerInitializer = factories.Transformer{ + PitFileIlkTransformerInitializer = factories.LogNoteTransformer{ Config: ilk.IlkFileConfig, Converter: &ilk.PitFileIlkConverter{}, Repository: &ilk.PitFileIlkRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer - PitFileStabilityFeeTransformerInitializer = factories.Transformer{ + PitFileStabilityFeeTransformerInitializer = factories.LogNoteTransformer{ Config: stability_fee.StabilityFeeFileConfig, Converter: &stability_fee.PitFileStabilityFeeConverter{}, Repository: &stability_fee.PitFileStabilityFeeRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer - PriceFeedTransformerInitializer = factories.Transformer{ + PriceFeedTransformerInitializer = factories.LogNoteTransformer{ Config: price_feeds.PriceFeedConfig, Converter: &price_feeds.PriceFeedConverter{}, Repository: &price_feeds.PriceFeedRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer - TendTransformerInitializer = factories.Transformer{ + TendTransformerInitializer = factories.LogNoteTransformer{ Config: tend.TendConfig, Converter: &tend.TendConverter{}, Repository: &tend.TendRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer - VatInitTransformerInitializer = factories.Transformer{ + VatInitTransformerInitializer = factories.LogNoteTransformer{ Config: vat_init.VatInitConfig, Converter: &vat_init.VatInitConverter{}, Repository: &vat_init.VatInitRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer - VatGrabTransformerInitializer = factories.Transformer{ + }.NewLogNoteTransformer + + VatGrabTransformerInitializer = factories.LogNoteTransformer{ Config: vat_grab.VatGrabConfig, Converter: &vat_grab.VatGrabConverter{}, Repository: &vat_grab.VatGrabRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer - VatFoldTransformerInitializer = factories.Transformer{ + }.NewLogNoteTransformer + + VatFoldTransformerInitializer = factories.LogNoteTransformer{ Config: vat_fold.VatFoldConfig, Converter: &vat_fold.VatFoldConverter{}, Repository: &vat_fold.VatFoldRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer - VatHealTransformerInitializer = factories.Transformer{ + }.NewLogNoteTransformer + + VatHealTransformerInitializer = factories.LogNoteTransformer{ Config: vat_heal.VatHealConfig, Converter: &vat_heal.VatHealConverter{}, Repository: &vat_heal.VatHealRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer - VatMoveTransformerInitializer = factories.Transformer{ + }.NewLogNoteTransformer + + VatMoveTransformerInitializer = factories.LogNoteTransformer{ Config: vat_move.VatMoveConfig, Converter: &vat_move.VatMoveConverter{}, Repository: &vat_move.VatMoveRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer - VatSlipTransformerInitializer = factories.Transformer{ + }.NewLogNoteTransformer + + VatSlipTransformerInitializer = factories.LogNoteTransformer{ Config: vat_slip.VatSlipConfig, Converter: &vat_slip.VatSlipConverter{}, Repository: &vat_slip.VatSlipRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer - VatTollTransformerInitializer = factories.Transformer{ + }.NewLogNoteTransformer + + VatTollTransformerInitializer = factories.LogNoteTransformer{ Config: vat_toll.VatTollConfig, Converter: &vat_toll.VatTollConverter{}, Repository: &vat_toll.VatTollRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer - VatTuneTransformerInitializer = factories.Transformer{ + }.NewLogNoteTransformer + + VatTuneTransformerInitializer = factories.LogNoteTransformer{ Config: vat_tune.VatTuneConfig, Converter: &vat_tune.VatTuneConverter{}, Repository: &vat_tune.VatTuneRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer - VatFluxTransformerInitializer = factories.Transformer{ + }.NewLogNoteTransformer + + VatFluxTransformerInitializer = factories.LogNoteTransformer{ Config: vat_flux.VatFluxConfig, Converter: &vat_flux.VatFluxConverter{}, Repository: &vat_flux.VatFluxRepository{}, Fetcher: &shared.Fetcher{}, - }.NewTransformer + }.NewLogNoteTransformer ) func TransformerInitializers() []shared.TransformerInitializer { diff --git a/pkg/transformers/vat_flux/transformer_test.go b/pkg/transformers/vat_flux/transformer_test.go index e7858633..c2fc0415 100644 --- a/pkg/transformers/vat_flux/transformer_test.go +++ b/pkg/transformers/vat_flux/transformer_test.go @@ -21,7 +21,7 @@ var _ = Describe("Vat flux transformer", func() { var ( config = vat_flux.VatFluxConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -30,16 +30,16 @@ var _ = Describe("Vat flux transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Fetcher: &fetcher, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/vat_fold/transformer_test.go b/pkg/transformers/vat_fold/transformer_test.go index e72e404f..00a0782d 100644 --- a/pkg/transformers/vat_fold/transformer_test.go +++ b/pkg/transformers/vat_fold/transformer_test.go @@ -35,7 +35,7 @@ var _ = Describe("Vat fold transformer", func() { var ( config = vat_fold.VatFoldConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -44,16 +44,16 @@ var _ = Describe("Vat fold transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Fetcher: &fetcher, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/vat_grab/converter_test.go b/pkg/transformers/vat_grab/converter_test.go index 86b25265..ee3f5fcc 100644 --- a/pkg/transformers/vat_grab/converter_test.go +++ b/pkg/transformers/vat_grab/converter_test.go @@ -6,13 +6,12 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_grab" ) var _ = Describe("Vat grab converter", func() { - var converter factories.Converter + var converter vat_grab.VatGrabConverter BeforeEach(func() { converter = vat_grab.VatGrabConverter{} diff --git a/pkg/transformers/vat_grab/transformer_test.go b/pkg/transformers/vat_grab/transformer_test.go index a621fa32..38d08784 100644 --- a/pkg/transformers/vat_grab/transformer_test.go +++ b/pkg/transformers/vat_grab/transformer_test.go @@ -18,7 +18,7 @@ import ( var _ = Describe("Vat grab transformer", func() { var ( config = vat_grab.VatGrabConfig - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository fetcher mocks.MockLogFetcher transformer shared.Transformer @@ -27,13 +27,13 @@ var _ = Describe("Vat grab transformer", func() { BeforeEach(func() { repository = mocks.MockRepository{} fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} - transformer = factories.Transformer{ + converter = mocks.MockLogNoteConverter{} + transformer = factories.LogNoteTransformer{ Config: config, Fetcher: &fetcher, Converter: &converter, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/vat_heal/transformer_test.go b/pkg/transformers/vat_heal/transformer_test.go index b90dfcd8..04f1d7d7 100644 --- a/pkg/transformers/vat_heal/transformer_test.go +++ b/pkg/transformers/vat_heal/transformer_test.go @@ -36,20 +36,20 @@ var _ = Describe("VatHeal Transformer", func() { repository mocks.MockRepository transformer shared.Transformer fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter config = vat_heal.VatHealConfig ) BeforeEach(func() { repository = mocks.MockRepository{} fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} - transformer = factories.Transformer{ + converter = mocks.MockLogNoteConverter{} + transformer = factories.LogNoteTransformer{ Repository: &repository, Config: config, Fetcher: &fetcher, Converter: &converter, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the database and blockchain", func() { diff --git a/pkg/transformers/vat_init/transformer_test.go b/pkg/transformers/vat_init/transformer_test.go index 6059ae2d..de39e6a2 100644 --- a/pkg/transformers/vat_init/transformer_test.go +++ b/pkg/transformers/vat_init/transformer_test.go @@ -34,7 +34,7 @@ import ( var _ = Describe("Vat init transformer", func() { var ( config = vat_init.VatInitConfig - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository fetcher mocks.MockLogFetcher transformer shared.Transformer @@ -43,17 +43,17 @@ var _ = Describe("Vat init transformer", func() { ) BeforeEach(func() { - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} fetcher = mocks.MockLogFetcher{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Fetcher: &fetcher, Converter: &converter, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/vat_move/transformer_test.go b/pkg/transformers/vat_move/transformer_test.go index 384d88e1..65df2869 100644 --- a/pkg/transformers/vat_move/transformer_test.go +++ b/pkg/transformers/vat_move/transformer_test.go @@ -34,7 +34,7 @@ import ( var _ = Describe("Vat move transformer", func() { var config = vat_move.VatMoveConfig var fetcher mocks.MockLogFetcher - var converter mocks.MockConverter + var converter mocks.MockLogNoteConverter var repository mocks.MockRepository var transformer shared.Transformer var headerOne core.Header @@ -42,16 +42,16 @@ var _ = Describe("Vat move transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Fetcher: &fetcher, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/vat_slip/transformer_test.go b/pkg/transformers/vat_slip/transformer_test.go index 54393daf..13c07f08 100644 --- a/pkg/transformers/vat_slip/transformer_test.go +++ b/pkg/transformers/vat_slip/transformer_test.go @@ -20,7 +20,7 @@ var _ = Describe("Vat slip transformer", func() { var ( config = vat_slip.VatSlipConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -29,16 +29,16 @@ var _ = Describe("Vat slip transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Fetcher: &fetcher, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/vat_toll/transformer_test.go b/pkg/transformers/vat_toll/transformer_test.go index 707bfd6b..2d5888b4 100644 --- a/pkg/transformers/vat_toll/transformer_test.go +++ b/pkg/transformers/vat_toll/transformer_test.go @@ -21,7 +21,7 @@ var _ = Describe("Vat toll transformer", func() { var ( config = vat_toll.VatTollConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -30,16 +30,16 @@ var _ = Describe("Vat toll transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Fetcher: &fetcher, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() { diff --git a/pkg/transformers/vat_tune/transformer_test.go b/pkg/transformers/vat_tune/transformer_test.go index 2c9b3a4a..e5435292 100644 --- a/pkg/transformers/vat_tune/transformer_test.go +++ b/pkg/transformers/vat_tune/transformer_test.go @@ -21,7 +21,7 @@ var _ = Describe("Vat tune transformer", func() { var ( config = vat_tune.VatTuneConfig fetcher mocks.MockLogFetcher - converter mocks.MockConverter + converter mocks.MockLogNoteConverter repository mocks.MockRepository transformer shared.Transformer headerOne core.Header @@ -30,16 +30,16 @@ var _ = Describe("Vat tune transformer", func() { BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = mocks.MockConverter{} + converter = mocks.MockLogNoteConverter{} repository = mocks.MockRepository{} headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - transformer = factories.Transformer{ + transformer = factories.LogNoteTransformer{ Config: config, Converter: &converter, Fetcher: &fetcher, Repository: &repository, - }.NewTransformer(nil, nil) + }.NewLogNoteTransformer(nil, nil) }) It("sets the blockchain and database", func() {