Rename Flog pack to Vow flog
- enables differentiation if another contract implements flog - also deletes flog-specific mocks
This commit is contained in:
parent
1b680d2a4b
commit
ed624330f6
@ -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
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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,
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
}
|
@ -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,
|
@ -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))
|
||||
})
|
||||
})
|
@ -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"`
|
@ -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
|
||||
}
|
@ -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())
|
@ -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})
|
||||
|
@ -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() {
|
Loading…
Reference in New Issue
Block a user