From 3778d7ac06275ea5a2f60f45a346f6f510455754 Mon Sep 17 00:00:00 2001 From: David Terry Date: Wed, 10 Oct 2018 13:40:25 +0300 Subject: [PATCH] vat.fold: add transformer tests for MarkHeaderChecked --- pkg/transformers/vat_fold/transformer_test.go | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/pkg/transformers/vat_fold/transformer_test.go b/pkg/transformers/vat_fold/transformer_test.go index f263bc90..8d5c74a1 100644 --- a/pkg/transformers/vat_fold/transformer_test.go +++ b/pkg/transformers/vat_fold/transformer_test.go @@ -176,4 +176,40 @@ var _ = Describe("Vat fold transformer", func() { Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(fakes.FakeError)) }) + + It("marks the header as checked when there are no logs", func() { + header := core.Header{Id: GinkgoRandomSeed()} + transformer, _, _, repository := setup(setupOptions{ + missingHeaders: []core.Header{header}, + }) + + err := transformer.Execute() + + Expect(err).NotTo(HaveOccurred()) + Expect(repository.MarkHeaderCheckedPassedHeaderID).To(Equal(header.Id)) + }) + + It("doesn't call MarkHeaderChecked when there are logs", func() { + transformer, _, _, repository := setup(setupOptions{ + missingHeaders: []core.Header{{Id: GinkgoRandomSeed()}}, + fetchedLogs: []types.Log{test_data.EthVatFoldLog}, + }) + + err := transformer.Execute() + + Expect(err).NotTo(HaveOccurred()) + Expect(repository.MarkHeaderCheckedPassedHeaderID).To(Equal(int64(0))) + }) + + It("returns an error if MarkHeaderChecked fails", func() { + transformer, _, _, _ := setup(setupOptions{ + missingHeaders: []core.Header{{Id: GinkgoRandomSeed()}}, + setMissingHeadersError: true, + }) + + err := transformer.Execute() + + Expect(err).To(HaveOccurred()) + Expect(err).To(MatchError(fakes.FakeError)) + }) })