fiatRates: rename "data_timestamp" field to "ts"

pull/345/head
Vladyslav Burzakovskyy 2020-01-06 23:30:48 +01:00 committed by Martin
parent 9cec5424e7
commit db8e0938df
2 changed files with 17 additions and 17 deletions

View File

@ -42,7 +42,7 @@ type CurrencyRatesTicker struct {
// ResultTickerAsString contains formatted CurrencyRatesTicker data
type ResultTickerAsString struct {
Timestamp int64 `json:"rateTs,omitempty"`
Timestamp int64 `json:"ts,omitempty"`
Rates map[string]float64 `json:"rates,omitempty"`
Rate float64 `json:"rate,omitempty"`
Error string `json:"error,omitempty"`
@ -55,7 +55,7 @@ type ResultTickersAsString struct {
// ResultTickerListAsString contains formatted data about available currency tickers
type ResultTickerListAsString struct {
Timestamp int64 `json:"dataTimestamp,omitempty"`
Timestamp int64 `json:"ts,omitempty"`
Tickers []string `json:"available_currencies"`
Error string `json:"error,omitempty"`
}

View File

@ -533,7 +533,7 @@ func httpTestsBitcoinType(t *testing.T, ts *httptest.Server) {
status: http.StatusOK,
contentType: "application/json; charset=utf-8",
body: []string{
`{"rateTs":1574346615,"rate":7914.5}`,
`{"ts":"20191121143015","rates":{"usd":7914.5}}`,
},
},
{
@ -542,7 +542,7 @@ func httpTestsBitcoinType(t *testing.T, ts *httptest.Server) {
status: http.StatusOK,
contentType: "application/json; charset=utf-8",
body: []string{
`{"rateTs":1574344800,"rate":7814.5}`,
`{"ts":"20191121140000","rates":{"usd":7814.5}}`,
},
},
{
@ -569,7 +569,7 @@ func httpTestsBitcoinType(t *testing.T, ts *httptest.Server) {
status: http.StatusOK,
contentType: "application/json; charset=utf-8",
body: []string{
`{"rateTs":1574344800,"rate":7100}`,
`{"ts":"20191121140000","rates":{"eur":7100.0,"usd":7814.5}}`,
},
},
{
@ -578,7 +578,7 @@ func httpTestsBitcoinType(t *testing.T, ts *httptest.Server) {
status: http.StatusOK,
contentType: "application/json; charset=utf-8",
body: []string{
`{"rateTs":1521511200,"rate":2000}`,
`{"ts":"20191121140000","rates":{"usd":7814.5}}`,
},
},
{
@ -587,7 +587,7 @@ func httpTestsBitcoinType(t *testing.T, ts *httptest.Server) {
status: http.StatusOK,
contentType: "application/json; charset=utf-8",
body: []string{
`{"rateTs":1521611721,"rate":2003}`,
`{"ts":"20180321055521","rates":{"usd":2003.0}}`,
},
},
{
@ -596,7 +596,7 @@ func httpTestsBitcoinType(t *testing.T, ts *httptest.Server) {
status: http.StatusOK,
contentType: "application/json; charset=utf-8",
body: []string{
`{"rateTs":1574346615,"rate":7134.1}`,
`{"ts":"20191121140000","rates":{"eur":7100.0,"usd":7814.5}}`,
},
},
{
@ -614,7 +614,7 @@ func httpTestsBitcoinType(t *testing.T, ts *httptest.Server) {
status: http.StatusOK,
contentType: "application/json; charset=utf-8",
body: []string{
`{"dataTimestamp":1574346615,"available_currencies":["eur","usd"]}`,
`{"ts":"20191121140000","available_currencies":["eur","usd"]}`,
},
},
{
@ -1212,7 +1212,7 @@ func websocketTestsBitcoinType(t *testing.T, ts *httptest.Server) {
"currency": "usd",
},
},
want: `{"id":"18","data":{"rateTs":1574346615,"rate":7914.5}}`,
want: `{"id":"18","data":{"ts":"20191121143015","rates":{"usd":7914.5}}}`,
},
{
name: "websocket getCurrentFiatRates eur",
@ -1222,7 +1222,7 @@ func websocketTestsBitcoinType(t *testing.T, ts *httptest.Server) {
"currency": "eur",
},
},
want: `{"id":"19","data":{"rateTs":1574346615,"rate":7134.1}}`,
want: `{"id":"19","data":{"ts":"20191121143015","rates":{"eur":7134.1,"usd":7914.5}}}`,
},
{
name: "websocket getCurrentFiatRates incorrect currency",
@ -1275,7 +1275,7 @@ func websocketTestsBitcoinType(t *testing.T, ts *httptest.Server) {
"timestamps": []int64{1574346615},
},
},
want: `{"id":"24","data":{"tickers":[{"rateTs":1574346615,"rate":7914.5}]}}`,
want: `{"id":"24","data":{"tickers":[{"ts":"20191121140000","rates":{"usd":7814.5}}]}}`,
},
{
name: "websocket getFiatRatesForTimestamps closest date, eur",
@ -1286,7 +1286,7 @@ func websocketTestsBitcoinType(t *testing.T, ts *httptest.Server) {
"timestamps": []int64{1521507600},
},
},
want: `{"id":"25","data":{"tickers":[{"rateTs":1521511200,"rate":1300}]}}`,
want: `{"id":"25","data":{"tickers":[{"ts":"20191121140000","rates":{"eur":7100.0,"usd":7814.5}}]}}`,
},
{
name: "websocket getFiatRatesForTimestamps multiple timestamps usd",
@ -1297,7 +1297,7 @@ func websocketTestsBitcoinType(t *testing.T, ts *httptest.Server) {
"timestamps": []int64{1570346615, 1574346615},
},
},
want: `{"id":"26","data":{"tickers":[{"rateTs":1574344800,"rate":7814.5},{"rateTs":1574346615,"rate":7914.5}]}}`,
want: `{"id":"26","data":{"tickers":[{"ts":"20191121140000","rates":{"usd":7814.5}},{"ts":"20191121143015","rates":{"usd":7914.5}}]}}`,
},
{
name: "websocket getFiatRatesForTimestamps multiple timestamps eur",
@ -1308,7 +1308,7 @@ func websocketTestsBitcoinType(t *testing.T, ts *httptest.Server) {
"timestamps": []int64{1570346615, 1574346615},
},
},
want: `{"id":"27","data":{"tickers":[{"rateTs":1574344800,"rate":7100},{"rateTs":1574346615,"rate":7134.1}]}}`,
want: `{"id":"27","data":{"tickers":[{"ts":"20191121140000","rates":{"eur":7100.0,"usd":7814.5}},{"ts":"20191121143015","rates":{"eur":7134.1,"usd":7914.5}}]}}`,
},
{
name: "websocket getFiatRatesForTimestamps multiple timestamps with an error",
@ -1319,7 +1319,7 @@ func websocketTestsBitcoinType(t *testing.T, ts *httptest.Server) {
"timestamps": []int64{1570346615, 1574346615, 2000000000},
},
},
want: `{"id":"28","data":{"tickers":[{"rateTs":1574344800,"rate":7814.5},{"rateTs":1574346615,"rate":7914.5},{"rateTs":2000000000,"rate":-1}]}}`,
want: `{"id":"28","data":{"tickers":[{"ts":"20191121140000","rates":{"usd":7814.5}},{"ts":"20191121143015","rates":{"usd":7914.5}},{"error":"Date \"not-a-real-date\" does not match any of available formats. Possible formats are: YYYYMMDDhhmmss, YYYYMMDDhhmm, YYYYMMDDhh, YYYYMMDD"}]}}`,
},
{
name: "websocket getFiatRatesForTimestamps multiple errors",
@ -1340,7 +1340,7 @@ func websocketTestsBitcoinType(t *testing.T, ts *httptest.Server) {
"timestamp": 1570346615,
},
},
want: `{"id":"30","data":{"dataTimestamp":1570346615,"available_currencies":["eur","usd"]}}`,
want: `{"id":"30","data":{"ts":"20191121140000","available_currencies":["eur","usd"]}}`,
},
{
name: "websocket getBalanceHistory Addr2",