Fix accounts_test
@@ -176,7 +176,7 @@ func TestWithValidAuthTokenConcurrent(t *testing.T) {
wg.Add(1)
go func(w int, wg *sync.WaitGroup) {
var response jsonrpc.RPCResponse
- q := jsonrpc.NewRequest("account_balance")
+ q := jsonrpc.NewRequest("account_list")
qBody, _ := json.Marshal(q)
r, _ := http.NewRequest("POST", proxySuffix, bytes.NewBuffer(qBody))
@@ -233,31 +233,52 @@ func TestWithoutToken(t *testing.T) {
testFuncSetup()
defer testFuncTeardown()
- // Create a dummy account so we have a wallet beside the default one
- lbrynet.CreateAccount(999)
- defer lbrynet.RemoveAccount(999)
-
var (
q *jsonrpc.RPCRequest
qBody []byte
response jsonrpc.RPCResponse
- account ljsonrpc.Account
+ statusResponse ljsonrpc.StatusResponse
)
- q = jsonrpc.NewRequest("account_list")
+ q = jsonrpc.NewRequest("status")
qBody, _ = json.Marshal(q)
r, _ := http.NewRequest("POST", proxySuffix, bytes.NewBuffer(qBody))
rr := httptest.NewRecorder()
handler := NewRequestHandler(svc)
handler.Handle(rr, r)
-
require.Equal(t, http.StatusOK, rr.Code)
- err := json.Unmarshal(rr.Body.Bytes(), &response)
+ err := json.Unmarshal(rr.Body.Bytes(), &response)
require.Nil(t, err)
require.Nil(t, response.Error)
- err = ljsonrpc.Decode(response.Result, &account)
+
+ err = ljsonrpc.Decode(response.Result, &statusResponse)
+ require.Nil(t, err)
+ assert.True(t, statusResponse.IsRunning)
+}
+
+func TestAccountSpecificWithoutToken(t *testing.T) {
+ testFuncSetup()
+ defer testFuncTeardown()
+
+ var (
+ q *jsonrpc.RPCRequest
+ qBody []byte
+ response jsonrpc.RPCResponse
+ )
+
+ q = jsonrpc.NewRequest("account_list")
+ qBody, _ = json.Marshal(q)
+ r, _ := http.NewRequest("POST", proxySuffix, bytes.NewBuffer(qBody))
+
+ rr := httptest.NewRecorder()
+ handler := NewRequestHandler(svc)
+ handler.Handle(rr, r)
+ require.Equal(t, http.StatusOK, rr.Code)
+
+ err := json.Unmarshal(rr.Body.Bytes(), &response)
require.Nil(t, err)
- assert.True(t, account.IsDefault, account)
+ require.NotNil(t, response.Error)
+ require.Equal(t, "account identificator required", response.Error.Message)
}
