Use not healthy as error msg (#41)
* use not healthy as error msg * update wording only
This commit is contained in:
parent
98e261e7f9
commit
1cacaab6b5
@ -56,7 +56,7 @@ var (
|
|||||||
}
|
}
|
||||||
ErrNoBackends = &RPCErr{
|
ErrNoBackends = &RPCErr{
|
||||||
Code: JSONRPCErrorInternal - 11,
|
Code: JSONRPCErrorInternal - 11,
|
||||||
Message: "no backends available for method",
|
Message: "no backend is currently healthy to serve traffic",
|
||||||
HTTPErrorCode: 503,
|
HTTPErrorCode: 503,
|
||||||
}
|
}
|
||||||
ErrBackendOverCapacity = &RPCErr{
|
ErrBackendOverCapacity = &RPCErr{
|
||||||
|
@ -66,8 +66,8 @@ func TestBatching(t *testing.T) {
|
|||||||
NewRPCReq("2", "eth_chainId", nil),
|
NewRPCReq("2", "eth_chainId", nil),
|
||||||
},
|
},
|
||||||
expectedRes: asArray(
|
expectedRes: asArray(
|
||||||
`{"error":{"code":-32011,"message":"no backends available for method"},"id":1,"jsonrpc":"2.0"}`,
|
`{"error":{"code":-32011,"message":"no backend is currently healthy to serve traffic"},"id":1,"jsonrpc":"2.0"}`,
|
||||||
`{"error":{"code":-32011,"message":"no backends available for method"},"id":2,"jsonrpc":"2.0"}`,
|
`{"error":{"code":-32011,"message":"no backend is currently healthy to serve traffic"},"id":2,"jsonrpc":"2.0"}`,
|
||||||
),
|
),
|
||||||
maxUpstreamBatchSize: 10,
|
maxUpstreamBatchSize: 10,
|
||||||
numExpectedForwards: 1,
|
numExpectedForwards: 1,
|
||||||
@ -80,8 +80,8 @@ func TestBatching(t *testing.T) {
|
|||||||
NewRPCReq("2", "eth_chainId", nil),
|
NewRPCReq("2", "eth_chainId", nil),
|
||||||
},
|
},
|
||||||
expectedRes: asArray(
|
expectedRes: asArray(
|
||||||
`{"error":{"code":-32011,"message":"no backends available for method"},"id":1,"jsonrpc":"2.0"}`,
|
`{"error":{"code":-32011,"message":"no backend is currently healthy to serve traffic"},"id":1,"jsonrpc":"2.0"}`,
|
||||||
`{"error":{"code":-32011,"message":"no backends available for method"},"id":2,"jsonrpc":"2.0"}`,
|
`{"error":{"code":-32011,"message":"no backend is currently healthy to serve traffic"},"id":2,"jsonrpc":"2.0"}`,
|
||||||
),
|
),
|
||||||
maxUpstreamBatchSize: 1,
|
maxUpstreamBatchSize: 1,
|
||||||
numExpectedForwards: 2,
|
numExpectedForwards: 2,
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
goodResponse = `{"jsonrpc": "2.0", "result": "hello", "id": 999}`
|
goodResponse = `{"jsonrpc": "2.0", "result": "hello", "id": 999}`
|
||||||
noBackendsResponse = `{"error":{"code":-32011,"message":"no backends available for method"},"id":999,"jsonrpc":"2.0"}`
|
noBackendsResponse = `{"error":{"code":-32011,"message":"no backend is currently healthy to serve traffic"},"id":999,"jsonrpc":"2.0"}`
|
||||||
unexpectedResponse = `{"error":{"code":-32011,"message":"some error"},"id":999,"jsonrpc":"2.0"}`
|
unexpectedResponse = `{"error":{"code":-32011,"message":"some error"},"id":999,"jsonrpc":"2.0"}`
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ func TestFailover(t *testing.T) {
|
|||||||
}))
|
}))
|
||||||
res, statusCode, _ := client.SendRPC("eth_chainId", nil)
|
res, statusCode, _ := client.SendRPC("eth_chainId", nil)
|
||||||
require.Equal(t, 503, statusCode)
|
require.Equal(t, 503, statusCode)
|
||||||
RequireEqualJSON(t, []byte(noBackendsResponse), res) // return no backend available since both failed
|
RequireEqualJSON(t, []byte(noBackendsResponse), res) // return currently not healthy since both failed
|
||||||
require.Equal(t, 1, len(goodBackend.Requests()))
|
require.Equal(t, 1, len(goodBackend.Requests()))
|
||||||
require.Equal(t, 1, len(badBackend.Requests())) // bad backend is still called
|
require.Equal(t, 1, len(badBackend.Requests())) // bad backend is still called
|
||||||
goodBackend.Reset()
|
goodBackend.Reset()
|
||||||
|
Loading…
Reference in New Issue
Block a user