Merge branch 'master' into marko/int64-

This commit is contained in:
Marko
2021-02-01 16:54:32 +00:00
committed by GitHub
10 changed files with 79 additions and 117 deletions

View File

@@ -118,12 +118,12 @@ func New(remote, wsEndpoint string) (*HTTP, error) {
// NewWithTimeout does the same thing as New, except you can set a Timeout for
// http.Client. A Timeout of zero means no timeout.
func NewWithTimeout(remote, wsEndpoint string, timeout uint) (*HTTP, error) {
func NewWithTimeout(remote, wsEndpoint string, timeout time.Duration) (*HTTP, error) {
httpClient, err := jsonrpcclient.DefaultHTTPClient(remote)
if err != nil {
return nil, err
}
httpClient.Timeout = time.Duration(timeout) * time.Second
httpClient.Timeout = timeout
return NewWithClient(remote, wsEndpoint, httpClient)
}

View File

@@ -40,7 +40,7 @@ func getHTTPClient() *rpchttp.HTTP {
return c
}
func getHTTPClientWithTimeout(timeout uint) *rpchttp.HTTP {
func getHTTPClientWithTimeout(timeout time.Duration) *rpchttp.HTTP {
rpcAddr := rpctest.GetConfig().RPC.ListenAddress
c, err := rpchttp.NewWithTimeout(rpcAddr, "/websocket", timeout)
if err != nil {
@@ -497,8 +497,7 @@ func TestTx(t *testing.T) {
}
func TestTxSearchWithTimeout(t *testing.T) {
// Get a client with a time-out of 10 secs.
timeoutClient := getHTTPClientWithTimeout(10)
timeoutClient := getHTTPClientWithTimeout(10 * time.Second)
_, _, tx := MakeTxKV()
_, err := timeoutClient.BroadcastTxCommit(context.Background(), tx)