Skip to content

Commit 6c41c1c

Browse files
committed
test: fix rest market data tests
1 parent 7133df9 commit 6c41c1c

File tree

7 files changed

+80
-80
lines changed

7 files changed

+80
-80
lines changed

tests/checks.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def good_orderbook_level(level)
2727
level.length == 2
2828
end
2929

30-
module Checks # rubocop:disable Style/Documentation
31-
def good_currency(currency)
30+
module Check # rubocop:disable Style/Documentation
31+
def self.good_currency(currency)
3232
good = good_params(currency, %w[
3333
full_name payin_enabled payout_enabled transfer_enabled
3434
precision_transfer networks
@@ -39,51 +39,51 @@ def good_currency(currency)
3939
true
4040
end
4141

42-
def good_network(network)
42+
def self.good_network(network)
4343
good_params(network,
4444
%w[
4545
network default payin_enabled payout_enabled precision_payout
4646
payout_fee payout_is_payment_id payin_payment_id payin_confirmations
4747
])
4848
end
4949

50-
def good_symbol(symbol)
50+
def self.good_symbol(symbol)
5151
good_params(symbol,
5252
%w[
5353
type base_currency quote_currency status quantity_increment
5454
tick_size take_rate make_rate fee_currency
5555
])
5656
end
5757

58-
def good_ticker(ticker)
58+
def self.good_ticker(ticker)
5959
good_params(ticker, %w[low high volume volume_quote timestamp])
6060
end
6161

62-
def good_price(price)
62+
def self.good_price(price)
6363
good_params(price, %w[currency price timestamp])
6464
end
6565

66-
def good_price_history(price_history)
66+
def self.good_price_history(price_history)
6767
good = good_params(price_history, %w[currency history])
6868
return false unless good
6969

7070
price_history['history'].each { |point| return false unless good_history_point(point) }
7171
true
7272
end
7373

74-
def good_history_point(point)
74+
def self.good_history_point(point)
7575
good_params(point, %w[open close min max timestamp])
7676
end
7777

78-
def good_ticker_price(price)
78+
def self.good_ticker_price(price)
7979
good_params(price, %w[price timestamp])
8080
end
8181

82-
def self.good_public_trade
83-
->(trade) { good_params(trade, %w[id price qty side timestamp]) }
82+
def self.good_public_trade(trade)
83+
good_params(trade, %w[id price qty side timestamp])
8484
end
8585

86-
def good_orderbook(orderbook)
86+
def self.good_orderbook(orderbook)
8787
good_orderbook = good_params(orderbook, %w[timestamp ask bid])
8888
return false unless good_orderbook
8989

@@ -92,21 +92,21 @@ def good_orderbook(orderbook)
9292
true
9393
end
9494

95-
def good_candle(candle)
95+
def self.good_candle(candle)
9696
good_params(candle, %w[timestamp open close min max volume volume_quote])
9797
end
9898

99-
def good_balance(balance)
99+
def self.good_balance(balance)
100100
good_params(balance, %w[currency available reserved])
101101
end
102102

103-
def good_order(order)
103+
def self.good_order(order)
104104
good_params(order,
105105
%w[id client_order_id symbol side status type time_in_force
106106
quantity price quantity_cumulative created_at updated_at])
107107
end
108108

109-
def good_trade
109+
def self.good_trade
110110
lambda { |trade|
111111
good_params(trade, %w[id orderId clientOrderId symbol side quantity
112112
price fee timestamp])
@@ -121,21 +121,21 @@ def self.good_transaction(transaction)
121121
good = good_params(transaction, %w[id status type subtype created_at updated_at])
122122
return false unless good
123123

124-
return false if transaction.key?('native') && !Checks.good_native_transaction(transaction['native'])
124+
return false if transaction.key?('native') && !Check.good_native_transaction(transaction['native'])
125125

126126
true
127127
end
128128

129-
def good_address(address)
129+
def self.good_address(address)
130130
good_params(address, %w[currency address])
131131
end
132132

133-
def good_trading_commission(commission)
133+
def self.good_trading_commission(commission)
134134
good_params(commission, %w[symbol make_rate take_rate])
135135
end
136136
end
137137

138-
module WSChecks # rubocop:disable Style/Documentation
138+
module WSCheck # rubocop:disable Style/Documentation
139139
def self.good_ws_public_trade
140140
->(trade) { good_params(trade, %w[t i p q s]) }
141141
end
@@ -145,7 +145,7 @@ def self.good_ws_public_candle
145145
end
146146

147147
def self.good_ws_mini_ticker
148-
WSChecks.good_ws_public_candle
148+
WSCheck.good_ws_public_candle
149149
end
150150

151151
def self.good_ticker
@@ -187,7 +187,7 @@ def self.good_commission
187187
end
188188

189189
def self.good_transaction
190-
->(transaction) { Checks.good_transaction(transaction) }
190+
->(transaction) { Check.good_transaction(transaction) }
191191
end
192192

193193
def self.print

tests/rest/market_data.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,120 +11,120 @@ def setup
1111

1212
def test_get_currencies
1313
result = @client.get_currencies currencies: nil
14-
result.each_value { |val| assert(good_currency(val)) }
14+
result.each_value { |val| assert(Check.good_currency(val)) }
1515
end
1616

1717
def test_get_2_currencies
1818
result = @client.get_currencies currencies: %w[EOS CRO]
19-
result.each_value { |val| assert(good_currency(val)) }
19+
result.each_value { |val| assert(Check.good_currency(val)) }
2020
end
2121

2222
def test_get_currency
2323
result = @client.get_currency currency: 'USDT'
24-
assert(good_currency(result))
24+
assert(Check.good_currency(result))
2525
end
2626

2727
def test_get_symbols
2828
result = @client.get_symbols
29-
result.each_value { |val| assert(good_symbol(val)) }
29+
result.each_value { |val| assert(Check.good_symbol(val)) }
3030
end
3131

3232
def test_get_2_symbols
3333
result = @client.get_symbols symbols: %w[XLMETH PAXGUSD]
34-
result.each_value { |val| assert(good_symbol(val)) }
34+
result.each_value { |val| assert(Check.good_symbol(val)) }
3535
end
3636

3737
def test_get_symbol
3838
result = @client.get_symbol symbol: 'CROETH'
39-
assert(good_symbol(result))
39+
assert(Check.good_symbol(result))
4040
end
4141

4242
def test_get_tickers
4343
result = @client.get_tickers
4444

4545
result.each_value do |val|
46-
assert(good_ticker(val))
46+
assert(Check.good_ticker(val))
4747
end
4848
end
4949

5050
def test_get_2_tickers
5151
result = @client.get_tickers symbols: %w[XLMETH PAXGUSD]
52-
result.each_value { |val| assert(good_ticker(val)) }
52+
result.each_value { |val| assert(Check.good_ticker(val)) }
5353
end
5454

5555
def test_get_ticker
5656
result = @client.get_ticker symbol: 'XLMETH'
57-
assert(good_ticker(result))
57+
assert(Check.good_ticker(result))
5858
end
5959

6060
def test_get_all_prices
6161
result = @client.get_prices to: 'ETH'
6262
assert(false, 'wrong number of ticker prices') if result.length < 2
63-
result.each_value { |val| assert(good_price(val)) }
63+
result.each_value { |val| assert(Check.good_price(val)) }
6464
end
6565

6666
def test_get_a_price
6767
result = @client.get_prices(to: 'XLM', from: 'ETH')
6868
assert(false, 'wrong number of ticker prices') if result.length != 1
69-
result.each_value { |val| assert(good_price(val)) }
69+
result.each_value { |val| assert(Check.good_price(val)) }
7070
end
7171

7272
def test_get_price_history
7373
result = @client.get_price_history to: 'XLM'
74-
result.each_value { |val| assert(good_price_history(val)) }
74+
result.each_value { |val| assert(Check.good_price_history(val)) }
7575
end
7676

7777
def test_get_ticker_prices
7878
result = @client.get_ticker_prices symbols: %w[PAXGUSDT ETHBTC]
7979
assert(false, 'wrong number of ticker prices') if result.length != 2
80-
result.each_value { |val| assert(good_ticker_price(val)) }
80+
result.each_value { |val| assert(Check.good_ticker_price(val)) }
8181
end
8282

8383
def test_get_ticker_price
8484
result = @client.get_ticker_price symbol: 'PAXGUSDT'
85-
assert(good_ticker_price(result))
85+
assert(Check.good_ticker_price(result))
8686
end
8787

8888
def test_get_trades
8989
result = @client.get_trades(symbols: %w[XLMETH EOSETH], limit: 5)
9090
result.each_value do |trades|
91-
trades.each { |val| assert(good_public_trade(val)) }
91+
trades.each { |val| assert(Check.good_public_trade(val)) }
9292
end
9393
end
9494

9595
def test_get_trades_by_symbol
9696
result = @client.get_trades_by_symbol(symbol: 'USDTDAI', limit: 5, offset: 10)
97-
result.each { |val| assert(good_public_trade(val)) }
97+
result.each { |val| assert(Check.good_public_trade(val)) }
9898
end
9999

100100
def test_get_orderbooks
101101
result = @client.get_orderbooks(symbols: %w[EOSETH XLMETH])
102102
result.each_value do |val|
103-
assert(good_orderbook(val))
103+
assert(Check.good_orderbook(val))
104104
end
105105
end
106106

107107
def test_get_orderbook
108108
result = @client.get_orderbook(symbol: 'EOSETH')
109-
assert(good_orderbook(result))
109+
assert(Check.good_orderbook(result))
110110
end
111111

112112
def test_get_orderbook_volume
113113
result = @client.get_orderbook_volume(symbol: 'EOSETH', volume: '100')
114-
assert(good_orderbook(result))
114+
assert(Check.good_orderbook(result))
115115
end
116116

117117
def test_get_candles
118118
result = @client.get_candles(symbols: ['EOSETH'], limit: 2)
119119
result.each_value do |candles|
120-
candles.each { |val| assert(good_candle(val)) }
120+
candles.each { |val| assert(Check.good_candle(val)) }
121121
end
122122
end
123123

124124
def test_get_candles_by_symbol
125125
result = @client.get_candles_by_symbol(symbol: 'EOSETH', limit: 2)
126126
result.each do |candle|
127-
assert(good_candle(candle))
127+
assert(Check.good_candle(candle))
128128
end
129129
end
130130
end

0 commit comments

Comments
 (0)