ipld-eth-server/pkg/transformers/test_data/mocks/converter.go
Elizabeth bfe4531d7e Common transformer tests (#97)
* Move chop lump transformer test to a generic log_note_transformer_test

* Add test cases to transformer test

- cat file flip
- cat file pit vow
- deal
- dent

* Move transformer tests over to transformer factor test file

- drip drip
- drip file ilk/repo/vow
- pit file deb ceiling/ilk/stability fee
- price feeds

* Move LogNoteTransformer test into factory package and remove log specific transformer tests

* Move Transformer test into factory package and remove log event specific transformer tests

* Respond to PR comments
2018-11-06 10:30:11 -06:00

43 lines
1.3 KiB
Go

package mocks
import (
"github.com/ethereum/go-ethereum/core/types"
)
type MockConverter struct {
ToEntitiesError error
PassedContractAddresses []string
ToModelsError error
entityConverterError error
modelConverterError error
ContractAbi string
LogsToConvert []types.Log
EntitiesToConvert []interface{}
EntitiesToReturn []interface{}
ModelsToReturn []interface{}
ToEntitiesCalledCounter int
ToModelsCalledCounter int
}
func (converter *MockConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]interface{}, error) {
for _, log := range ethLogs {
converter.PassedContractAddresses = append(converter.PassedContractAddresses, log.Address.Hex())
}
converter.ContractAbi = contractAbi
converter.LogsToConvert = ethLogs
return converter.EntitiesToReturn, converter.ToEntitiesError
}
func (converter *MockConverter) ToModels(entities []interface{}) ([]interface{}, error) {
converter.EntitiesToConvert = entities
return converter.ModelsToReturn, converter.ToModelsError
}
func (converter *MockConverter) SetToEntityConverterError(err error) {
converter.entityConverterError = err
}
func (c *MockConverter) SetToModelConverterError(err error) {
c.modelConverterError = err
}