use configurable timeout for geth batch http requests; additional error log info in payload fetchers

This commit is contained in:
Ian Norden
2020-04-20 11:05:12 -05:00
parent b3be8aaa05
commit eceaa0aecb
16 changed files with 128 additions and 32 deletions
+22
View File
@@ -17,6 +17,7 @@
package mocks
import (
"context"
"encoding/json"
"errors"
@@ -62,3 +63,24 @@ func (mc *BackFillerClient) BatchCall(batch []client.BatchElem) error {
}
return nil
}
// BatchCallContext mockClient method to simulate batch call to geth
func (mc *BackFillerClient) BatchCallContext(ctx context.Context, batch []client.BatchElem) error {
if mc.MappedStateDiffAt == nil {
return errors.New("mockclient needs to be initialized with statediff payloads and errors")
}
for _, batchElem := range batch {
if len(batchElem.Args) != 1 {
return errors.New("expected batch elem to contain single argument")
}
blockHeight, ok := batchElem.Args[0].(uint64)
if !ok {
return errors.New("expected batch elem argument to be a uint64")
}
err := json.Unmarshal(mc.MappedStateDiffAt[blockHeight], batchElem.Result)
if err != nil {
return err
}
}
return nil
}