forked from cerc-io/ipld-eth-server
Update tests for stability_fee
This commit is contained in:
parent
2cc303a2f5
commit
3412866182
@ -33,7 +33,7 @@ import (
|
|||||||
var _ = Describe("Pit file stability fee repository", func() {
|
var _ = Describe("Pit file stability fee repository", func() {
|
||||||
var (
|
var (
|
||||||
db *postgres.DB
|
db *postgres.DB
|
||||||
pitFileRepository stability_fee.Repository
|
pitFileStabilityFeeRepository stability_fee.PitFileStabilityFeeRepository
|
||||||
err error
|
err error
|
||||||
headerRepository datastore.HeaderRepository
|
headerRepository datastore.HeaderRepository
|
||||||
)
|
)
|
||||||
@ -42,17 +42,21 @@ var _ = Describe("Pit file stability fee repository", func() {
|
|||||||
db = test_config.NewTestDB(core.Node{})
|
db = test_config.NewTestDB(core.Node{})
|
||||||
test_config.CleanTestDB(db)
|
test_config.CleanTestDB(db)
|
||||||
headerRepository = repositories.NewHeaderRepository(db)
|
headerRepository = repositories.NewHeaderRepository(db)
|
||||||
pitFileRepository = stability_fee.NewPitFileStabilityFeeRepository(db)
|
pitFileStabilityFeeRepository = stability_fee.PitFileStabilityFeeRepository{DB: db}
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("Create", func() {
|
Describe("Create", func() {
|
||||||
var headerID int64
|
var (
|
||||||
|
db *postgres.DB
|
||||||
|
err error
|
||||||
|
headerID int64
|
||||||
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
err = pitFileRepository.Create(headerID, []stability_fee.PitFileStabilityFeeModel{test_data.PitFileStabilityFeeModel})
|
err = pitFileStabilityFeeRepository.Create(headerID, []interface{}{test_data.PitFileStabilityFeeModel})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -74,7 +78,7 @@ var _ = Describe("Pit file stability fee repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("does not duplicate pit file events", func() {
|
It("does not duplicate pit file events", func() {
|
||||||
err = pitFileRepository.Create(headerID, []stability_fee.PitFileStabilityFeeModel{test_data.PitFileStabilityFeeModel})
|
err = pitFileStabilityFeeRepository.Create(headerID, []interface{}{test_data.PitFileStabilityFeeModel})
|
||||||
|
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint"))
|
Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint"))
|
||||||
@ -100,7 +104,7 @@ var _ = Describe("Pit file stability fee repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("creates a row for a new headerID", func() {
|
It("creates a row for a new headerID", func() {
|
||||||
err = pitFileRepository.MarkHeaderChecked(headerID)
|
err = pitFileStabilityFeeRepository.MarkHeaderChecked(headerID)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
var headerChecked bool
|
var headerChecked bool
|
||||||
@ -112,7 +116,7 @@ var _ = Describe("Pit file stability fee repository", func() {
|
|||||||
It("updates row when headerID already exists", func() {
|
It("updates row when headerID already exists", func() {
|
||||||
_, err = db.Exec(`INSERT INTO public.checked_headers (header_id) VALUES ($1)`, headerID)
|
_, err = db.Exec(`INSERT INTO public.checked_headers (header_id) VALUES ($1)`, headerID)
|
||||||
|
|
||||||
err = pitFileRepository.MarkHeaderChecked(headerID)
|
err = pitFileStabilityFeeRepository.MarkHeaderChecked(headerID)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
var headerChecked bool
|
var headerChecked bool
|
||||||
@ -144,10 +148,10 @@ var _ = Describe("Pit file stability fee repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns headers that haven't been checked", func() {
|
It("returns headers that haven't been checked", func() {
|
||||||
err := pitFileRepository.MarkHeaderChecked(headerIDs[1])
|
err = pitFileStabilityFeeRepository.MarkHeaderChecked(headerIDs[1])
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
headers, err := pitFileRepository.MissingHeaders(startingBlock, endingBlock)
|
headers, err := pitFileStabilityFeeRepository.MissingHeaders(startingBlock, endingBlock)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(headers)).To(Equal(2))
|
Expect(len(headers)).To(Equal(2))
|
||||||
@ -156,10 +160,10 @@ var _ = Describe("Pit file stability fee repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("only treats headers as checked if pit file stability fee logs have been checked", func() {
|
It("only treats headers as checked if pit file stability fee logs have been checked", func() {
|
||||||
_, err := db.Exec(`INSERT INTO public.checked_headers (header_id) VALUES ($1)`, headerIDs[1])
|
_, err = db.Exec(`INSERT INTO public.checked_headers (header_id) VALUES ($1)`, headerIDs[1])
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
headers, err := pitFileRepository.MissingHeaders(startingBlock, endingBlock)
|
headers, err := pitFileStabilityFeeRepository.MissingHeaders(startingBlock, endingBlock)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(headers)).To(Equal(3))
|
Expect(len(headers)).To(Equal(3))
|
||||||
@ -175,11 +179,12 @@ var _ = Describe("Pit file stability fee repository", func() {
|
|||||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
}
|
}
|
||||||
pitFileRepositoryTwo := stability_fee.NewPitFileStabilityFeeRepository(dbTwo)
|
|
||||||
err := pitFileRepository.MarkHeaderChecked(headerIDs[0])
|
pitFileRepositoryTwo := stability_fee.PitFileStabilityFeeRepository{DB: dbTwo}
|
||||||
|
err = pitFileStabilityFeeRepository.MarkHeaderChecked(headerIDs[0])
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
nodeOneMissingHeaders, err := pitFileRepository.MissingHeaders(blockNumbers[0], blockNumbers[len(blockNumbers)-1])
|
nodeOneMissingHeaders, err := pitFileStabilityFeeRepository.MissingHeaders(blockNumbers[0], blockNumbers[len(blockNumbers)-1])
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(nodeOneMissingHeaders)).To(Equal(len(blockNumbers) - 1))
|
Expect(len(nodeOneMissingHeaders)).To(Equal(len(blockNumbers) - 1))
|
||||||
|
|
||||||
|
@ -19,11 +19,12 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
|
||||||
@ -31,15 +32,31 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Pit file stability fee transformer", func() {
|
var _ = Describe("Pit file stability fee transformer", func() {
|
||||||
It("gets missing headers for block numbers specified in config", func() {
|
var (
|
||||||
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
config = stability_fee.StabilityFeeFileConfig
|
||||||
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
fetcher mocks.MockLogFetcher
|
||||||
Config: pit_file.PitFileConfig,
|
converter stability_fee_mocks.MockPitFileStabilityFeeConverter
|
||||||
Fetcher: &mocks.MockLogFetcher{},
|
repository stability_fee_mocks.MockPitFileStabilityFeeRepository
|
||||||
Converter: &stability_fee_mocks.MockPitFileStabilityFeeConverter{},
|
transformer shared.Transformer
|
||||||
Repository: repository,
|
headerOne core.Header
|
||||||
}
|
headerTwo core.Header
|
||||||
|
)
|
||||||
|
|
||||||
|
BeforeEach(func() {
|
||||||
|
fetcher = mocks.MockLogFetcher{}
|
||||||
|
converter = stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
||||||
|
repository = stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
||||||
|
transformer = factories.Transformer{
|
||||||
|
Config: config,
|
||||||
|
Fetcher: &fetcher,
|
||||||
|
Converter: &converter,
|
||||||
|
Repository: &repository,
|
||||||
|
}.NewTransformer(nil, nil)
|
||||||
|
headerOne = core.Header{Id: GinkgoRandomSeed(), BlockNumber: GinkgoRandomSeed()}
|
||||||
|
headerTwo = core.Header{Id: GinkgoRandomSeed(), BlockNumber: GinkgoRandomSeed()}
|
||||||
|
})
|
||||||
|
|
||||||
|
It("gets missing headers for block numbers specified in config", func() {
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
@ -48,14 +65,7 @@ var _ = Describe("Pit file stability fee transformer", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if repository returns error for missing headers", func() {
|
It("returns error if repository returns error for missing headers", func() {
|
||||||
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
|
||||||
repository.SetMissingHeadersErr(fakes.FakeError)
|
repository.SetMissingHeadersErr(fakes.FakeError)
|
||||||
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
|
||||||
Fetcher: &mocks.MockLogFetcher{},
|
|
||||||
Converter: &stability_fee_mocks.MockPitFileStabilityFeeConverter{},
|
|
||||||
Repository: repository,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
@ -63,33 +73,19 @@ var _ = Describe("Pit file stability fee transformer", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("fetches logs for missing headers", func() {
|
It("fetches logs for missing headers", func() {
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
repository.SetMissingHeaders([]core.Header{headerOne, headerTwo})
|
||||||
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
|
||||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}, {BlockNumber: 2}})
|
|
||||||
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
|
||||||
Fetcher: fetcher,
|
|
||||||
Converter: &stability_fee_mocks.MockPitFileStabilityFeeConverter{},
|
|
||||||
Repository: repository,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{headerOne.BlockNumber, headerTwo.BlockNumber}))
|
||||||
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{pit_file.PitFileConfig.ContractAddresses, pit_file.PitFileConfig.ContractAddresses}))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{
|
||||||
|
pit_file.PitFileConfig.ContractAddresses, pit_file.PitFileConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileStabilityFeeSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileStabilityFeeSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if fetcher returns error", func() {
|
It("returns error if fetcher returns error", func() {
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
|
||||||
fetcher.SetFetcherError(fakes.FakeError)
|
fetcher.SetFetcherError(fakes.FakeError)
|
||||||
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
repository.SetMissingHeaders([]core.Header{headerOne})
|
||||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
|
||||||
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
|
||||||
Fetcher: fetcher,
|
|
||||||
Converter: &stability_fee_mocks.MockPitFileStabilityFeeConverter{},
|
|
||||||
Repository: repository,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
@ -98,34 +94,17 @@ var _ = Describe("Pit file stability fee transformer", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("marks header checked if no logs returned", func() {
|
It("marks header checked if no logs returned", func() {
|
||||||
mockConverter := &stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
repository.SetMissingHeaders([]core.Header{headerOne})
|
||||||
mockRepository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
|
||||||
headerID := int64(123)
|
|
||||||
mockRepository.SetMissingHeaders([]core.Header{{Id: headerID}})
|
|
||||||
mockFetcher := &mocks.MockLogFetcher{}
|
|
||||||
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
|
||||||
Converter: mockConverter,
|
|
||||||
Fetcher: mockFetcher,
|
|
||||||
Repository: mockRepository,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
mockRepository.AssertMarkHeaderCheckedCalledWith(headerID)
|
repository.AssertMarkHeaderCheckedCalledWith(headerOne.Id)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if marking header checked returns err", func() {
|
It("returns error if marking header checked returns err", func() {
|
||||||
mockConverter := &stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
repository.SetMissingHeaders([]core.Header{headerOne})
|
||||||
mockRepository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
repository.SetMarkHeaderCheckedErr(fakes.FakeError)
|
||||||
mockRepository.SetMissingHeaders([]core.Header{{Id: int64(123)}})
|
|
||||||
mockRepository.SetMarkHeaderCheckedErr(fakes.FakeError)
|
|
||||||
mockFetcher := &mocks.MockLogFetcher{}
|
|
||||||
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
|
||||||
Converter: mockConverter,
|
|
||||||
Fetcher: mockFetcher,
|
|
||||||
Repository: mockRepository,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
@ -134,16 +113,8 @@ var _ = Describe("Pit file stability fee transformer", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("converts matching logs", func() {
|
It("converts matching logs", func() {
|
||||||
converter := &stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
|
||||||
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
||||||
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
repository.SetMissingHeaders([]core.Header{headerOne})
|
||||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
|
||||||
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
|
||||||
Fetcher: fetcher,
|
|
||||||
Converter: converter,
|
|
||||||
Repository: repository,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
@ -152,17 +123,9 @@ var _ = Describe("Pit file stability fee transformer", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if converter returns error", func() {
|
It("returns error if converter returns error", func() {
|
||||||
converter := &stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
|
||||||
converter.SetConverterError(fakes.FakeError)
|
converter.SetConverterError(fakes.FakeError)
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
|
||||||
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
||||||
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
repository.SetMissingHeaders([]core.Header{headerOne})
|
||||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
|
||||||
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
|
||||||
Fetcher: fetcher,
|
|
||||||
Converter: converter,
|
|
||||||
Repository: repository,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
@ -171,37 +134,20 @@ var _ = Describe("Pit file stability fee transformer", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("persists pit file model", func() {
|
It("persists pit file model", func() {
|
||||||
converter := &stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
|
||||||
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
||||||
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
repository.SetMissingHeaders([]core.Header{headerOne})
|
||||||
fakeHeader := core.Header{BlockNumber: 1, Id: 2}
|
|
||||||
repository.SetMissingHeaders([]core.Header{fakeHeader})
|
|
||||||
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
|
||||||
Fetcher: fetcher,
|
|
||||||
Converter: converter,
|
|
||||||
Repository: repository,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(repository.PassedHeaderID).To(Equal(fakeHeader.Id))
|
Expect(repository.PassedHeaderID).To(Equal(headerOne.Id))
|
||||||
Expect(repository.PassedModels).To(Equal([]stability_fee.PitFileStabilityFeeModel{test_data.PitFileStabilityFeeModel}))
|
Expect(repository.PassedModels).To(Equal([]interface{}{test_data.PitFileStabilityFeeModel}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if repository returns error for create", func() {
|
It("returns error if repository returns error for create", func() {
|
||||||
converter := &stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
|
||||||
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
||||||
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
repository.SetMissingHeaders([]core.Header{headerOne})
|
||||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1, Id: 2}})
|
|
||||||
repository.SetCreateError(fakes.FakeError)
|
repository.SetCreateError(fakes.FakeError)
|
||||||
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
|
||||||
Fetcher: fetcher,
|
|
||||||
Converter: converter,
|
|
||||||
Repository: repository,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
|
@ -17,20 +17,19 @@ package stability_fee
|
|||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MockPitFileStabilityFeeConverter struct {
|
type MockPitFileStabilityFeeConverter struct {
|
||||||
converterErr error
|
converterError error
|
||||||
PassedLogs []types.Log
|
PassedLogs []types.Log
|
||||||
}
|
}
|
||||||
|
|
||||||
func (converter *MockPitFileStabilityFeeConverter) ToModels(ethLogs []types.Log) ([]stability_fee.PitFileStabilityFeeModel, error) {
|
func (converter *MockPitFileStabilityFeeConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||||
converter.PassedLogs = ethLogs
|
converter.PassedLogs = ethLogs
|
||||||
return []stability_fee.PitFileStabilityFeeModel{test_data.PitFileStabilityFeeModel}, converter.converterErr
|
return []interface{}{test_data.PitFileStabilityFeeModel}, converter.converterError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (converter *MockPitFileStabilityFeeConverter) SetConverterError(e error) {
|
func (converter *MockPitFileStabilityFeeConverter) SetConverterError(e error) {
|
||||||
converter.converterErr = e
|
converter.converterError = e
|
||||||
}
|
}
|
||||||
|
@ -16,46 +16,46 @@ package stability_fee
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MockPitFileStabilityFeeRepository struct {
|
type MockPitFileStabilityFeeRepository struct {
|
||||||
createErr error
|
createError error
|
||||||
markHeaderCheckedErr error
|
markHeaderCheckedError error
|
||||||
markHeaderCheckedPassedHeaderID int64
|
markHeaderCheckedPassedHeaderID int64
|
||||||
missingHeaders []core.Header
|
missingHeaders []core.Header
|
||||||
missingHeadersErr error
|
missingHeadersError error
|
||||||
PassedStartingBlockNumber int64
|
PassedStartingBlockNumber int64
|
||||||
PassedEndingBlockNumber int64
|
PassedEndingBlockNumber int64
|
||||||
PassedHeaderID int64
|
PassedHeaderID int64
|
||||||
PassedModels []stability_fee.PitFileStabilityFeeModel
|
PassedModels []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockPitFileStabilityFeeRepository) Create(headerID int64, models []stability_fee.PitFileStabilityFeeModel) error {
|
func (repository *MockPitFileStabilityFeeRepository) Create(headerID int64, models []interface{}) error {
|
||||||
repository.PassedModels = models
|
repository.PassedModels = models
|
||||||
repository.PassedHeaderID = headerID
|
repository.PassedHeaderID = headerID
|
||||||
return repository.createErr
|
return repository.createError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockPitFileStabilityFeeRepository) MarkHeaderChecked(headerID int64) error {
|
func (repository *MockPitFileStabilityFeeRepository) MarkHeaderChecked(headerID int64) error {
|
||||||
repository.markHeaderCheckedPassedHeaderID = headerID
|
repository.markHeaderCheckedPassedHeaderID = headerID
|
||||||
return repository.markHeaderCheckedErr
|
return repository.markHeaderCheckedError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockPitFileStabilityFeeRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
func (repository *MockPitFileStabilityFeeRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||||
repository.PassedStartingBlockNumber = startingBlockNumber
|
repository.PassedStartingBlockNumber = startingBlockNumber
|
||||||
repository.PassedEndingBlockNumber = endingBlockNumber
|
repository.PassedEndingBlockNumber = endingBlockNumber
|
||||||
return repository.missingHeaders, repository.missingHeadersErr
|
return repository.missingHeaders, repository.missingHeadersError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockPitFileStabilityFeeRepository) SetMarkHeaderCheckedErr(e error) {
|
func (repository *MockPitFileStabilityFeeRepository) SetMarkHeaderCheckedErr(e error) {
|
||||||
repository.markHeaderCheckedErr = e
|
repository.markHeaderCheckedError = e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockPitFileStabilityFeeRepository) SetMissingHeadersErr(e error) {
|
func (repository *MockPitFileStabilityFeeRepository) SetMissingHeadersErr(e error) {
|
||||||
repository.missingHeadersErr = e
|
repository.missingHeadersError = e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockPitFileStabilityFeeRepository) SetMissingHeaders(headers []core.Header) {
|
func (repository *MockPitFileStabilityFeeRepository) SetMissingHeaders(headers []core.Header) {
|
||||||
@ -63,9 +63,11 @@ func (repository *MockPitFileStabilityFeeRepository) SetMissingHeaders(headers [
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockPitFileStabilityFeeRepository) SetCreateError(e error) {
|
func (repository *MockPitFileStabilityFeeRepository) SetCreateError(e error) {
|
||||||
repository.createErr = e
|
repository.createError = e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockPitFileStabilityFeeRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
|
func (repository *MockPitFileStabilityFeeRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
|
||||||
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
|
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repository *MockPitFileStabilityFeeRepository) SetDB(db *postgres.DB) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user