forked from cerc-io/ipld-eth-server
Add test for can't create Vat tune of wrong type
This commit is contained in:
parent
a0cae99437
commit
6d662a6ce7
@ -33,7 +33,7 @@ var _ = Describe("Vat tune converter", func() {
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
|
||||
It("converts a log to an model", func() {
|
||||
It("converts a log to a model", func() {
|
||||
converter := vat_tune.VatTuneConverter{}
|
||||
|
||||
models, err := converter.ToModels([]types.Log{test_data.EthVatTuneLog})
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_tune"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
var _ = Describe("Vat tune repository", func() {
|
||||
@ -80,7 +81,7 @@ var _ = Describe("Vat tune repository", func() {
|
||||
Expect(headerChecked).To(BeTrue())
|
||||
})
|
||||
|
||||
It("does not duplicate pit file vat_tune events", func() {
|
||||
It("does not duplicate vat tune events", func() {
|
||||
err = vatTuneRepository.Create(headerID, []interface{}{test_data.VatTuneModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
@ -90,7 +91,7 @@ var _ = Describe("Vat tune repository", func() {
|
||||
Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint"))
|
||||
})
|
||||
|
||||
It("allows for multiple flop kick events in one transaction if they have different log indexes", func() {
|
||||
It("allows for multiple vat tune events in one transaction if they have different log indexes", func() {
|
||||
err = vatTuneRepository.Create(headerID, []interface{}{test_data.VatTuneModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
@ -101,7 +102,7 @@ var _ = Describe("Vat tune repository", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
It("removes pit file vat_tune if corresponding header is deleted", func() {
|
||||
It("removes vat tune if corresponding header is deleted", func() {
|
||||
err = vatTuneRepository.Create(headerID, []interface{}{test_data.VatTuneModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
@ -113,6 +114,12 @@ var _ = Describe("Vat tune repository", func() {
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(sql.ErrNoRows))
|
||||
})
|
||||
|
||||
It("returns an error if model is of wrong type", func() {
|
||||
err = vatTuneRepository.Create(headerID, []interface{}{test_data.WrongModel{}})
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("model of type"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("MarkHeaderChecked", func() {
|
||||
@ -153,7 +160,7 @@ var _ = Describe("Vat tune repository", func() {
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
startingBlockNumber = GinkgoRandomSeed()
|
||||
startingBlockNumber = rand.Int63()
|
||||
vatTuneBlockNumber = startingBlockNumber + 1
|
||||
endingBlockNumber = startingBlockNumber + 2
|
||||
|
||||
|
@ -18,13 +18,15 @@ import (
|
||||
)
|
||||
|
||||
var _ = Describe("Vat tune transformer", func() {
|
||||
var config = vat_tune.VatTuneConfig
|
||||
var fetcher mocks.MockLogFetcher
|
||||
var converter vat_tune_mocks.MockVatTuneConverter
|
||||
var repository vat_tune_mocks.MockVatTuneRepository
|
||||
var transformer shared.Transformer
|
||||
var headerOne core.Header
|
||||
var headerTwo core.Header
|
||||
var (
|
||||
config = vat_tune.VatTuneConfig
|
||||
fetcher mocks.MockLogFetcher
|
||||
converter vat_tune_mocks.MockVatTuneConverter
|
||||
repository vat_tune_mocks.MockVatTuneRepository
|
||||
transformer shared.Transformer
|
||||
headerOne core.Header
|
||||
headerTwo core.Header
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
fetcher = mocks.MockLogFetcher{}
|
||||
|
Loading…
Reference in New Issue
Block a user