Replace magic numbers with variables
This commit is contained in:
parent
eea0b0bdca
commit
c21c069b69
@ -120,7 +120,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.AddCheckColumn(eventIDs[0])
|
err := contractHeaderRepo.AddCheckColumn(eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err := contractHeaderRepo.MissingHeaders(6194632, 6194635, eventIDs[0])
|
missingHeaders, err := contractHeaderRepo.MissingHeaders(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
})
|
})
|
||||||
@ -130,16 +130,16 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.AddCheckColumn(eventIDs[0])
|
err := contractHeaderRepo.AddCheckColumn(eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err := contractHeaderRepo.MissingHeaders(6194632, 6194635, eventIDs[0])
|
missingHeaders, err := contractHeaderRepo.MissingHeaders(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
h1 := missingHeaders[0]
|
h1 := missingHeaders[0]
|
||||||
h2 := missingHeaders[1]
|
h2 := missingHeaders[1]
|
||||||
h3 := missingHeaders[2]
|
h3 := missingHeaders[2]
|
||||||
Expect(h1.BlockNumber).To(Equal(int64(6194632)))
|
Expect(h1.BlockNumber).To(Equal(int64(mocks.MockHeader1.BlockNumber)))
|
||||||
Expect(h2.BlockNumber).To(Equal(int64(6194633)))
|
Expect(h2.BlockNumber).To(Equal(int64(mocks.MockHeader2.BlockNumber)))
|
||||||
Expect(h3.BlockNumber).To(Equal(int64(6194634)))
|
Expect(h3.BlockNumber).To(Equal(int64(mocks.MockHeader3.BlockNumber)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("Returns only contiguous chunks of headers", func() {
|
It("Returns only contiguous chunks of headers", func() {
|
||||||
@ -147,11 +147,11 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.AddCheckColumns(eventIDs)
|
err := contractHeaderRepo.AddCheckColumns(eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err := contractHeaderRepo.MissingHeaders(6194632, 6194635, eventIDs[0])
|
missingHeaders, err := contractHeaderRepo.MissingHeaders(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(2))
|
Expect(len(missingHeaders)).To(Equal(2))
|
||||||
Expect(missingHeaders[0].BlockNumber).To(Equal(int64(6194632)))
|
Expect(missingHeaders[0].BlockNumber).To(Equal(int64(mocks.MockHeader1.BlockNumber)))
|
||||||
Expect(missingHeaders[1].BlockNumber).To(Equal(int64(6194633)))
|
Expect(missingHeaders[1].BlockNumber).To(Equal(int64(mocks.MockHeader2.BlockNumber)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("Fails if eventID does not yet exist in check_headers table", func() {
|
It("Fails if eventID does not yet exist in check_headers table", func() {
|
||||||
@ -159,7 +159,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.AddCheckColumn(eventIDs[0])
|
err := contractHeaderRepo.AddCheckColumn(eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
_, err = contractHeaderRepo.MissingHeaders(6194632, 6194635, "notEventId")
|
_, err = contractHeaderRepo.MissingHeaders(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, "notEventId")
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -170,14 +170,14 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.AddCheckColumns(eventIDs)
|
err := contractHeaderRepo.AddCheckColumns(eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err := contractHeaderRepo.MissingHeadersForAll(6194632, 6194635, eventIDs)
|
missingHeaders, err := contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
err = contractHeaderRepo.MarkHeaderChecked(missingHeaders[0].Id, eventIDs[0])
|
err = contractHeaderRepo.MarkHeaderChecked(missingHeaders[0].Id, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err = contractHeaderRepo.MissingHeadersForAll(6194632, 6194635, eventIDs)
|
missingHeaders, err = contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err = contractHeaderRepo.MarkHeaderChecked(missingHeaders[0].Id, eventIDs[2])
|
err = contractHeaderRepo.MarkHeaderChecked(missingHeaders[0].Id, eventIDs[2])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err = contractHeaderRepo.MissingHeadersForAll(6194633, 6194635, eventIDs)
|
missingHeaders, err = contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader2.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(2))
|
Expect(len(missingHeaders)).To(Equal(2))
|
||||||
})
|
})
|
||||||
@ -196,11 +196,11 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.AddCheckColumns(eventIDs)
|
err := contractHeaderRepo.AddCheckColumns(eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err := contractHeaderRepo.MissingHeadersForAll(6194632, 6194635, eventIDs)
|
missingHeaders, err := contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(2))
|
Expect(len(missingHeaders)).To(Equal(2))
|
||||||
Expect(missingHeaders[0].BlockNumber).To(Equal(int64(6194632)))
|
Expect(missingHeaders[0].BlockNumber).To(Equal(int64(mocks.MockHeader1.BlockNumber)))
|
||||||
Expect(missingHeaders[1].BlockNumber).To(Equal(int64(6194633)))
|
Expect(missingHeaders[1].BlockNumber).To(Equal(int64(mocks.MockHeader2.BlockNumber)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns headers after starting header if starting header not missing", func() {
|
It("returns headers after starting header if starting header not missing", func() {
|
||||||
@ -208,7 +208,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.AddCheckColumns(eventIDs)
|
err := contractHeaderRepo.AddCheckColumns(eventIDs)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err := contractHeaderRepo.MissingHeadersForAll(6194632, -1, eventIDs)
|
missingHeaders, err := contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader1.BlockNumber, -1, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(2))
|
Expect(len(missingHeaders)).To(Equal(2))
|
||||||
Expect(missingHeaders[0].BlockNumber).To(Equal(mocks.MockHeader3.BlockNumber))
|
Expect(missingHeaders[0].BlockNumber).To(Equal(mocks.MockHeader3.BlockNumber))
|
||||||
@ -221,7 +221,7 @@ var _ = Describe("Repository", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
badEventIDs := append(eventIDs, "notEventId")
|
badEventIDs := append(eventIDs, "notEventId")
|
||||||
|
|
||||||
_, err = contractHeaderRepo.MissingHeadersForAll(6194632, 6194635, badEventIDs)
|
_, err = contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, badEventIDs)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -232,7 +232,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.AddCheckColumn(eventIDs[0])
|
err := contractHeaderRepo.AddCheckColumn(eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err := contractHeaderRepo.MissingHeaders(6194632, 6194635, eventIDs[0])
|
missingHeaders, err := contractHeaderRepo.MissingHeaders(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err = contractHeaderRepo.MarkHeaderChecked(headerID, eventIDs[0])
|
err = contractHeaderRepo.MarkHeaderChecked(headerID, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err = contractHeaderRepo.MissingHeaders(6194633, 6194635, eventIDs[0])
|
missingHeaders, err = contractHeaderRepo.MissingHeaders(mocks.MockHeader2.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(2))
|
Expect(len(missingHeaders)).To(Equal(2))
|
||||||
})
|
})
|
||||||
@ -250,7 +250,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.AddCheckColumn(eventIDs[0])
|
err := contractHeaderRepo.AddCheckColumn(eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err := contractHeaderRepo.MissingHeaders(6194632, 6194635, eventIDs[0])
|
missingHeaders, err := contractHeaderRepo.MissingHeaders(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err = contractHeaderRepo.MarkHeaderChecked(headerID, "notEventId")
|
err = contractHeaderRepo.MarkHeaderChecked(headerID, "notEventId")
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err = contractHeaderRepo.MissingHeaders(6194632, 6194635, eventIDs[0])
|
missingHeaders, err = contractHeaderRepo.MissingHeaders(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
})
|
})
|
||||||
@ -270,7 +270,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.AddCheckColumns(eventIDs)
|
err := contractHeaderRepo.AddCheckColumns(eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err := contractHeaderRepo.MissingHeadersForAll(6194632, 6194635, eventIDs)
|
missingHeaders, err := contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err = contractHeaderRepo.MarkHeaderCheckedForAll(headerID, eventIDs)
|
err = contractHeaderRepo.MarkHeaderCheckedForAll(headerID, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err = contractHeaderRepo.MissingHeaders(6194633, 6194635, eventIDs[0])
|
missingHeaders, err = contractHeaderRepo.MissingHeaders(mocks.MockHeader2.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(2))
|
Expect(len(missingHeaders)).To(Equal(2))
|
||||||
})
|
})
|
||||||
@ -297,7 +297,7 @@ var _ = Describe("Repository", func() {
|
|||||||
for _, id := range methodIDs {
|
for _, id := range methodIDs {
|
||||||
err := contractHeaderRepo.AddCheckColumn(id)
|
err := contractHeaderRepo.AddCheckColumn(id)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
missingHeaders, err = contractHeaderRepo.MissingHeaders(6194632, 6194635, id)
|
missingHeaders, err = contractHeaderRepo.MissingHeaders(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, id)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
}
|
}
|
||||||
@ -305,7 +305,7 @@ var _ = Describe("Repository", func() {
|
|||||||
err := contractHeaderRepo.MarkHeadersCheckedForAll(missingHeaders, methodIDs)
|
err := contractHeaderRepo.MarkHeadersCheckedForAll(missingHeaders, methodIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
for _, id := range methodIDs {
|
for _, id := range methodIDs {
|
||||||
missingHeaders, err = contractHeaderRepo.MissingHeaders(6194632, 6194635, id)
|
missingHeaders, err = contractHeaderRepo.MissingHeaders(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, id)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(0))
|
Expect(len(missingHeaders)).To(Equal(0))
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ var _ = Describe("Repository", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
missingHeaders, err := contractHeaderRepo.MissingHeaders(6194632, 6194635, eventIDs[0])
|
missingHeaders, err := contractHeaderRepo.MissingHeaders(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ var _ = Describe("Repository", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
intersectionHeaders, err := contractHeaderRepo.MissingMethodsCheckedEventsIntersection(6194632, 6194635, methodIDs, eventIDs)
|
intersectionHeaders, err := contractHeaderRepo.MissingMethodsCheckedEventsIntersection(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, methodIDs, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(intersectionHeaders)).To(Equal(1))
|
Expect(len(intersectionHeaders)).To(Equal(1))
|
||||||
Expect(intersectionHeaders[0].Id).To(Equal(headerID2))
|
Expect(intersectionHeaders[0].Id).To(Equal(headerID2))
|
||||||
|
Loading…
Reference in New Issue
Block a user