Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test time zone for trades stream #729

Merged
merged 1 commit into from
Feb 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions tests/ExchangeSharpTests/ExchangeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public async Task TradesWebsocketTest()
|| api is ExchangeBL3PAPI // volume too low
|| api is ExchangeLivecoinAPI // defunct
|| api is ExchangeOKCoinAPI // volume appears to be too low
|| api is ExchangeNDAXAPI // volume too low for automated testing
) { continue; }
//if (api is ExchangeKrakenAPI)
try
Expand All @@ -182,18 +183,25 @@ public async Task TradesWebsocketTest()
bool thisExchangePassed = false;
using (var socket = await api.GetTradesWebSocketAsync(async kvp =>
{
thisExchangePassed = true;
delayCTS.Cancel(); // msg received. this exchange passes
if (!kvp.Value.Flags.HasFlag(ExchangeTradeFlags.IsFromSnapshot))
{ // skip over any snapshot ones bc we cannot test time zone on those
if (kvp.Value.Timestamp.Hour == DateTime.UtcNow.Hour)
{
thisExchangePassed = true;
delayCTS.Cancel(); // msg received. this exchange passes
}
else Assert.Fail($"Trades are not in the UTC time zone for exchange {api.GetType().Name}.");
}
}, testSymbol))
{
socket.Disconnected += async s => Assert.Fail($"disconnected by exchange {api.GetType().Name}");
await Task.Delay(100000, delayCTS.Token);
if (!thisExchangePassed) Assert.Fail($"No msgs recieved after 100 seconds for exchange {api.GetType().Name}");
if (!thisExchangePassed) Assert.Fail($"No msgs recieved after 100 seconds for exchange {api.GetType().Name}.");
}
}
catch (NotImplementedException) { } // no need to test exchanges where trades websocket is not implemented
catch (TaskCanceledException) { } // if the delay task is cancelled
catch (Exception ex) { Assert.Fail($"For exchange {api.GetType().Name}, encountered exception {ex}"); }
catch (Exception ex) { Assert.Fail($"For exchange {api.GetType().Name}, encountered exception {ex}."); }
}
}
}
Expand Down