Skip to content

Commit

Permalink
fix: add more cases for missing data errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aramalipoor committed Aug 30, 2024
1 parent c6922da commit 6f7c769
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 9 additions & 4 deletions erpc/networks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3872,7 +3872,7 @@ func TestNetwork_Forward(t *testing.T) {
rateLimitersRegistry,
)

_, err = networksRegistry.RegisterNetwork(
ntw, err := networksRegistry.RegisterNetwork(
&logger,
&common.ProjectConfig{Id: projectID},
&common.NetworkConfig{
Expand Down Expand Up @@ -3917,20 +3917,25 @@ func TestNetwork_Forward(t *testing.T) {

wg := sync.WaitGroup{}
for _, method := range allMethods {
for i := 0; i < 1; i++ {
for i := 0; i < 100; i++ {
wg.Add(1)
go func(method string) {
defer wg.Done()
upstreamsRegistry.RefreshUpstreamNetworkMethodScores()
req := common.NewNormalizedRequest([]byte(fmt.Sprintf(`{"jsonrpc":"2.0","method":"%s","params":[],"id":1}`, method)))
ups, err := upstreamsRegistry.GetSortedUpstreams(networkID, method)
req.SetNetwork(ntw)
oups, err := upstreamsRegistry.GetSortedUpstreams(networkID, method)
upstreamsRegistry.RLockUpstreams()
ups := []*upstream.Upstream{}
ups = append(ups, oups...)
upstreamsRegistry.RUnlockUpstreams()
assert.NoError(t, err)
for _, up := range ups {
_, err = up.Forward(ctx, req)
assert.NoError(t, err)
}
}(method)
time.Sleep(1 * time.Millisecond)
// time.Sleep(1 * time.Millisecond)
}
}
wg.Wait()
Expand Down
3 changes: 2 additions & 1 deletion upstream/http_json_rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ func extractJsonRpcError(r *http.Response, nr *common.NormalizedResponse, jr *co
),
)
} else if strings.Contains(err.Message, "transaction not found") ||
strings.Contains(err.Message, "cannot find transaction") {
strings.Contains(err.Message, "cannot find transaction") ||
strings.Contains(err.Message, "after last accepted block") {
return common.NewErrEndpointMissingData(
common.NewErrJsonRpcExceptionInternal(
int(code),
Expand Down

0 comments on commit 6f7c769

Please sign in to comment.