2018-10-25 01:37:12 +00:00
|
|
|
package mocks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MockConverter struct {
|
2018-11-02 14:13:10 +00:00
|
|
|
ToEntitiesError error
|
|
|
|
PassedContractAddresses []string
|
|
|
|
ToModelsError error
|
|
|
|
entityConverterError error
|
|
|
|
modelConverterError error
|
|
|
|
ContractAbi string
|
|
|
|
LogsToConvert []types.Log
|
|
|
|
EntitiesToConvert []interface{}
|
|
|
|
EntitiesToReturn []interface{}
|
|
|
|
ModelsToReturn []interface{}
|
2018-11-06 16:30:11 +00:00
|
|
|
ToEntitiesCalledCounter int
|
|
|
|
ToModelsCalledCounter int
|
2018-10-25 01:37:12 +00:00
|
|
|
}
|
|
|
|
|
2018-10-26 18:26:10 +00:00
|
|
|
func (converter *MockConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]interface{}, error) {
|
2018-11-02 14:13:10 +00:00
|
|
|
for _, log := range ethLogs {
|
|
|
|
converter.PassedContractAddresses = append(converter.PassedContractAddresses, log.Address.Hex())
|
|
|
|
}
|
2018-10-26 18:26:10 +00:00
|
|
|
converter.ContractAbi = contractAbi
|
|
|
|
converter.LogsToConvert = ethLogs
|
|
|
|
return converter.EntitiesToReturn, converter.ToEntitiesError
|
2018-10-25 01:37:12 +00:00
|
|
|
}
|
|
|
|
|
2018-10-26 18:26:10 +00:00
|
|
|
func (converter *MockConverter) ToModels(entities []interface{}) ([]interface{}, error) {
|
|
|
|
converter.EntitiesToConvert = entities
|
|
|
|
return converter.ModelsToReturn, converter.ToModelsError
|
2018-10-25 01:37:12 +00:00
|
|
|
}
|
2018-11-02 14:13:10 +00:00
|
|
|
|
|
|
|
func (converter *MockConverter) SetToEntityConverterError(err error) {
|
|
|
|
converter.entityConverterError = err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *MockConverter) SetToModelConverterError(err error) {
|
|
|
|
c.modelConverterError = err
|
|
|
|
}
|