Add tests for plugin helpers

- Prevents code analysis from showing functions as unused
- Also address other code analysis issues
This commit is contained in:
Rob Mulholand
2019-03-06 12:43:39 -06:00
parent a806cb2818
commit b6bef49318
17 changed files with 390 additions and 154 deletions
+4 -4
View File
@@ -50,8 +50,8 @@ func NewStorageWatcher(tailer fs.Tailer, db *postgres.DB) StorageWatcher {
func (watcher StorageWatcher) AddTransformers(initializers []transformer.StorageTransformerInitializer) {
for _, initializer := range initializers {
transformer := initializer(watcher.db)
watcher.Transformers[transformer.ContractAddress()] = transformer
storageTransformer := initializer(watcher.db)
watcher.Transformers[storageTransformer.ContractAddress()] = storageTransformer
}
}
@@ -65,12 +65,12 @@ func (watcher StorageWatcher) Execute() error {
if parseErr != nil {
return parseErr
}
transformer, ok := watcher.Transformers[row.Contract]
storageTransformer, ok := watcher.Transformers[row.Contract]
if !ok {
logrus.Warn(utils.ErrContractNotFound{Contract: row.Contract.Hex()}.Error())
continue
}
executeErr := transformer.Execute(row)
executeErr := storageTransformer.Execute(row)
if executeErr != nil {
if isKeyNotFound(executeErr) {
queueErr := watcher.Queue.Add(row)