Fix up relay unit tests. Detected an unintentional bug benign behavior change.
This commit is contained in:
1 parent
4adaddbdb7
commit
5f01bf5ea8
2 files changed
+25
-26
No files matched your search
Vendored
+1
-1
@@ -106,7 +106,7 @@
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/ninja_debug/src/server/sparkd/sparkd",
|
||||
"args": ["test", "-a", "Co2Tests"],
|
||||
"args": ["test", "-a", "Co2RelayTests"],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/ninja_debug/src/server/sparkd/",
|
||||
"environment": [],
|
||||
|
||||
@@ -32,6 +32,8 @@ using namespace std;
|
||||
namespace bts {
|
||||
int md_tests = 0;
|
||||
namespace md {
|
||||
// import this from RelayClient.cpp
|
||||
PriceSize book_at(const google::protobuf::RepeatedPtrField<co2::PriceSizeMessage>& side, int index);
|
||||
namespace test {
|
||||
|
||||
using namespace api;
|
||||
@@ -1200,14 +1202,14 @@ TEST_CASE ("Co2IndexTests","[md]") {
|
||||
|
||||
struct Co2RelayTests {
|
||||
void setup() {
|
||||
config::internal::initialize_for_test(
|
||||
"PlatformMap {"
|
||||
" value {"
|
||||
" sim {"
|
||||
" exchange: TESTEXCHANGE"
|
||||
" }"
|
||||
" }"
|
||||
"}");
|
||||
// config::internal::initialize_for_test(
|
||||
// "PlatformMap {"
|
||||
// " value {"
|
||||
// " sim {"
|
||||
// " exchange: TESTEXCHANGE"
|
||||
// " }"
|
||||
// " }"
|
||||
// "}");
|
||||
}
|
||||
void teardown() {}
|
||||
|
||||
@@ -1231,9 +1233,9 @@ struct Co2RelayTests {
|
||||
return temp;
|
||||
}
|
||||
|
||||
PriceSize convert(const co2::PriceSizeMessage& psm) {
|
||||
return PriceSize(psm.mantissa(), psm.exponent(), psm.size());
|
||||
}
|
||||
// PriceSize convert(const co2::PriceSizeMessage& psm) {
|
||||
// return PriceSize(psm.mantissa(), psm.exponent(), psm.size());
|
||||
// }
|
||||
|
||||
void relay_nans() {
|
||||
MDProducer producer(TEST_PLATFORM);
|
||||
@@ -1284,8 +1286,8 @@ struct Co2RelayTests {
|
||||
REQUIRE(update.has_book());
|
||||
REQUIRE(update.book().asks_size() > 0);
|
||||
REQUIRE(update.book().bids_size() > 0);
|
||||
REQUIRE(convert(update.book().bids(0)) == price35);
|
||||
REQUIRE(convert(update.book().asks(0)) == price35);
|
||||
REQUIRE(book_at(update.book().bids(), 0) == price35);
|
||||
REQUIRE(book_at(update.book().asks(), 0) == price35);
|
||||
}
|
||||
|
||||
// Second request with updated time should include nothing
|
||||
@@ -1305,8 +1307,8 @@ struct Co2RelayTests {
|
||||
REQUIRE(reply.channels().size() == 1);
|
||||
REQUIRE(reply.channels(0).updates().size() == 1);
|
||||
REQUIRE(reply.channels(0).updates(0).has_book());
|
||||
REQUIRE(convert(reply.channels(0).updates(0).book().bids(0)) == price5);
|
||||
REQUIRE(convert(reply.channels(0).updates(0).book().asks(0)) == price5);
|
||||
REQUIRE(book_at(reply.channels(0).updates(0).book().bids(), 0) == price5);
|
||||
REQUIRE(book_at(reply.channels(0).updates(0).book().asks(), 0) == price5);
|
||||
|
||||
// NaN out all the prices - expect to get a full set of updates
|
||||
for(auto p : producers) {
|
||||
@@ -1320,10 +1322,9 @@ struct Co2RelayTests {
|
||||
REQUIRE((size_t)reply.channels(0).updates().size() == producers.size());
|
||||
for (auto& update : reply.channels(0).updates()) {
|
||||
REQUIRE(update.has_book());
|
||||
REQUIRE(update.book().bids_size() > 0);
|
||||
REQUIRE(update.book().asks_size() > 0);
|
||||
REQUIRE(convert(update.book().bids(0)) == PriceSize::NO_MARKET);
|
||||
REQUIRE(convert(update.book().asks(0)) == PriceSize::NO_MARKET);
|
||||
// We need to have a book to signal that it was updated but it can have no rows. This signifies an empty book and will be written as such by the relay client.
|
||||
REQUIRE(book_at(update.book().bids(), 0) == PriceSize::NO_MARKET);
|
||||
REQUIRE(book_at(update.book().asks(), 0) == PriceSize::NO_MARKET);
|
||||
}
|
||||
|
||||
// Fill up the markets again
|
||||
@@ -1340,8 +1341,8 @@ struct Co2RelayTests {
|
||||
REQUIRE(update.has_book());
|
||||
REQUIRE(update.book().bids_size() > 0);
|
||||
REQUIRE(update.book().asks_size() > 0);
|
||||
REQUIRE(convert(update.book().bids(0)) == price35);
|
||||
REQUIRE(convert(update.book().asks(0)) == price35);
|
||||
REQUIRE(book_at(update.book().bids(), 0) == price35);
|
||||
REQUIRE(book_at(update.book().asks(), 0) == price35);
|
||||
}
|
||||
|
||||
// NaN out the bids
|
||||
@@ -1356,10 +1357,8 @@ struct Co2RelayTests {
|
||||
REQUIRE((size_t)reply.channels(0).updates().size() == producers.size());
|
||||
for (auto& update : reply.channels(0).updates()) {
|
||||
REQUIRE(update.has_book());
|
||||
REQUIRE(update.book().bids_size() > 0);
|
||||
REQUIRE(update.book().asks_size() > 0);
|
||||
REQUIRE(convert(update.book().bids(0)) == PriceSize::NO_MARKET);
|
||||
REQUIRE(convert(update.book().asks(0)) == price35);
|
||||
REQUIRE(book_at(update.book().bids(), 0) == PriceSize::NO_MARKET);
|
||||
REQUIRE(book_at(update.book().asks(), 0) == price35);
|
||||
}
|
||||
}
|
||||
} ;
|
||||
|
||||
Reference in new issue
Block a user