Extract shared mock converter and repository

This commit is contained in:
Rob Mulholand 2018-10-24 20:37:12 -05:00
parent f5b9a21a8c
commit 8831586fba
42 changed files with 202 additions and 1518 deletions

View File

@ -15,28 +15,28 @@
package ilk_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"math/rand"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/ilk"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
ilk_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/drip_file/ilk"
)
var _ = Describe("Drip file ilk transformer", func() {
var (
config = ilk.DripFileIlkConfig
fetcher mocks.MockLogFetcher
converter ilk_mocks.MockDripFileIlkConverter
repository ilk_mocks.MockDripFileIlkRepository
converter mocks.MockConverter
repository mocks.MockRepository
transformer shared.Transformer
headerOne core.Header
headerTwo core.Header
@ -44,8 +44,8 @@ var _ = Describe("Drip file ilk transformer", func() {
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = ilk_mocks.MockDripFileIlkConverter{}
repository = ilk_mocks.MockDripFileIlkRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
transformer = factories.Transformer{
Config: config,
Fetcher: &fetcher,
@ -137,6 +137,7 @@ var _ = Describe("Drip file ilk transformer", func() {
})
It("persists drip file model", func() {
converter.SetReturnModels([]interface{}{test_data.DripFileIlkModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthDripFileIlkLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -15,28 +15,28 @@
package repo_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"math/rand"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/repo"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
repo_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/drip_file/repo"
)
var _ = Describe("Drip file repo transformer", func() {
var (
config = repo.DripFileRepoConfig
fetcher mocks.MockLogFetcher
converter repo_mocks.MockDripFileRepoConverter
repository repo_mocks.MockDripFileRepoRepository
converter mocks.MockConverter
repository mocks.MockRepository
transformer shared.Transformer
headerOne core.Header
headerTwo core.Header
@ -44,8 +44,8 @@ var _ = Describe("Drip file repo transformer", func() {
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = repo_mocks.MockDripFileRepoConverter{}
repository = repo_mocks.MockDripFileRepoRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
transformer = factories.Transformer{
Config: config,
Fetcher: &fetcher,
@ -137,6 +137,7 @@ var _ = Describe("Drip file repo transformer", func() {
})
It("persists drip file model", func() {
converter.SetReturnModels([]interface{}{test_data.DripFileRepoModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthDripFileRepoLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -15,28 +15,28 @@
package vow_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"math/rand"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/vow"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
vow_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/drip_file/vow"
)
var _ = Describe("Drip file vow transformer", func() {
var (
config = vow.DripFileVowConfig
fetcher mocks.MockLogFetcher
converter vow_mocks.MockDripFileVowConverter
repository vow_mocks.MockDripFileVowRepository
converter mocks.MockConverter
repository mocks.MockRepository
transformer shared.Transformer
headerOne core.Header
headerTwo core.Header
@ -44,8 +44,8 @@ var _ = Describe("Drip file vow transformer", func() {
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = vow_mocks.MockDripFileVowConverter{}
repository = vow_mocks.MockDripFileVowRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
transformer = factories.Transformer{
Config: config,
Fetcher: &fetcher,
@ -137,6 +137,7 @@ var _ = Describe("Drip file vow transformer", func() {
})
It("persists drip file model", func() {
converter.SetReturnModels([]interface{}{test_data.DripFileVowModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthDripFileVowLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -15,28 +15,28 @@
package debt_ceiling_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"math/rand"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/debt_ceiling"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
debt_ceiling_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/pit_file/debt_ceiling"
)
var _ = Describe("Pit file debt ceiling transformer", func() {
var (
config = debt_ceiling.DebtCeilingFileConfig
fetcher mocks.MockLogFetcher
converter debt_ceiling_mocks.MockPitFileDebtCeilingConverter
repository debt_ceiling_mocks.MockPitFileDebtCeilingRepository
converter mocks.MockConverter
repository mocks.MockRepository
transformer shared.Transformer
headerOne core.Header
headerTwo core.Header
@ -44,8 +44,8 @@ var _ = Describe("Pit file debt ceiling transformer", func() {
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = debt_ceiling_mocks.MockPitFileDebtCeilingConverter{}
repository = debt_ceiling_mocks.MockPitFileDebtCeilingRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
transformer = factories.Transformer{
@ -137,6 +137,7 @@ var _ = Describe("Pit file debt ceiling transformer", func() {
})
It("persists pit file model", func() {
converter.SetReturnModels([]interface{}{test_data.PitFileDebtCeilingModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileDebtCeilingLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -15,28 +15,28 @@
package ilk_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"math/rand"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
ilk_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/pit_file/ilk"
)
var _ = Describe("Pit file ilk transformer", func() {
var (
config = ilk.IlkFileConfig
fetcher mocks.MockLogFetcher
converter ilk_mocks.MockPitFileIlkConverter
repository ilk_mocks.MockPitFileIlkRepository
converter mocks.MockConverter
repository mocks.MockRepository
transformer shared.Transformer
headerOne core.Header
headerTwo core.Header
@ -44,8 +44,8 @@ var _ = Describe("Pit file ilk transformer", func() {
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = ilk_mocks.MockPitFileIlkConverter{}
repository = ilk_mocks.MockPitFileIlkRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
transformer = factories.Transformer{
@ -140,6 +140,7 @@ var _ = Describe("Pit file ilk transformer", func() {
})
It("persists pit file model", func() {
converter.SetReturnModels([]interface{}{test_data.PitFileIlkModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileIlkLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -15,28 +15,28 @@
package stability_fee_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
"math/rand"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
stability_fee_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/pit_file/stability_fee"
)
var _ = Describe("Pit file stability fee transformer", func() {
var (
config = stability_fee.StabilityFeeFileConfig
fetcher mocks.MockLogFetcher
converter stability_fee_mocks.MockPitFileStabilityFeeConverter
repository stability_fee_mocks.MockPitFileStabilityFeeRepository
converter mocks.MockConverter
repository mocks.MockRepository
transformer shared.Transformer
headerOne core.Header
headerTwo core.Header
@ -44,8 +44,8 @@ var _ = Describe("Pit file stability fee transformer", func() {
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = stability_fee_mocks.MockPitFileStabilityFeeConverter{}
repository = stability_fee_mocks.MockPitFileStabilityFeeRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
transformer = factories.Transformer{
Config: config,
Fetcher: &fetcher,
@ -70,7 +70,7 @@ var _ = Describe("Pit file stability fee transformer", func() {
})
It("returns error if repository returns error for missing headers", func() {
repository.SetMissingHeadersErr(fakes.FakeError)
repository.SetMissingHeadersError(fakes.FakeError)
err := transformer.Execute()
Expect(err).To(HaveOccurred())
@ -109,7 +109,7 @@ var _ = Describe("Pit file stability fee transformer", func() {
It("returns error if marking header checked returns err", func() {
repository.SetMissingHeaders([]core.Header{headerOne})
repository.SetMarkHeaderCheckedErr(fakes.FakeError)
repository.SetMarkHeaderCheckedError(fakes.FakeError)
err := transformer.Execute()
@ -139,6 +139,7 @@ var _ = Describe("Pit file stability fee transformer", func() {
})
It("persists pit file model", func() {
converter.SetReturnModels([]interface{}{test_data.PitFileStabilityFeeModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -1,62 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package tend_test
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/geth"
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/test_config"
)
// These test are marked as pending until the Flip contract is deployed to Kovan.
var _ = Describe("Integration tests", func() {
XIt("Fetches Tend event logs from a local test chain", func() {
ipcPath := test_config.TestClient.IPCPath
rawRpcClient, err := rpc.Dial(ipcPath)
Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, ipcPath)
ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient)
realNode := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
realBlockChain := geth.NewBlockChain(blockChainClient, rpcClient, realNode, transactionConverter)
realFetcher := shared.NewFetcher(realBlockChain)
topic0 := common.HexToHash(shared.TendFunctionSignature)
topics := [][]common.Hash{{topic0}}
result, err := realFetcher.FetchLogs(tend.TendConfig.ContractAddresses, topics, test_data.FlipKickBlockNumber)
Expect(err).NotTo(HaveOccurred())
Expect(len(result) > 0).To(BeTrue())
Expect(result[0].Address).To(Equal(test_data.EthFlipKickLog.Address))
Expect(result[0].TxHash).To(Equal(test_data.EthFlipKickLog.TxHash))
Expect(result[0].BlockNumber).To(Equal(test_data.EthFlipKickLog.BlockNumber))
Expect(result[0].Topics).To(Equal(test_data.EthFlipKickLog.Topics))
Expect(result[0].Index).To(Equal(test_data.EthFlipKickLog.Index))
})
})

View File

@ -15,28 +15,27 @@
package tend_test
import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
tend_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/tend"
)
var _ = Describe("Tend Transformer", func() {
var (
config = tend.TendConfig
converter tend_mocks.MockTendConverter
repository tend_mocks.MockTendRepository
converter mocks.MockConverter
repository mocks.MockRepository
fetcher mocks.MockLogFetcher
transformer shared.Transformer
headerOne core.Header
@ -44,8 +43,8 @@ var _ = Describe("Tend Transformer", func() {
)
BeforeEach(func() {
converter = tend_mocks.MockTendConverter{}
repository = tend_mocks.MockTendRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
fetcher = mocks.MockLogFetcher{}
headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
@ -71,7 +70,7 @@ var _ = Describe("Tend Transformer", func() {
})
It("returns an error if it fails to get missing headers", func() {
repository.SetMissingHeadersErr(fakes.FakeError)
repository.SetMissingHeadersError(fakes.FakeError)
err := transformer.Execute()
Expect(err).To(HaveOccurred())
@ -108,7 +107,7 @@ var _ = Describe("Tend Transformer", func() {
It("returns error if marking header checked returns err", func() {
repository.SetMissingHeaders([]core.Header{headerOne})
repository.SetMarkHeaderCheckedErr(fakes.FakeError)
repository.SetMarkHeaderCheckedError(fakes.FakeError)
err := transformer.Execute()
@ -136,6 +135,7 @@ var _ = Describe("Tend Transformer", func() {
})
It("persists the tend record", func() {
converter.SetReturnModels([]interface{}{test_data.TendModel})
repository.SetMissingHeaders([]core.Header{headerOne})
fetcher.SetFetchedLogs([]types.Log{test_data.TendLogNote})
@ -143,7 +143,7 @@ var _ = Describe("Tend Transformer", func() {
Expect(err).NotTo(HaveOccurred())
Expect(repository.PassedHeaderID).To(Equal(headerOne.Id))
Expect(repository.PassedTendModel).To(Equal(test_data.TendModel))
Expect(repository.PassedModels).To(Equal([]interface{}{test_data.TendModel}))
})
It("returns error if persisting tend record fails", func() {

View File

@ -0,0 +1,24 @@
package mocks
import (
"github.com/ethereum/go-ethereum/core/types"
)
type MockConverter struct {
err error
returnModels []interface{}
PassedLogs []types.Log
}
func (converter *MockConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return converter.returnModels, converter.err
}
func (converter *MockConverter) SetConverterError(e error) {
converter.err = e
}
func (converter *MockConverter) SetReturnModels(models []interface{}) {
converter.returnModels = models
}

View File

@ -1,34 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ilk
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockDripFileIlkConverter struct {
converterError error
PassedLogs []types.Log
}
func (converter *MockDripFileIlkConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.DripFileIlkModel}, converter.converterError
}
func (converter *MockDripFileIlkConverter) SetConverterError(e error) {
converter.converterError = e
}

View File

@ -1,75 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ilk
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
type MockDripFileIlkRepository struct {
createError error
markHeaderCheckedError error
markHeaderCheckedPassedHeaderID int64
missingHeaders []core.Header
missingHeadersError error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockDripFileIlkRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createError
}
func (repository *MockDripFileIlkRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedError
}
func (repository *MockDripFileIlkRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockDripFileIlkRepository) SetMarkHeaderCheckedError(e error) {
repository.markHeaderCheckedError = e
}
func (repository *MockDripFileIlkRepository) SetMissingHeadersError(e error) {
repository.missingHeadersError = e
}
func (repository *MockDripFileIlkRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockDripFileIlkRepository) SetCreateError(e error) {
repository.createError = e
}
func (repository *MockDripFileIlkRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
}
func (repository *MockDripFileIlkRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}

View File

@ -1,34 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package repo
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockDripFileRepoConverter struct {
converterError error
PassedLogs []types.Log
}
func (converter *MockDripFileRepoConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.DripFileRepoModel}, converter.converterError
}
func (converter *MockDripFileRepoConverter) SetConverterError(e error) {
converter.converterError = e
}

View File

@ -1,76 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package repo
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
type MockDripFileRepoRepository struct {
createError error
markHeaderCheckedError error
markHeaderCheckedPassedHeaderID int64
missingHeaders []core.Header
missingHeadersError error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockDripFileRepoRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createError
}
func (repository *MockDripFileRepoRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedError
}
func (repository *MockDripFileRepoRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockDripFileRepoRepository) SetMarkHeaderCheckedError(e error) {
repository.markHeaderCheckedError = e
}
func (repository *MockDripFileRepoRepository) SetMissingHeadersError(e error) {
repository.missingHeadersError = e
}
func (repository *MockDripFileRepoRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockDripFileRepoRepository) SetCreateError(e error) {
repository.createError = e
}
func (repository *MockDripFileRepoRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
}
func (repository *MockDripFileRepoRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}

View File

@ -1,34 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package vow
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockDripFileVowConverter struct {
converterErr error
PassedLogs []types.Log
}
func (converter *MockDripFileVowConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.DripFileVowModel}, converter.converterErr
}
func (converter *MockDripFileVowConverter) SetConverterError(e error) {
converter.converterErr = e
}

View File

@ -1,75 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package vow
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
type MockDripFileVowRepository struct {
createError error
markHeaderCheckedError error
markHeaderCheckedPassedHeaderID int64
missingHeaders []core.Header
missingHeadersError error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockDripFileVowRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createError
}
func (repository *MockDripFileVowRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedError
}
func (repository *MockDripFileVowRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockDripFileVowRepository) SetMarkHeaderCheckedError(e error) {
repository.markHeaderCheckedError = e
}
func (repository *MockDripFileVowRepository) SetMissingHeadersError(e error) {
repository.missingHeadersError = e
}
func (repository *MockDripFileVowRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockDripFileVowRepository) SetCreateError(e error) {
repository.createError = e
}
func (repository *MockDripFileVowRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
}
func (repository *MockDripFileVowRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}

View File

@ -1,35 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package debt_ceiling
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockPitFileDebtCeilingConverter struct {
converterError error
PassedLogs []types.Log
}
func (converter *MockPitFileDebtCeilingConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.PitFileDebtCeilingModel}, converter.converterError
}
func (converter *MockPitFileDebtCeilingConverter) SetConverterError(e error) {
converter.converterError = e
}

View File

@ -1,76 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package debt_ceiling
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
type MockPitFileDebtCeilingRepository struct {
createError error
markHeaderCheckedError error
markHeaderCheckedPassedHeaderID int64
missingHeaders []core.Header
missingHeadersError error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockPitFileDebtCeilingRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedError
}
func (repository *MockPitFileDebtCeilingRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createError
}
func (repository *MockPitFileDebtCeilingRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockPitFileDebtCeilingRepository) SetMarkHeaderCheckedError(e error) {
repository.markHeaderCheckedError = e
}
func (repository *MockPitFileDebtCeilingRepository) SetMissingHeadersError(e error) {
repository.missingHeadersError = e
}
func (repository *MockPitFileDebtCeilingRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockPitFileDebtCeilingRepository) SetCreateError(e error) {
repository.createError = e
}
func (repository *MockPitFileDebtCeilingRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
}
func (repository *MockPitFileDebtCeilingRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}

View File

@ -1,35 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ilk
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockPitFileIlkConverter struct {
PassedLogs []types.Log
converterError error
}
func (converter *MockPitFileIlkConverter) SetConverterError(err error) {
converter.converterError = err
}
func (converter *MockPitFileIlkConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.PitFileIlkModel}, converter.converterError
}

View File

@ -1,76 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ilk
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
type MockPitFileIlkRepository struct {
createError error
PassedEndingBlockNumber int64
PassedModels []interface{}
PassedHeaderID int64
PassedStartingBlockNumber int64
markHeaderCheckedError error
markHeaderCheckedPassedHeaderID int64
missingHeaders []core.Header
missingHeadersError error
SetDbCalled bool
}
func (repository *MockPitFileIlkRepository) SetCreateError(err error) {
repository.createError = err
}
func (repository *MockPitFileIlkRepository) SetMarkHeaderCheckedError(e error) {
repository.markHeaderCheckedError = e
}
func (repository *MockPitFileIlkRepository) SetMissingHeadersError(err error) {
repository.missingHeadersError = err
}
func (repository *MockPitFileIlkRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockPitFileIlkRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createError
}
func (repository *MockPitFileIlkRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedError
}
func (repository *MockPitFileIlkRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockPitFileIlkRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
}
func (repository *MockPitFileIlkRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}

View File

@ -1,35 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package stability_fee
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockPitFileStabilityFeeConverter struct {
converterError error
PassedLogs []types.Log
}
func (converter *MockPitFileStabilityFeeConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.PitFileStabilityFeeModel}, converter.converterError
}
func (converter *MockPitFileStabilityFeeConverter) SetConverterError(e error) {
converter.converterError = e
}

View File

@ -1,76 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package stability_fee
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
type MockPitFileStabilityFeeRepository struct {
createError error
markHeaderCheckedError error
markHeaderCheckedPassedHeaderID int64
missingHeaders []core.Header
missingHeadersError error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockPitFileStabilityFeeRepository) Create(headerID int64, models []interface{}) error {
repository.PassedModels = models
repository.PassedHeaderID = headerID
return repository.createError
}
func (repository *MockPitFileStabilityFeeRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedError
}
func (repository *MockPitFileStabilityFeeRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockPitFileStabilityFeeRepository) SetMarkHeaderCheckedErr(e error) {
repository.markHeaderCheckedError = e
}
func (repository *MockPitFileStabilityFeeRepository) SetMissingHeadersErr(e error) {
repository.missingHeadersError = e
}
func (repository *MockPitFileStabilityFeeRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockPitFileStabilityFeeRepository) SetCreateError(e error) {
repository.createError = e
}
func (repository *MockPitFileStabilityFeeRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
}
func (repository *MockPitFileStabilityFeeRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}

View File

@ -0,0 +1,62 @@
package mocks
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
)
type MockRepository struct {
createError error
markHeaderCheckedError error
markHeaderCheckedPassedHeaderIDs []int64
missingHeaders []core.Header
missingHeadersError error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createError
}
func (repository *MockRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderIDs = append(repository.markHeaderCheckedPassedHeaderIDs, headerID)
return repository.markHeaderCheckedError
}
func (repository *MockRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}
func (repository *MockRepository) SetMissingHeadersError(e error) {
repository.missingHeadersError = e
}
func (repository *MockRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderIDs).To(ContainElement(i))
}
func (repository *MockRepository) SetMarkHeaderCheckedError(e error) {
repository.markHeaderCheckedError = e
}
func (repository *MockRepository) SetCreateError(e error) {
repository.createError = e
}

View File

@ -1,35 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package tend
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockTendConverter struct {
PassedLogs []types.Log
ConverterError error
}
func (converter *MockTendConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.TendModel}, converter.ConverterError
}
func (converter *MockTendConverter) SetConverterError(err error) {
converter.ConverterError = err
}

View File

@ -1,76 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package tend
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
type MockTendRepository struct {
createError error
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedStartingBlockNumber int64
PassedTendModel interface{}
markHeaderCheckedError error
markHeaderCheckedPassedHeaderId int64
missingHeaders []core.Header
missingHeadersError error
SetDbCalled bool
}
func (repository *MockTendRepository) Create(headerId int64, tend []interface{}) error {
repository.PassedHeaderID = headerId
repository.PassedTendModel = tend[0]
return repository.createError
}
func (repository *MockTendRepository) SetCreateError(err error) {
repository.createError = err
}
func (repository *MockTendRepository) SetMarkHeaderCheckedErr(err error) {
repository.markHeaderCheckedError = err
}
func (repository *MockTendRepository) SetMissingHeadersErr(err error) {
repository.missingHeadersError = err
}
func (repository *MockTendRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockTendRepository) MarkHeaderChecked(headerId int64) error {
repository.markHeaderCheckedPassedHeaderId = headerId
return repository.markHeaderCheckedError
}
func (repository *MockTendRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockTendRepository) AssertMarkHeaderCheckedCalledWith(headerId int64) {
Expect(repository.markHeaderCheckedPassedHeaderId).To(Equal(headerId))
}
func (repository *MockTendRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}

View File

@ -1,21 +0,0 @@
package vat_flux
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockVatFluxConverter struct {
err error
PassedLogs []types.Log
}
func (converter *MockVatFluxConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.VatFluxModel}, converter.err
}
func (converter *MockVatFluxConverter) SetConverterError(e error) {
converter.err = e
}

View File

@ -1,70 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package vat_flux
import (
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
)
type MockVatFluxRepository struct {
createErr error
markHeaderCheckedErr error
MarkHeaderCheckedPassedHeaderID int64
missingHeaders []core.Header
missingHeadersErr error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockVatFluxRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createErr
}
func (repository *MockVatFluxRepository) MarkHeaderChecked(headerID int64) error {
repository.MarkHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedErr
}
func (repository *MockVatFluxRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersErr
}
func (repository *MockVatFluxRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}
func (repository *MockVatFluxRepository) SetMarkHeaderCheckedErr(e error) {
repository.markHeaderCheckedErr = e
}
func (repository *MockVatFluxRepository) SetMissingHeadersErr(e error) {
repository.missingHeadersErr = e
}
func (repository *MockVatFluxRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockVatFluxRepository) SetCreateError(e error) {
repository.createErr = e
}

View File

@ -1,35 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package vat_init
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockVatInitConverter struct {
converterError error
PassedLogs []types.Log
}
func (converter *MockVatInitConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.VatInitModel}, converter.converterError
}
func (converter *MockVatInitConverter) SetConverterError(e error) {
converter.converterError = e
}

View File

@ -1,76 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package vat_init
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
type MockVatInitRepository struct {
createError error
markHeaderCheckedError error
markHeaderCheckedPassedHeaderID int64
missingHeaders []core.Header
missingHeadersError error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockVatInitRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createError
}
func (repository *MockVatInitRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedError
}
func (repository *MockVatInitRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockVatInitRepository) SetMarkHeaderCheckedError(e error) {
repository.markHeaderCheckedError = e
}
func (repository *MockVatInitRepository) SetMissingHeadersError(e error) {
repository.missingHeadersError = e
}
func (repository *MockVatInitRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockVatInitRepository) SetCreateError(e error) {
repository.createError = e
}
func (repository *MockVatInitRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
}
func (repository *MockVatInitRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}

View File

@ -1,34 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package vat_move
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockVatMoveConverter struct {
converterError error
PassedLogs []types.Log
}
func (converter *MockVatMoveConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.VatMoveModel}, converter.converterError
}
func (converter *MockVatMoveConverter) SetConverterError(e error) {
converter.converterError = e
}

View File

@ -1,70 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package vat_move
import (
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
)
type MockVatMoveRepository struct {
createError error
missingHeaders []core.Header
missingHeadersError error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
CheckedHeaderIDs []int64
CheckedHeaderError error
SetDbCalled bool
}
func (repository *MockVatMoveRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createError
}
func (repository *MockVatMoveRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockVatMoveRepository) SetMissingHeadersError(e error) {
repository.missingHeadersError = e
}
func (repository *MockVatMoveRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockVatMoveRepository) SetCreateError(e error) {
repository.createError = e
}
func (repository *MockVatMoveRepository) MarkHeaderChecked(headerId int64) error {
repository.CheckedHeaderIDs = append(repository.CheckedHeaderIDs, headerId)
return repository.CheckedHeaderError
}
func (repository *MockVatMoveRepository) SetCheckedHeaderError(e error) {
repository.CheckedHeaderError = e
}
func (repository *MockVatMoveRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}

View File

@ -1,34 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package vat_slip
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockVatSlipConverter struct {
err error
PassedLogs []types.Log
}
func (converter *MockVatSlipConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.VatSlipModel}, converter.err
}
func (converter *MockVatSlipConverter) SetConverterError(e error) {
converter.err = e
}

View File

@ -1,76 +0,0 @@
// Copyright 2018 Vulcanize
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package vat_slip
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
)
type MockVatSlipRepository struct {
createError error
markHeaderCheckedError error
markHeaderCheckedPassedHeaderID int64
missingHeadersError error
missingHeaders []core.Header
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockVatSlipRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createError
}
func (repository *MockVatSlipRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedError
}
func (repository *MockVatSlipRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersError
}
func (repository *MockVatSlipRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}
func (repository *MockVatSlipRepository) SetCreateError(e error) {
repository.createError = e
}
func (repository *MockVatSlipRepository) SetMarkHeaderCheckedErr(e error) {
repository.markHeaderCheckedError = e
}
func (repository *MockVatSlipRepository) SetMissingHeadersErr(e error) {
repository.missingHeadersError = e
}
func (repository *MockVatSlipRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockVatSlipRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
}

View File

@ -1,20 +0,0 @@
package vat_toll
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockVatTollConverter struct {
err error
PassedLogs []types.Log
}
func (converter *MockVatTollConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.VatTollModel}, converter.err
}
func (converter *MockVatTollConverter) SetConverterError(e error) {
converter.err = e
}

View File

@ -1,62 +0,0 @@
package vat_toll
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
)
type MockVatTollRepository struct {
createErr error
markHeaderCheckedErr error
markHeaderCheckedPassedHeaderID int64
missingHeadersErr error
missingHeaders []core.Header
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockVatTollRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createErr
}
func (repository *MockVatTollRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedErr
}
func (repository *MockVatTollRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersErr
}
func (repository *MockVatTollRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}
func (repository *MockVatTollRepository) SetCreateError(e error) {
repository.createErr = e
}
func (repository *MockVatTollRepository) SetMarkHeaderCheckedErr(e error) {
repository.markHeaderCheckedErr = e
}
func (repository *MockVatTollRepository) SetMissingHeadersErr(e error) {
repository.missingHeadersErr = e
}
func (repository *MockVatTollRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockVatTollRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
}

View File

@ -1,20 +0,0 @@
package vat_tune
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockVatTuneConverter struct {
err error
PassedLogs []types.Log
}
func (converter *MockVatTuneConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
converter.PassedLogs = ethLogs
return []interface{}{test_data.VatTuneModel}, converter.err
}
func (converter *MockVatTuneConverter) SetConverterError(e error) {
converter.err = e
}

View File

@ -1,62 +0,0 @@
package vat_tune
import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
)
type MockVatTuneRepository struct {
createErr error
markHeaderCheckedErr error
markHeaderCheckedPassedHeaderID int64
missingHeaders []core.Header
missingHeadersErr error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModels []interface{}
SetDbCalled bool
}
func (repository *MockVatTuneRepository) Create(headerID int64, models []interface{}) error {
repository.PassedHeaderID = headerID
repository.PassedModels = models
return repository.createErr
}
func (repository *MockVatTuneRepository) MarkHeaderChecked(headerID int64) error {
repository.markHeaderCheckedPassedHeaderID = headerID
return repository.markHeaderCheckedErr
}
func (repository *MockVatTuneRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersErr
}
func (repository *MockVatTuneRepository) SetDB(db *postgres.DB) {
repository.SetDbCalled = true
}
func (repository *MockVatTuneRepository) SetMissingHeadersErr(e error) {
repository.missingHeadersErr = e
}
func (repository *MockVatTuneRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockVatTuneRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
}
func (repository *MockVatTuneRepository) SetMarkHeaderCheckedErr(e error) {
repository.markHeaderCheckedErr = e
}
func (repository *MockVatTuneRepository) SetCreateError(e error) {
repository.createErr = e
}

View File

@ -1,28 +1,28 @@
package vat_flux_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/ethereum/go-ethereum/common"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
vat_flux_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/vat_flux"
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_flux"
"math/rand"
)
var _ = Describe("Vat flux transformer", func() {
var (
config = vat_flux.VatFluxConfig
fetcher mocks.MockLogFetcher
converter vat_flux_mocks.MockVatFluxConverter
repository vat_flux_mocks.MockVatFluxRepository
converter mocks.MockConverter
repository mocks.MockRepository
transformer shared.Transformer
headerOne core.Header
headerTwo core.Header
@ -30,8 +30,8 @@ var _ = Describe("Vat flux transformer", func() {
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = vat_flux_mocks.MockVatFluxConverter{}
repository = vat_flux_mocks.MockVatFluxRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
transformer = factories.Transformer{
@ -56,7 +56,7 @@ var _ = Describe("Vat flux transformer", func() {
})
It("returns error if repository returns error for missing headers", func() {
repository.SetMissingHeadersErr(fakes.FakeError)
repository.SetMissingHeadersError(fakes.FakeError)
err := transformer.Execute()
Expect(err).To(HaveOccurred())
@ -89,12 +89,12 @@ var _ = Describe("Vat flux transformer", func() {
err := transformer.Execute()
Expect(err).NotTo(HaveOccurred())
Expect(repository.MarkHeaderCheckedPassedHeaderID).To(Equal(headerOne.Id))
repository.AssertMarkHeaderCheckedCalledWith(headerOne.Id)
})
It("returns error if marking header checked returns err", func() {
repository.SetMissingHeaders([]core.Header{headerOne})
repository.SetMarkHeaderCheckedErr(fakes.FakeError)
repository.SetMarkHeaderCheckedError(fakes.FakeError)
err := transformer.Execute()
@ -124,6 +124,7 @@ var _ = Describe("Vat flux transformer", func() {
})
It("persists vat flux model", func() {
converter.SetReturnModels([]interface{}{test_data.VatFluxModel})
fetcher.SetFetchedLogs([]types.Log{test_data.VatFluxLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -15,27 +15,27 @@
package vat_init_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"math/rand"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
vat_init_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/vat_init"
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_init"
)
var _ = Describe("Vat init transformer", func() {
var (
config = vat_init.VatInitConfig
converter vat_init_mocks.MockVatInitConverter
repository vat_init_mocks.MockVatInitRepository
converter mocks.MockConverter
repository mocks.MockRepository
fetcher mocks.MockLogFetcher
transformer shared.Transformer
headerOne core.Header
@ -43,8 +43,8 @@ var _ = Describe("Vat init transformer", func() {
)
BeforeEach(func() {
converter = vat_init_mocks.MockVatInitConverter{}
repository = vat_init_mocks.MockVatInitRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
fetcher = mocks.MockLogFetcher{}
headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
@ -141,6 +141,7 @@ var _ = Describe("Vat init transformer", func() {
})
It("persists vat init model", func() {
converter.SetReturnModels([]interface{}{test_data.VatInitModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthVatInitLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -15,34 +15,35 @@
package vat_move_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
vat_move_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/vat_move"
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_move"
"math/rand"
)
var _ = Describe("Vat move transformer", func() {
var config = vat_move.VatMoveConfig
var fetcher mocks.MockLogFetcher
var converter vat_move_mocks.MockVatMoveConverter
var repository vat_move_mocks.MockVatMoveRepository
var converter mocks.MockConverter
var repository mocks.MockRepository
var transformer shared.Transformer
var headerOne core.Header
var headerTwo core.Header
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = vat_move_mocks.MockVatMoveConverter{}
repository = vat_move_mocks.MockVatMoveRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
transformer = factories.Transformer{
@ -126,13 +127,13 @@ var _ = Describe("Vat move transformer", func() {
err := transformer.Execute()
Expect(err).NotTo(HaveOccurred())
Expect(repository.CheckedHeaderIDs).To(ContainElement(headerOne.Id))
Expect(repository.CheckedHeaderIDs).To(ContainElement(headerTwo.Id))
repository.AssertMarkHeaderCheckedCalledWith(headerOne.Id)
repository.AssertMarkHeaderCheckedCalledWith(headerTwo.Id)
})
It("returns error if marking header checked returns err", func() {
repository.SetMissingHeaders([]core.Header{headerOne, headerTwo})
repository.SetCheckedHeaderError(fakes.FakeError)
repository.SetMarkHeaderCheckedError(fakes.FakeError)
fetcher.SetFetchedLogs([]types.Log{})
err := transformer.Execute()
@ -142,6 +143,7 @@ var _ = Describe("Vat move transformer", func() {
})
It("persists vat move model", func() {
converter.SetReturnModels([]interface{}{test_data.VatMoveModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthVatMoveLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -12,7 +12,6 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
vat_slip_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/vat_slip"
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_slip"
"math/rand"
)
@ -21,8 +20,8 @@ var _ = Describe("Vat slip transformer", func() {
var (
config = vat_slip.VatSlipConfig
fetcher mocks.MockLogFetcher
converter vat_slip_mocks.MockVatSlipConverter
repository vat_slip_mocks.MockVatSlipRepository
converter mocks.MockConverter
repository mocks.MockRepository
transformer shared.Transformer
headerOne core.Header
headerTwo core.Header
@ -30,8 +29,8 @@ var _ = Describe("Vat slip transformer", func() {
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = vat_slip_mocks.MockVatSlipConverter{}
repository = vat_slip_mocks.MockVatSlipRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
transformer = factories.Transformer{
@ -56,7 +55,7 @@ var _ = Describe("Vat slip transformer", func() {
})
It("returns error if repository returns error for missing headers", func() {
repository.SetMissingHeadersErr(fakes.FakeError)
repository.SetMissingHeadersError(fakes.FakeError)
err := transformer.Execute()
@ -96,7 +95,7 @@ var _ = Describe("Vat slip transformer", func() {
It("returns error if marking header checked returns err", func() {
repository.SetMissingHeaders([]core.Header{headerOne})
repository.SetMarkHeaderCheckedErr(fakes.FakeError)
repository.SetMarkHeaderCheckedError(fakes.FakeError)
err := transformer.Execute()
@ -126,6 +125,7 @@ var _ = Describe("Vat slip transformer", func() {
})
It("persists vat slip model", func() {
converter.SetReturnModels([]interface{}{test_data.VatSlipModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthVatSlipLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -1,6 +1,8 @@
package vat_toll_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
@ -12,17 +14,15 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
vat_toll_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/vat_toll"
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_toll"
"math/rand"
)
var _ = Describe("Vat toll transformer", func() {
var (
config = vat_toll.VatTollConfig
fetcher mocks.MockLogFetcher
converter vat_toll_mocks.MockVatTollConverter
repository vat_toll_mocks.MockVatTollRepository
converter mocks.MockConverter
repository mocks.MockRepository
transformer shared.Transformer
headerOne core.Header
headerTwo core.Header
@ -30,8 +30,8 @@ var _ = Describe("Vat toll transformer", func() {
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = vat_toll_mocks.MockVatTollConverter{}
repository = vat_toll_mocks.MockVatTollRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
transformer = factories.Transformer{
@ -56,7 +56,7 @@ var _ = Describe("Vat toll transformer", func() {
})
It("returns error if repository returns error for missing headers", func() {
repository.SetMissingHeadersErr(fakes.FakeError)
repository.SetMissingHeadersError(fakes.FakeError)
err := transformer.Execute()
@ -96,7 +96,7 @@ var _ = Describe("Vat toll transformer", func() {
It("returns error if marking header checked returns err", func() {
repository.SetMissingHeaders([]core.Header{headerOne})
repository.SetMarkHeaderCheckedErr(fakes.FakeError)
repository.SetMarkHeaderCheckedError(fakes.FakeError)
err := transformer.Execute()
@ -126,6 +126,7 @@ var _ = Describe("Vat toll transformer", func() {
})
It("persists vat toll model", func() {
converter.SetReturnModels([]interface{}{test_data.VatTollModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthVatTollLog})
repository.SetMissingHeaders([]core.Header{headerOne})

View File

@ -1,6 +1,8 @@
package vat_tune_test
import (
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
@ -12,17 +14,15 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
vat_tune_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/vat_tune"
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_tune"
"math/rand"
)
var _ = Describe("Vat tune transformer", func() {
var (
config = vat_tune.VatTuneConfig
fetcher mocks.MockLogFetcher
converter vat_tune_mocks.MockVatTuneConverter
repository vat_tune_mocks.MockVatTuneRepository
converter mocks.MockConverter
repository mocks.MockRepository
transformer shared.Transformer
headerOne core.Header
headerTwo core.Header
@ -30,8 +30,8 @@ var _ = Describe("Vat tune transformer", func() {
BeforeEach(func() {
fetcher = mocks.MockLogFetcher{}
converter = vat_tune_mocks.MockVatTuneConverter{}
repository = vat_tune_mocks.MockVatTuneRepository{}
converter = mocks.MockConverter{}
repository = mocks.MockRepository{}
headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
headerTwo = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
transformer = factories.Transformer{
@ -56,7 +56,7 @@ var _ = Describe("Vat tune transformer", func() {
})
It("returns error if repository returns error for missing headers", func() {
repository.SetMissingHeadersErr(fakes.FakeError)
repository.SetMissingHeadersError(fakes.FakeError)
err := transformer.Execute()
@ -96,7 +96,7 @@ var _ = Describe("Vat tune transformer", func() {
It("returns error if marking header checked returns err", func() {
repository.SetMissingHeaders([]core.Header{headerOne})
repository.SetMarkHeaderCheckedErr(fakes.FakeError)
repository.SetMarkHeaderCheckedError(fakes.FakeError)
err := transformer.Execute()
@ -126,6 +126,7 @@ var _ = Describe("Vat tune transformer", func() {
})
It("persists vat tune model", func() {
converter.SetReturnModels([]interface{}{test_data.VatTuneModel})
fetcher.SetFetchedLogs([]types.Log{test_data.EthVatTuneLog})
repository.SetMissingHeaders([]core.Header{headerOne})