From ed624330f6f3bfd5811b031406436984c23bd251 Mon Sep 17 00:00:00 2001 From: Rob Mulholand Date: Fri, 26 Oct 2018 14:31:02 -0500 Subject: [PATCH] Rename Flog pack to Vow flog - enables differentiation if another contract implements flog - also deletes flog-specific mocks --- cmd/continuousLogSync.go | 2 +- pkg/transformers/shared/constants.go | 30 ++++---- .../test_data/mocks/flog/converter.go | 34 --------- .../test_data/mocks/flog/repository.go | 70 ------------------- .../test_data/{flog.go => vow_flog.go} | 4 +- pkg/transformers/transformers.go | 8 +-- pkg/transformers/{flog => vow_flog}/config.go | 8 +-- .../{flog => vow_flog}/converter.go | 8 +-- .../{flog => vow_flog}/converter_test.go | 12 ++-- pkg/transformers/{flog => vow_flog}/model.go | 4 +- .../{flog => vow_flog}/repository.go | 16 ++--- .../{flog => vow_flog}/repository_test.go | 24 +++---- .../{flog => vow_flog}/transformer_test.go | 32 +++++---- .../vow_flog_suite_test.go} | 6 +- 14 files changed, 78 insertions(+), 180 deletions(-) delete mode 100644 pkg/transformers/test_data/mocks/flog/converter.go delete mode 100644 pkg/transformers/test_data/mocks/flog/repository.go rename pkg/transformers/test_data/{flog.go => vow_flog.go} (95%) rename pkg/transformers/{flog => vow_flog}/config.go (83%) rename pkg/transformers/{flog => vow_flog}/converter.go (90%) rename pkg/transformers/{flog => vow_flog}/converter_test.go (83%) rename pkg/transformers/{flog => vow_flog}/model.go (94%) rename pkg/transformers/{flog => vow_flog}/repository.go (80%) rename pkg/transformers/{flog => vow_flog}/repository_test.go (92%) rename pkg/transformers/{flog => vow_flog}/transformer_test.go (87%) rename pkg/transformers/{flog/flog_suite_test.go => vow_flog/vow_flog_suite_test.go} (90%) diff --git a/cmd/continuousLogSync.go b/cmd/continuousLogSync.go index 0fc660c7..859a720b 100644 --- a/cmd/continuousLogSync.go +++ b/cmd/continuousLogSync.go @@ -97,7 +97,7 @@ func buildTransformerInitializerMap() map[string]shared2.TransformerInitializer transformerInitializerMap[shared2.DripFileRepoLabel] = transformers.DripFileRepoTransformerInitializer transformerInitializerMap[shared2.DripFileVowLabel] = transformers.DripFileVowTransfromerInitializer transformerInitializerMap[shared2.FlipKickLabel] = transformers.FlipKickTransformerInitializer - transformerInitializerMap[shared2.FlogLabel] = transformers.FlogTransformerInitializer + transformerInitializerMap[shared2.VowFlogLabel] = transformers.FlogTransformerInitializer transformerInitializerMap[shared2.FlopKickLabel] = transformers.FlopKickTransformerInitializer transformerInitializerMap[shared2.FrobLabel] = transformers.FrobTransformerInitializer transformerInitializerMap[shared2.PitFileDebtCeilingLabel] = transformers.PitFileDebtCeilingTransformerInitializer diff --git a/pkg/transformers/shared/constants.go b/pkg/transformers/shared/constants.go index 04bcad66..281c1107 100644 --- a/pkg/transformers/shared/constants.go +++ b/pkg/transformers/shared/constants.go @@ -50,7 +50,7 @@ var ( VatContractAddress = getContractValue("contract.vat", "0xcd726790550afcd77e9a7a47e86a3f9010af126b") VowContractAddress = getContractValue("contract.vow", "0x3728e9777B2a0a611ee0F89e00E01044ce4736d1") - //TODO: get pit and drip file method signatures directly from the ABI + //TODO: get cat, pit, and drip file method signatures directly from the ABI biteMethod = GetSolidityMethodSignature(CatABI, "Bite") catFileChopLumpMethod = "file(bytes32,bytes32,uint256)" catFileFlipMethod = GetSolidityMethodSignature(CatABI, "file") @@ -62,7 +62,6 @@ var ( dripFileRepoMethod = GetSolidityMethodSignature(DripABI, "file") dripFileVowMethod = "file(bytes32,bytes32)" flipKickMethod = GetSolidityMethodSignature(FlipperABI, "Kick") - flogMethod = GetSolidityMethodSignature(VowABI, "flog") flopKickMethod = GetSolidityMethodSignature(FlopperABI, "Kick") frobMethod = GetSolidityMethodSignature(PitABI, "Frob") logValueMethod = GetSolidityMethodSignature(MedianizerABI, "LogValue") @@ -70,28 +69,28 @@ var ( pitFileIlkMethod = "file(bytes32,bytes32,uint256)" pitFileStabilityFeeMethod = GetSolidityMethodSignature(PitABI, "file") tendMethod = GetSolidityMethodSignature(FlipperABI, "tend") - vatHealMethod = GetSolidityMethodSignature(VatABI, "heal") + vatFluxMethod = GetSolidityMethodSignature(VatABI, "flux") + vatFoldMethod = GetSolidityMethodSignature(VatABI, "fold") vatGrabMethod = GetSolidityMethodSignature(VatABI, "grab") + vatHealMethod = GetSolidityMethodSignature(VatABI, "heal") vatInitMethod = GetSolidityMethodSignature(VatABI, "init") vatMoveMethod = GetSolidityMethodSignature(VatABI, "move") - vatFoldMethod = GetSolidityMethodSignature(VatABI, "fold") vatSlipMethod = GetSolidityMethodSignature(VatABI, "slip") vatTollMethod = GetSolidityMethodSignature(VatABI, "toll") vatTuneMethod = GetSolidityMethodSignature(VatABI, "tune") - vatFluxMethod = GetSolidityMethodSignature(VatABI, "flux") + vowFlogMethod = GetSolidityMethodSignature(VowABI, "flog") BiteSignature = GetEventSignature(biteMethod) - DealSignature = GetLogNoteSignature(dealMethod) CatFileChopLumpSignature = GetLogNoteSignature(catFileChopLumpMethod) CatFileFlipSignature = GetLogNoteSignature(catFileFlipMethod) CatFilePitVowSignature = GetLogNoteSignature(catFilePitVowMethod) + DealSignature = GetLogNoteSignature(dealMethod) DentFunctionSignature = GetLogNoteSignature(dentMethod) DripDripSignature = GetLogNoteSignature(dripDripMethod) DripFileIlkSignature = GetLogNoteSignature(dripFileIlkMethod) DripFileRepoSignature = GetLogNoteSignature(dripFileRepoMethod) DripFileVowSignature = GetLogNoteSignature(dripFileVowMethod) FlipKickSignature = GetEventSignature(flipKickMethod) - FlogSignature = GetLogNoteSignature(flogMethod) FlopKickSignature = GetEventSignature(flopKickMethod) FrobSignature = GetEventSignature(frobMethod) LogValueSignature = GetEventSignature(logValueMethod) @@ -99,28 +98,28 @@ var ( PitFileIlkSignature = GetLogNoteSignature(pitFileIlkMethod) PitFileStabilityFeeSignature = GetLogNoteSignature(pitFileStabilityFeeMethod) TendFunctionSignature = GetLogNoteSignature(tendMethod) - VatHealSignature = GetLogNoteSignature(vatHealMethod) + VatFluxSignature = GetLogNoteSignature(vatFluxMethod) + VatFoldSignature = GetLogNoteSignature(vatFoldMethod) VatGrabSignature = GetLogNoteSignature(vatGrabMethod) + VatHealSignature = GetLogNoteSignature(vatHealMethod) VatInitSignature = GetLogNoteSignature(vatInitMethod) VatMoveSignature = GetLogNoteSignature(vatMoveMethod) - VatFoldSignature = GetLogNoteSignature(vatFoldMethod) VatSlipSignature = GetLogNoteSignature(vatSlipMethod) VatTollSignature = GetLogNoteSignature(vatTollMethod) VatTuneSignature = GetLogNoteSignature(vatTuneMethod) - VatFluxSignature = GetLogNoteSignature(vatFluxMethod) + VowFlogSignature = GetLogNoteSignature(vowFlogMethod) BiteLabel = "bite" - DealLabel = "deal" CatFileChopLumpLabel = "catFileChopLump" CatFileFlipLabel = "catFileFlip" CatFilePitVowLabel = "catFilePitVow" + DealLabel = "deal" DentLabel = "dent" DripDripLabel = "dripDrip" DripFileIlkLabel = "dripFileIlk" DripFileRepoLabel = "dripFileRepo" DripFileVowLabel = "dripFileVow" FlipKickLabel = "flipKick" - FlogLabel = "flog" FlopKickLabel = "flopKick" FrobLabel = "frob" PitFileDebtCeilingLabel = "pitFileDebtCeiling" @@ -128,13 +127,14 @@ var ( PitFileStabilityFeeLabel = "pitFileStabilityFee" PriceFeedLabel = "priceFeed" TendLabel = "tend" - VatHealLabel = "vatHeal" + VatFluxLabel = "vatFlux" + VatFoldLabel = "vatFold" VatGrabLabel = "vatGrab" + VatHealLabel = "vatHeal" VatInitLabel = "vatInit" VatMoveLabel = "vatMove" - VatFoldLabel = "vatFold" VatSlipLabel = "vatSlip" VatTollLabel = "vatToll" VatTuneLabel = "vatTune" - VatFluxLabel = "vatFlux" + VowFlogLabel = "vowFlog" ) diff --git a/pkg/transformers/test_data/mocks/flog/converter.go b/pkg/transformers/test_data/mocks/flog/converter.go deleted file mode 100644 index a53ca340..00000000 --- a/pkg/transformers/test_data/mocks/flog/converter.go +++ /dev/null @@ -1,34 +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 flog - -import ( - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -type MockFlogConverter struct { - converterError error - PassedLogs []types.Log -} - -func (converter *MockFlogConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - converter.PassedLogs = ethLogs - return []interface{}{test_data.FlogModel}, converter.converterError -} - -func (converter *MockFlogConverter) SetConverterError(e error) { - converter.converterError = e -} diff --git a/pkg/transformers/test_data/mocks/flog/repository.go b/pkg/transformers/test_data/mocks/flog/repository.go deleted file mode 100644 index 585d9aff..00000000 --- a/pkg/transformers/test_data/mocks/flog/repository.go +++ /dev/null @@ -1,70 +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 flog - -import ( - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" -) - -type MockFlogRepository struct { - createError error - missingHeaders []core.Header - missingHeadersError error - PassedStartingBlockNumber int64 - PassedEndingBlockNumber int64 - PassedHeaderID int64 - PassedModels []interface{} - CheckedHeaderIDs []int64 - CheckedHeaderError error - SetDbCalled bool -} - -func (repository *MockFlogRepository) Create(headerID int64, models []interface{}) error { - repository.PassedHeaderID = headerID - repository.PassedModels = models - return repository.createError -} - -func (repository *MockFlogRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - repository.PassedStartingBlockNumber = startingBlockNumber - repository.PassedEndingBlockNumber = endingBlockNumber - return repository.missingHeaders, repository.missingHeadersError -} - -func (repository *MockFlogRepository) SetMissingHeadersError(e error) { - repository.missingHeadersError = e -} - -func (repository *MockFlogRepository) SetMissingHeaders(headers []core.Header) { - repository.missingHeaders = headers -} - -func (repository *MockFlogRepository) SetCreateError(e error) { - repository.createError = e -} - -func (repository *MockFlogRepository) MarkHeaderChecked(headerId int64) error { - repository.CheckedHeaderIDs = append(repository.CheckedHeaderIDs, headerId) - return repository.CheckedHeaderError -} - -func (repository *MockFlogRepository) SetCheckedHeaderError(e error) { - repository.CheckedHeaderError = e -} - -func (repository *MockFlogRepository) SetDB(db *postgres.DB) { - repository.SetDbCalled = true -} diff --git a/pkg/transformers/test_data/flog.go b/pkg/transformers/test_data/vow_flog.go similarity index 95% rename from pkg/transformers/test_data/flog.go rename to pkg/transformers/test_data/vow_flog.go index 9964d120..53ab56bc 100644 --- a/pkg/transformers/test_data/flog.go +++ b/pkg/transformers/test_data/vow_flog.go @@ -19,7 +19,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flog" + "github.com/vulcanize/vulcanizedb/pkg/transformers/vow_flog" "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" ) @@ -42,7 +42,7 @@ var EthFlogLog = types.Log{ } var rawFlogLog, _ = json.Marshal(EthFlogLog) -var FlogModel = flog.FlogModel{ +var FlogModel = vow_flog.VowFlogModel{ Era: "1337", LogIndex: EthFlogLog.Index, TransactionIndex: EthFlogLog.TxIndex, diff --git a/pkg/transformers/transformers.go b/pkg/transformers/transformers.go index 43e9ad5d..121690ef 100644 --- a/pkg/transformers/transformers.go +++ b/pkg/transformers/transformers.go @@ -27,7 +27,6 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/vow" "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" "github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flog" "github.com/vulcanize/vulcanizedb/pkg/transformers/flop_kick" "github.com/vulcanize/vulcanizedb/pkg/transformers/frob" "github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/debt_ceiling" @@ -45,6 +44,7 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_slip" "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_toll" "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_tune" + "github.com/vulcanize/vulcanizedb/pkg/transformers/vow_flog" ) var ( @@ -120,9 +120,9 @@ var ( FlipKickTransformerInitializer = flip_kick.FlipKickTransformerInitializer{Config: flip_kick.FlipKickConfig}.NewFlipKickTransformer FlogTransformerInitializer = factories.LogNoteTransformer{ - Config: flog.FlogConfig, - Converter: &flog.FlogConverter{}, - Repository: &flog.FlogRepository{}, + Config: vow_flog.VowFlogConfig, + Converter: &vow_flog.VowFlogConverter{}, + Repository: &vow_flog.VowFlogRepository{}, Fetcher: &shared.Fetcher{}, }.NewLogNoteTransformer diff --git a/pkg/transformers/flog/config.go b/pkg/transformers/vow_flog/config.go similarity index 83% rename from pkg/transformers/flog/config.go rename to pkg/transformers/vow_flog/config.go index fcd9e54d..fd2c55f6 100644 --- a/pkg/transformers/flog/config.go +++ b/pkg/transformers/vow_flog/config.go @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -package flog +package vow_flog import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -var FlogConfig = shared.SingleTransformerConfig{ - TransformerName: shared.FlogLabel, +var VowFlogConfig = shared.SingleTransformerConfig{ + TransformerName: shared.VowFlogLabel, ContractAddresses: []string{shared.VowContractAddress}, ContractAbi: shared.VowABI, - Topic: shared.FlogSignature, + Topic: shared.VowFlogSignature, StartingBlockNumber: 0, EndingBlockNumber: 10000000, } diff --git a/pkg/transformers/flog/converter.go b/pkg/transformers/vow_flog/converter.go similarity index 90% rename from pkg/transformers/flog/converter.go rename to pkg/transformers/vow_flog/converter.go index d3704c04..ee7d97b2 100644 --- a/pkg/transformers/flog/converter.go +++ b/pkg/transformers/vow_flog/converter.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package flog +package vow_flog import ( "encoding/json" @@ -22,9 +22,9 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" ) -type FlogConverter struct{} +type VowFlogConverter struct{} -func (FlogConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { +func (VowFlogConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { var models []interface{} for _, ethLog := range ethLogs { err := verifyLog(ethLog) @@ -38,7 +38,7 @@ func (FlogConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { if err != nil { return nil, err } - model := FlogModel{ + model := VowFlogModel{ Era: era.String(), LogIndex: ethLog.Index, TransactionIndex: ethLog.TxIndex, diff --git a/pkg/transformers/flog/converter_test.go b/pkg/transformers/vow_flog/converter_test.go similarity index 83% rename from pkg/transformers/flog/converter_test.go rename to pkg/transformers/vow_flog/converter_test.go index 62428f0b..4849f06c 100644 --- a/pkg/transformers/flog/converter_test.go +++ b/pkg/transformers/vow_flog/converter_test.go @@ -12,22 +12,22 @@ // See the License for the specific language governing permissions and // limitations under the License. -package flog_test +package vow_flog_test import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flog" + "github.com/vulcanize/vulcanizedb/pkg/transformers/vow_flog" "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" ) -var _ = Describe("Flog converter", func() { - var converter flog.FlogConverter +var _ = Describe("Vow flog converter", func() { + var converter vow_flog.VowFlogConverter BeforeEach(func() { - converter = flog.FlogConverter{} + converter = vow_flog.VowFlogConverter{} }) It("returns err if log is missing topics", func() { @@ -53,6 +53,6 @@ var _ = Describe("Flog converter", func() { Expect(err).NotTo(HaveOccurred()) Expect(len(models)).To(Equal(1)) - Expect(models[0].(flog.FlogModel)).To(Equal(test_data.FlogModel)) + Expect(models[0].(vow_flog.VowFlogModel)).To(Equal(test_data.FlogModel)) }) }) diff --git a/pkg/transformers/flog/model.go b/pkg/transformers/vow_flog/model.go similarity index 94% rename from pkg/transformers/flog/model.go rename to pkg/transformers/vow_flog/model.go index 0698f422..569cd92d 100644 --- a/pkg/transformers/flog/model.go +++ b/pkg/transformers/vow_flog/model.go @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -package flog +package vow_flog -type FlogModel struct { +type VowFlogModel struct { Era string LogIndex uint `db:"log_idx"` TransactionIndex uint `db:"tx_idx"` diff --git a/pkg/transformers/flog/repository.go b/pkg/transformers/vow_flog/repository.go similarity index 80% rename from pkg/transformers/flog/repository.go rename to pkg/transformers/vow_flog/repository.go index 618e0802..78a22373 100644 --- a/pkg/transformers/flog/repository.go +++ b/pkg/transformers/vow_flog/repository.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package flog +package vow_flog import ( "fmt" @@ -20,21 +20,21 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" ) -type FlogRepository struct { +type VowFlogRepository struct { db *postgres.DB } -func (repository FlogRepository) Create(headerID int64, models []interface{}) error { +func (repository VowFlogRepository) Create(headerID int64, models []interface{}) error { tx, err := repository.db.Begin() if err != nil { return err } for _, model := range models { - flog, ok := model.(FlogModel) + flog, ok := model.(VowFlogModel) if !ok { tx.Rollback() - return fmt.Errorf("model of type %T, not %T", model, FlogModel{}) + return fmt.Errorf("model of type %T, not %T", model, VowFlogModel{}) } _, err = tx.Exec( @@ -60,7 +60,7 @@ func (repository FlogRepository) Create(headerID int64, models []interface{}) er return tx.Commit() } -func (repository FlogRepository) MarkHeaderChecked(headerID int64) error { +func (repository VowFlogRepository) MarkHeaderChecked(headerID int64) error { _, err := repository.db.Exec(`INSERT INTO public.checked_headers (header_id, vow_flog_checked) VALUES ($1, $2) ON CONFLICT (header_id) DO @@ -68,7 +68,7 @@ func (repository FlogRepository) MarkHeaderChecked(headerID int64) error { return err } -func (repository FlogRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { +func (repository VowFlogRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { var result []core.Header err := repository.db.Select( &result, @@ -85,6 +85,6 @@ func (repository FlogRepository) MissingHeaders(startingBlockNumber, endingBlock return result, err } -func (repository *FlogRepository) SetDB(db *postgres.DB) { +func (repository *VowFlogRepository) SetDB(db *postgres.DB) { repository.db = db } diff --git a/pkg/transformers/flog/repository_test.go b/pkg/transformers/vow_flog/repository_test.go similarity index 92% rename from pkg/transformers/flog/repository_test.go rename to pkg/transformers/vow_flog/repository_test.go index ed44dd86..821388ac 100644 --- a/pkg/transformers/flog/repository_test.go +++ b/pkg/transformers/vow_flog/repository_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package flog_test +package vow_flog_test import ( "database/sql" @@ -26,15 +26,15 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flog" "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" + "github.com/vulcanize/vulcanizedb/pkg/transformers/vow_flog" "github.com/vulcanize/vulcanizedb/test_config" ) -var _ = Describe("Flog repository", func() { +var _ = Describe("Vow flog repository", func() { var ( db *postgres.DB - flogRepository flog.FlogRepository + flogRepository vow_flog.VowFlogRepository err error headerRepository datastore.HeaderRepository ) @@ -43,7 +43,7 @@ var _ = Describe("Flog repository", func() { db = test_config.NewTestDB(core.Node{}) test_config.CleanTestDB(db) headerRepository = repositories.NewHeaderRepository(db) - flogRepository = flog.FlogRepository{} + flogRepository = vow_flog.VowFlogRepository{} flogRepository.SetDB(db) }) @@ -55,11 +55,11 @@ var _ = Describe("Flog repository", func() { Expect(err).NotTo(HaveOccurred()) }) - It("adds a flog event", func() { + It("adds a vow flog event", func() { err = flogRepository.Create(headerID, []interface{}{test_data.FlogModel}) Expect(err).NotTo(HaveOccurred()) - var dbFlog flog.FlogModel + var dbFlog vow_flog.VowFlogModel err = db.Get(&dbFlog, `SELECT era, log_idx, tx_idx, raw_log FROM maker.vow_flog WHERE header_id = $1`, headerID) Expect(err).NotTo(HaveOccurred()) Expect(dbFlog.Era).To(Equal(test_data.FlogModel.Era)) @@ -91,7 +91,7 @@ var _ = Describe("Flog repository", func() { Expect(headerChecked).To(BeTrue()) }) - It("does not duplicate flog events", func() { + It("does not duplicate vow flog events", func() { err = flogRepository.Create(headerID, []interface{}{test_data.FlogModel}) Expect(err).NotTo(HaveOccurred()) @@ -100,11 +100,11 @@ var _ = Describe("Flog repository", func() { Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint")) }) - It("removes flog events if corresponding header is deleted", func() { + It("removes vow flog events if corresponding header is deleted", func() { _, err = db.Exec(`DELETE FROM headers WHERE id = $1`, headerID) Expect(err).NotTo(HaveOccurred()) - var dbFlog flog.FlogModel + var dbFlog vow_flog.VowFlogModel err = db.Get(&dbFlog, `SELECT era, log_idx, tx_idx, raw_log FROM maker.vow_flog WHERE header_id = $1`, headerID) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(sql.ErrNoRows)) @@ -181,7 +181,7 @@ var _ = Describe("Flog repository", func() { Expect(headers[1].BlockNumber).To(Or(Equal(startingBlockNumber), Equal(endingBlockNumber))) }) - It("only treats headers as checked if flog logs have been checked", func() { + It("only treats headers as checked if vow flog logs have been checked", func() { _, err := db.Exec(`INSERT INTO public.checked_headers (header_id) VALUES ($1)`, headerIDs[1]) Expect(err).NotTo(HaveOccurred()) @@ -201,7 +201,7 @@ var _ = Describe("Flog repository", func() { _, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n)) Expect(err).NotTo(HaveOccurred()) } - flogRepositoryTwo := flog.FlogRepository{} + flogRepositoryTwo := vow_flog.VowFlogRepository{} flogRepositoryTwo.SetDB(dbTwo) err := flogRepository.MarkHeaderChecked(headerIDs[0]) Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/transformers/flog/transformer_test.go b/pkg/transformers/vow_flog/transformer_test.go similarity index 87% rename from pkg/transformers/flog/transformer_test.go rename to pkg/transformers/vow_flog/transformer_test.go index 36ef491d..a64ca61c 100644 --- a/pkg/transformers/flog/transformer_test.go +++ b/pkg/transformers/vow_flog/transformer_test.go @@ -12,37 +12,38 @@ // See the License for the specific language governing permissions and // limitations under the License. -package flog_test +package vow_flog_test import ( + "math/rand" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flog" "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks" - flog_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/flog" - "math/rand" + "github.com/vulcanize/vulcanizedb/pkg/transformers/vow_flog" ) -var _ = Describe("Flog transformer", func() { - var config = flog.FlogConfig +var _ = Describe("Vow flog transformer", func() { + var config = vow_flog.VowFlogConfig var fetcher mocks.MockLogFetcher - var converter flog_mocks.MockFlogConverter - var repository flog_mocks.MockFlogRepository + var converter mocks.MockLogNoteConverter + var repository mocks.MockRepository var transformer shared.Transformer var headerOne core.Header var headerTwo core.Header BeforeEach(func() { fetcher = mocks.MockLogFetcher{} - converter = flog_mocks.MockFlogConverter{} - repository = flog_mocks.MockFlogRepository{} + 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.LogNoteTransformer{ @@ -86,7 +87,7 @@ var _ = Describe("Flog transformer", func() { config.ContractAddresses, config.ContractAddresses, })) - Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.FlogSignature)}})) + Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.VowFlogSignature)}})) }) It("returns error if fetcher returns error", func() { @@ -126,13 +127,13 @@ var _ = Describe("Flog transformer", func() { err := transformer.Execute() Expect(err).NotTo(HaveOccurred()) - Expect(repository.CheckedHeaderIDs).To(ContainElement(headerOne.Id)) - Expect(repository.CheckedHeaderIDs).To(ContainElement(headerTwo.Id)) + Expect(repository.MarkHeaderCheckedPassedHeaderIDs).To(ContainElement(headerOne.Id)) + Expect(repository.MarkHeaderCheckedPassedHeaderIDs).To(ContainElement(headerTwo.Id)) }) It("returns error if marking header checked returns err", func() { repository.SetMissingHeaders([]core.Header{headerOne, headerTwo}) - repository.SetCheckedHeaderError(fakes.FakeError) + repository.SetMarkHeaderCheckedError(fakes.FakeError) fetcher.SetFetchedLogs([]types.Log{}) err := transformer.Execute() @@ -141,7 +142,8 @@ var _ = Describe("Flog transformer", func() { Expect(err).To(MatchError(fakes.FakeError)) }) - It("persists flog model", func() { + It("persists vow flog model", func() { + converter.SetReturnModels([]interface{}{test_data.FlogModel}) fetcher.SetFetchedLogs([]types.Log{test_data.EthFlogLog}) repository.SetMissingHeaders([]core.Header{headerOne}) diff --git a/pkg/transformers/flog/flog_suite_test.go b/pkg/transformers/vow_flog/vow_flog_suite_test.go similarity index 90% rename from pkg/transformers/flog/flog_suite_test.go rename to pkg/transformers/vow_flog/vow_flog_suite_test.go index b40bcf56..fa12db35 100644 --- a/pkg/transformers/flog/flog_suite_test.go +++ b/pkg/transformers/vow_flog/vow_flog_suite_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package flog +package vow_flog import ( "testing" @@ -23,9 +23,9 @@ import ( "log" ) -func TestFlog(t *testing.T) { +func TestVowFlog(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "Flog Suite") + RunSpecs(t, "VowFlog Suite") } var _ = BeforeSuite(func() {