From 0c06145d673fb9f37cc947a311a1096ba95b3352 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Thu, 16 Mar 2023 16:11:31 +0000 Subject: [PATCH] client: Use types 2.0.0 --- client/client.go | 2 +- client/client_test.go | 17 ++++++++++++----- client/go.mod | 4 ++-- client/go.sum | 4 ++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/client/client.go b/client/client.go index 6e19217..e621c0a 100644 --- a/client/client.go +++ b/client/client.go @@ -14,7 +14,7 @@ import ( "github.com/decred/dcrd/txscript/v4/stdaddr" "github.com/decred/slog" - "github.com/decred/vspd/types" + "github.com/decred/vspd/types/v2" ) type Client struct { diff --git a/client/client_test.go b/client/client_test.go index f7c7d27..5fca36a 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -10,7 +10,7 @@ import ( "testing" "github.com/decred/slog" - "github.com/decred/vspd/types" + "github.com/decred/vspd/types/v2" ) // TestErrorDetails ensures errors returned by client.do contain adequate @@ -22,21 +22,28 @@ func TestErrorDetails(t *testing.T) { respBodyBytes []byte expectedErr string vspdError bool - vspdErrCode int64 + vspdErrCode types.ErrorCode }{ "500, vspd error (generic bad request)": { respHTTPStatus: 500, - respBodyBytes: []byte(`{"code": 1, "message": "bad request"}`), + respBodyBytes: []byte(`{"code": 0, "message": "bad request"}`), expectedErr: `bad request`, vspdError: true, - vspdErrCode: 1, + vspdErrCode: types.ErrBadRequest, + }, + "500, vspd error (generic internal error)": { + respHTTPStatus: 500, + respBodyBytes: []byte(`{"code": 1, "message": "something terrible happened"}`), + expectedErr: `something terrible happened`, + vspdError: true, + vspdErrCode: types.ErrInternalError, }, "428, vspd error (cannot broadcast fee)": { respHTTPStatus: 428, respBodyBytes: []byte(`{"code": 16, "message": "fee transaction could not be broadcast due to unknown outputs"}`), expectedErr: `fee transaction could not be broadcast due to unknown outputs`, vspdError: true, - vspdErrCode: 16, + vspdErrCode: types.ErrCannotBroadcastFeeUnknownOutputs, }, "500, no body": { respHTTPStatus: 500, diff --git a/client/go.mod b/client/go.mod index 8c9029a..fa30d7a 100644 --- a/client/go.mod +++ b/client/go.mod @@ -1,11 +1,11 @@ -module github.com/decred/vspd/client +module github.com/decred/vspd/client/v2 go 1.19 require ( github.com/decred/dcrd/txscript/v4 v4.0.0 github.com/decred/slog v1.2.0 - github.com/decred/vspd/types v1.1.0 + github.com/decred/vspd/types/v2 v2.0.0 ) require ( diff --git a/client/go.sum b/client/go.sum index e50a88d..751015f 100644 --- a/client/go.sum +++ b/client/go.sum @@ -27,5 +27,5 @@ github.com/decred/dcrd/wire v1.5.0 h1:3SgcEzSjqAMQvOugP0a8iX7yQSpiVT1yNi9bc4iOXV github.com/decred/dcrd/wire v1.5.0/go.mod h1:fzAjVqw32LkbAZIt5mnrvBR751GTa3e0rRQdOIhPY3w= github.com/decred/slog v1.2.0 h1:soHAxV52B54Di3WtKLfPum9OFfWqwtf/ygf9njdfnPM= github.com/decred/slog v1.2.0/go.mod h1:kVXlGnt6DHy2fV5OjSeuvCJ0OmlmTF6LFpEPMu/fOY0= -github.com/decred/vspd/types v1.1.0 h1:hTeqQwgRUN2FGIbuCIdyzBejKV+jxKrmEIcLKxpsB1g= -github.com/decred/vspd/types v1.1.0/go.mod h1:THsO8aBSwWBq6ZsIG25cNqbkNb+EEASXzLhFvODVc0s= +github.com/decred/vspd/types/v2 v2.0.0 h1:FaPA+W4OOMRWK+Vk4fyyYdXoVLRMMRQsxzsnSjJjOnI= +github.com/decred/vspd/types/v2 v2.0.0/go.mod h1:2xnNqedkt9GuL+pK8uIzDxqYxFlwLRflYFJH64b76n0=