@@ -162,6 +162,66 @@ TEST_F(LiveBlockingTests, TestSubscriptionChunkingStringStart) {
162162 target.Subscribe (kSymbols , kSchema , kSType , kStart );
163163}
164164
165+ TEST_F (LiveBlockingTests, TestSubscribeSnapshot) {
166+ constexpr auto kTsOut = false ;
167+ constexpr auto kDataset = dataset::kXnasItch ;
168+ const auto kSymbol = " TEST" ;
169+ const std::size_t kSymbolCount = 1000 ;
170+ const auto kSchema = Schema::Ohlcv1M;
171+ const auto kSType = SType::RawSymbol;
172+ const auto use_snapshot = true ;
173+
174+ const mock::MockLsgServer mock_server{
175+ kDataset , kTsOut ,
176+ [kSymbol , kSymbolCount , kSchema , kSType ](mock::MockLsgServer& self) {
177+ self.Accept ();
178+ self.Authenticate ();
179+ std::size_t i{};
180+ while (i < 1000 ) {
181+ const auto chunk_size =
182+ std::min (static_cast <std::size_t >(128 ), kSymbolCount - i);
183+ const std::vector<std::string> symbols_chunk (chunk_size, kSymbol );
184+ self.Subscribe (symbols_chunk, kSchema , kSType , use_snapshot);
185+ i += chunk_size;
186+ }
187+ }};
188+
189+ LiveBlocking target{logger_.get (),
190+ kKey ,
191+ kDataset ,
192+ kLocalhost ,
193+ mock_server.Port (),
194+ kTsOut ,
195+ VersionUpgradePolicy{}};
196+ const std::vector<std::string> kSymbols (kSymbolCount , kSymbol );
197+ target.Subscribe (kSymbols , kSchema , kSType , use_snapshot);
198+ }
199+
200+ TEST_F (LiveBlockingTests, TestInvalidSubscription) {
201+ constexpr auto kTsOut = false ;
202+ constexpr auto kDataset = dataset::kXnasItch ;
203+ const std::vector<std::string> noSymbols{};
204+ const auto kSchema = Schema::Ohlcv1M;
205+ const auto kSType = SType::RawSymbol;
206+
207+ const mock::MockLsgServer mock_server{kDataset , kTsOut ,
208+ [](mock::MockLsgServer& self) {
209+ self.Accept ();
210+ self.Authenticate ();
211+ }};
212+
213+ LiveBlocking target{logger_.get (),
214+ kKey ,
215+ kDataset ,
216+ kLocalhost ,
217+ mock_server.Port (),
218+ kTsOut ,
219+ VersionUpgradePolicy{}};
220+
221+ ASSERT_THROW (target.Subscribe (noSymbols, kSchema , kSType ),
222+ databento::InvalidArgumentError);
223+ }
224+
165225TEST_F (LiveBlockingTests, TestNextRecord) {
166226 constexpr auto kTsOut = false ;
167227 const auto kRecCount = 12 ;
0 commit comments