Fixes after rebase
This commit is contained in:
parent
70722fc9e3
commit
7d3bf1f0f6
@ -2,8 +2,8 @@
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.3
|
||||
-- Dumped by pg_dump version 10.3
|
||||
-- Dumped from database version 10.5
|
||||
-- Dumped by pg_dump version 10.5
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
|
@ -46,12 +46,7 @@ var _ = Describe("Pit file ilk repository", func() {
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
pitFileIlkRepository ilk.PitFileIlkRepository
|
||||
err error
|
||||
headerID int64
|
||||
)
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
@ -59,7 +54,6 @@ var _ = Describe("Pit file ilk repository", func() {
|
||||
|
||||
err = pitFileRepository.Create(headerID, []interface{}{test_data.PitFileIlkModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
pitFileIlkRepository = ilk.PitFileIlkRepository{DB: db}
|
||||
})
|
||||
|
||||
It("adds a pit file ilk event", func() {
|
||||
|
@ -46,11 +46,7 @@ var _ = Describe("Pit file stability fee repository", func() {
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
err error
|
||||
headerID int64
|
||||
)
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
|
@ -41,15 +41,15 @@ var _ = Describe("TendRepository", func() {
|
||||
db = test_config.NewTestDB(node)
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
tendRepository = tend.TendRepository{DB: db}
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
It("persists a tend record", func() {
|
||||
err := tendRepository.Create(headerId, []interface{}{test_data.TendModel})
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = tendRepository.Create(headerId, []interface{}{test_data.TendModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -80,18 +80,12 @@ var _ = Describe("TendRepository", func() {
|
||||
})
|
||||
|
||||
It("returns an error if inserting a tend record fails", func() {
|
||||
err := tendRepository.Create(headerId, []interface{}{test_data.TendModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = tendRepository.Create(headerId, []interface{}{test_data.TendModel})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint"))
|
||||
})
|
||||
|
||||
It("deletes the tend record if its corresponding header record is deleted", func() {
|
||||
err := tendRepository.Create(headerId, []interface{}{test_data.TendModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
var count int
|
||||
err = db.QueryRow(`SELECT count(*) from maker.tend`).Scan(&count)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -107,11 +101,12 @@ var _ = Describe("TendRepository", func() {
|
||||
})
|
||||
|
||||
Describe("MarkHeaderChecked", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = tendRepository.Create(headerId, []interface{}{test_data.TendModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
It("creates a row for a new headerID", func() {
|
||||
|
@ -124,10 +124,10 @@ var (
|
||||
Repository: &vat_move.VatMoveRepository{},
|
||||
Fetcher: &shared.Fetcher{},
|
||||
}.NewTransformer
|
||||
VatSlipTransformerInitializer = vat_slip.VatSlipTransformerInitializer{Config: vat_slip.VatSlipConfig}.NewVatSlipTransformer
|
||||
VatTollTransformerInitializer = vat_toll.VatTollTransformerInitializer{Config: vat_toll.VatTollConfig}.NewVatTollTransformer
|
||||
VatTuneTransformerInitializer = vat_tune.VatTuneTransformerInitializer{Config: vat_tune.VatTuneConfig}.NewVatTuneTransformer
|
||||
VatFluxTransformerInitializer = vat_flux.VatFluxTransformerInitializer{Config: vat_flux.VatFluxConfig}.NewVatFluxTransformer
|
||||
VatSlipTransformerInitializer = vat_slip.VatSlipTransformerInitializer{Config: vat_slip.VatSlipConfig}.NewVatSlipTransformer
|
||||
VatTollTransformerInitializer = vat_toll.VatTollTransformerInitializer{Config: vat_toll.VatTollConfig}.NewVatTollTransformer
|
||||
VatTuneTransformerInitializer = vat_tune.VatTuneTransformerInitializer{Config: vat_tune.VatTuneConfig}.NewVatTuneTransformer
|
||||
VatFluxTransformerInitializer = vat_flux.VatFluxTransformerInitializer{Config: vat_flux.VatFluxConfig}.NewVatFluxTransformer
|
||||
)
|
||||
|
||||
func TransformerInitializers() []shared.TransformerInitializer {
|
||||
|
@ -65,9 +65,6 @@ var _ = Describe("Vat init repository", func() {
|
||||
})
|
||||
|
||||
It("does not duplicate vat events", func() {
|
||||
err = vatInitRepository.Create(headerID, []interface{}{test_data.VatInitModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = vatInitRepository.Create(headerID, []interface{}{test_data.VatInitModel})
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
@ -93,20 +90,11 @@ var _ = Describe("Vat init repository", func() {
|
||||
})
|
||||
|
||||
Describe("MarkHeaderChecked", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
vatInitRepository vat_init.VatInitRepository
|
||||
err error
|
||||
headerID int64
|
||||
)
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
db = test_config.NewTestDB(core.Node{})
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
vatInitRepository = vat_init.VatInitRepository{DB: db}
|
||||
})
|
||||
|
||||
It("creates a row for a new headerID", func() {
|
||||
@ -166,16 +154,6 @@ var _ = Describe("Vat init repository", func() {
|
||||
})
|
||||
|
||||
It("only treats headers as checked if drip drip logs have been checked", func() {
|
||||
startingBlockNumber := int64(1)
|
||||
vatInitBlockNumber := int64(2)
|
||||
endingBlockNumber := int64(3)
|
||||
blockNumbers = []int64{startingBlockNumber, vatInitBlockNumber, endingBlockNumber, endingBlockNumber + 1}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n})
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
_, err := db.Exec(`INSERT INTO public.checked_headers (header_id) VALUES ($1)`, headerIDs[1])
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
@ -196,9 +174,8 @@ var _ = Describe("Vat init repository", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
vatInitRepository := vat_init.VatInitRepository{DB: db}
|
||||
vatInitRepositoryTwo := vat_init.VatInitRepository{DB: dbTwo}
|
||||
err := vatInitRepository.MarkHeaderChecked(headerIDs[0])
|
||||
err = vatInitRepository.MarkHeaderChecked(headerIDs[0])
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
nodeOneMissingHeaders, err := vatInitRepository.MissingHeaders(blockNumbers[0], blockNumbers[len(blockNumbers)-1])
|
||||
@ -213,8 +190,7 @@ var _ = Describe("Vat init repository", func() {
|
||||
|
||||
Describe("SetDB", func() {
|
||||
It("sets the repository db", func() {
|
||||
db := test_config.NewTestDB(core.Node{})
|
||||
vatInitRepository := vat_init.VatInitRepository{DB: nil}
|
||||
vatInitRepository.SetDB(nil)
|
||||
Expect(vatInitRepository.DB).To(BeNil())
|
||||
vatInitRepository.SetDB(db)
|
||||
Expect(vatInitRepository.DB).To(Equal(db))
|
||||
|
@ -21,18 +21,14 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
)
|
||||
|
||||
type Converter interface {
|
||||
ToModels(ethLog []types.Log) ([]VatMoveModel, error)
|
||||
}
|
||||
|
||||
type VatMoveConverter struct{}
|
||||
|
||||
func (VatMoveConverter) ToModels(ethLogs []types.Log) ([]VatMoveModel, error) {
|
||||
var models []VatMoveModel
|
||||
func (VatMoveConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
var models []interface{}
|
||||
for _, ethLog := range ethLogs {
|
||||
err := verifyLog(ethLog)
|
||||
if err != nil {
|
||||
return []VatMoveModel{}, err
|
||||
return []interface{}{}, err
|
||||
}
|
||||
|
||||
src := common.BytesToAddress(ethLog.Topics[1].Bytes())
|
||||
@ -40,7 +36,7 @@ func (VatMoveConverter) ToModels(ethLogs []types.Log) ([]VatMoveModel, error) {
|
||||
rad := ethLog.Topics[3].Big()
|
||||
raw, err := json.Marshal(ethLog)
|
||||
if err != nil {
|
||||
return []VatMoveModel{}, err
|
||||
return []interface{}{}, err
|
||||
}
|
||||
|
||||
models = append(models, VatMoveModel{
|
||||
|
Loading…
Reference in New Issue
Block a user