Bitcoin Core  27.99.0
P2P Digital Currency
streams_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2022 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <streams.h>
6 #include <test/util/random.h>
8 #include <util/fs.h>
9 #include <util/strencodings.h>
10 
11 #include <boost/test/unit_test.hpp>
12 
13 using namespace std::string_literals;
14 
15 BOOST_FIXTURE_TEST_SUITE(streams_tests, BasicTestingSetup)
16 
18 {
19  fs::path xor_path{m_args.GetDataDirBase() / "test_xor.bin"};
20  auto raw_file{[&](const auto& mode) { return fsbridge::fopen(xor_path, mode); }};
21  const std::vector<uint8_t> test1{1, 2, 3};
22  const std::vector<uint8_t> test2{4, 5};
23  const std::vector<std::byte> xor_pat{std::byte{0xff}, std::byte{0x00}};
24  {
25  // Check errors for missing file
26  AutoFile xor_file{raw_file("rb"), xor_pat};
27  BOOST_CHECK_EXCEPTION(xor_file << std::byte{}, std::ios_base::failure, HasReason{"AutoFile::write: file handle is nullpt"});
28  BOOST_CHECK_EXCEPTION(xor_file >> std::byte{}, std::ios_base::failure, HasReason{"AutoFile::read: file handle is nullpt"});
29  BOOST_CHECK_EXCEPTION(xor_file.ignore(1), std::ios_base::failure, HasReason{"AutoFile::ignore: file handle is nullpt"});
30  }
31  {
32 #ifdef __MINGW64__
33  // Our usage of mingw-w64 and the msvcrt runtime does not support
34  // the x modifier for the _wfopen().
35  const char* mode = "wb";
36 #else
37  const char* mode = "wbx";
38 #endif
39  AutoFile xor_file{raw_file(mode), xor_pat};
40  xor_file << test1 << test2;
41  }
42  {
43  // Read raw from disk
44  AutoFile non_xor_file{raw_file("rb")};
45  std::vector<std::byte> raw(7);
46  non_xor_file >> Span{raw};
47  BOOST_CHECK_EQUAL(HexStr(raw), "fc01fd03fd04fa");
48  // Check that no padding exists
49  BOOST_CHECK_EXCEPTION(non_xor_file.ignore(1), std::ios_base::failure, HasReason{"AutoFile::ignore: end of file"});
50  }
51  {
52  AutoFile xor_file{raw_file("rb"), xor_pat};
53  std::vector<std::byte> read1, read2;
54  xor_file >> read1 >> read2;
56  BOOST_CHECK_EQUAL(HexStr(read2), HexStr(test2));
57  // Check that eof was reached
58  BOOST_CHECK_EXCEPTION(xor_file >> std::byte{}, std::ios_base::failure, HasReason{"AutoFile::read: end of file"});
59  }
60  {
61  AutoFile xor_file{raw_file("rb"), xor_pat};
62  std::vector<std::byte> read2;
63  // Check that ignore works
64  xor_file.ignore(4);
65  xor_file >> read2;
66  BOOST_CHECK_EQUAL(HexStr(read2), HexStr(test2));
67  // Check that ignore and read fail now
68  BOOST_CHECK_EXCEPTION(xor_file.ignore(1), std::ios_base::failure, HasReason{"AutoFile::ignore: end of file"});
69  BOOST_CHECK_EXCEPTION(xor_file >> std::byte{}, std::ios_base::failure, HasReason{"AutoFile::read: end of file"});
70  }
71 }
72 
73 BOOST_AUTO_TEST_CASE(streams_vector_writer)
74 {
75  unsigned char a(1);
76  unsigned char b(2);
77  unsigned char bytes[] = { 3, 4, 5, 6 };
78  std::vector<unsigned char> vch;
79 
80  // Each test runs twice. Serializing a second time at the same starting
81  // point should yield the same results, even if the first test grew the
82  // vector.
83 
84  VectorWriter{vch, 0, a, b};
85  BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}}));
86  VectorWriter{vch, 0, a, b};
87  BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}}));
88  vch.clear();
89 
90  VectorWriter{vch, 2, a, b};
91  BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}}));
92  VectorWriter{vch, 2, a, b};
93  BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}}));
94  vch.clear();
95 
96  vch.resize(5, 0);
97  VectorWriter{vch, 2, a, b};
98  BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}}));
99  VectorWriter{vch, 2, a, b};
100  BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}}));
101  vch.clear();
102 
103  vch.resize(4, 0);
104  VectorWriter{vch, 3, a, b};
105  BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}}));
106  VectorWriter{vch, 3, a, b};
107  BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}}));
108  vch.clear();
109 
110  vch.resize(4, 0);
111  VectorWriter{vch, 4, a, b};
112  BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}}));
113  VectorWriter{vch, 4, a, b};
114  BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}}));
115  vch.clear();
116 
117  VectorWriter{vch, 0, bytes};
118  BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}}));
119  VectorWriter{vch, 0, bytes};
120  BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}}));
121  vch.clear();
122 
123  vch.resize(4, 8);
124  VectorWriter{vch, 2, a, bytes, b};
125  BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}}));
126  VectorWriter{vch, 2, a, bytes, b};
127  BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}}));
128  vch.clear();
129 }
130 
131 BOOST_AUTO_TEST_CASE(streams_vector_reader)
132 {
133  std::vector<unsigned char> vch = {1, 255, 3, 4, 5, 6};
134 
135  SpanReader reader{vch};
136  BOOST_CHECK_EQUAL(reader.size(), 6U);
137  BOOST_CHECK(!reader.empty());
138 
139  // Read a single byte as an unsigned char.
140  unsigned char a;
141  reader >> a;
142  BOOST_CHECK_EQUAL(a, 1);
143  BOOST_CHECK_EQUAL(reader.size(), 5U);
144  BOOST_CHECK(!reader.empty());
145 
146  // Read a single byte as a int8_t.
147  int8_t b;
148  reader >> b;
149  BOOST_CHECK_EQUAL(b, -1);
150  BOOST_CHECK_EQUAL(reader.size(), 4U);
151  BOOST_CHECK(!reader.empty());
152 
153  // Read a 4 bytes as an unsigned int.
154  unsigned int c;
155  reader >> c;
156  BOOST_CHECK_EQUAL(c, 100992003U); // 3,4,5,6 in little-endian base-256
157  BOOST_CHECK_EQUAL(reader.size(), 0U);
158  BOOST_CHECK(reader.empty());
159 
160  // Reading after end of byte vector throws an error.
161  signed int d;
162  BOOST_CHECK_THROW(reader >> d, std::ios_base::failure);
163 
164  // Read a 4 bytes as a signed int from the beginning of the buffer.
165  SpanReader new_reader{vch};
166  new_reader >> d;
167  BOOST_CHECK_EQUAL(d, 67370753); // 1,255,3,4 in little-endian base-256
168  BOOST_CHECK_EQUAL(new_reader.size(), 2U);
169  BOOST_CHECK(!new_reader.empty());
170 
171  // Reading after end of byte vector throws an error even if the reader is
172  // not totally empty.
173  BOOST_CHECK_THROW(new_reader >> d, std::ios_base::failure);
174 }
175 
176 BOOST_AUTO_TEST_CASE(streams_vector_reader_rvalue)
177 {
178  std::vector<uint8_t> data{0x82, 0xa7, 0x31};
179  SpanReader reader{data};
180  uint32_t varint = 0;
181  // Deserialize into r-value
182  reader >> VARINT(varint);
183  BOOST_CHECK_EQUAL(varint, 54321U);
184  BOOST_CHECK(reader.empty());
185 }
186 
187 BOOST_AUTO_TEST_CASE(bitstream_reader_writer)
188 {
189  DataStream data{};
190 
191  BitStreamWriter bit_writer{data};
192  bit_writer.Write(0, 1);
193  bit_writer.Write(2, 2);
194  bit_writer.Write(6, 3);
195  bit_writer.Write(11, 4);
196  bit_writer.Write(1, 5);
197  bit_writer.Write(32, 6);
198  bit_writer.Write(7, 7);
199  bit_writer.Write(30497, 16);
200  bit_writer.Flush();
201 
202  DataStream data_copy{data};
203  uint32_t serialized_int1;
204  data >> serialized_int1;
205  BOOST_CHECK_EQUAL(serialized_int1, uint32_t{0x7700C35A}); // NOTE: Serialized as LE
206  uint16_t serialized_int2;
207  data >> serialized_int2;
208  BOOST_CHECK_EQUAL(serialized_int2, uint16_t{0x1072}); // NOTE: Serialized as LE
209 
210  BitStreamReader bit_reader{data_copy};
211  BOOST_CHECK_EQUAL(bit_reader.Read(1), 0U);
212  BOOST_CHECK_EQUAL(bit_reader.Read(2), 2U);
213  BOOST_CHECK_EQUAL(bit_reader.Read(3), 6U);
214  BOOST_CHECK_EQUAL(bit_reader.Read(4), 11U);
215  BOOST_CHECK_EQUAL(bit_reader.Read(5), 1U);
216  BOOST_CHECK_EQUAL(bit_reader.Read(6), 32U);
217  BOOST_CHECK_EQUAL(bit_reader.Read(7), 7U);
218  BOOST_CHECK_EQUAL(bit_reader.Read(16), 30497U);
219  BOOST_CHECK_THROW(bit_reader.Read(8), std::ios_base::failure);
220 }
221 
222 BOOST_AUTO_TEST_CASE(streams_serializedata_xor)
223 {
224  std::vector<std::byte> in;
225 
226  // Degenerate case
227  {
228  DataStream ds{in};
229  ds.Xor({0x00, 0x00});
230  BOOST_CHECK_EQUAL(""s, ds.str());
231  }
232 
233  in.push_back(std::byte{0x0f});
234  in.push_back(std::byte{0xf0});
235 
236  // Single character key
237  {
238  DataStream ds{in};
239  ds.Xor({0xff});
240  BOOST_CHECK_EQUAL("\xf0\x0f"s, ds.str());
241  }
242 
243  // Multi character key
244 
245  in.clear();
246  in.push_back(std::byte{0xf0});
247  in.push_back(std::byte{0x0f});
248 
249  {
250  DataStream ds{in};
251  ds.Xor({0xff, 0x0f});
252  BOOST_CHECK_EQUAL("\x0f\x00"s, ds.str());
253  }
254 }
255 
256 BOOST_AUTO_TEST_CASE(streams_buffered_file)
257 {
258  fs::path streams_test_filename = m_args.GetDataDirBase() / "streams_test_tmp";
259  AutoFile file{fsbridge::fopen(streams_test_filename, "w+b")};
260 
261  // The value at each offset is the offset.
262  for (uint8_t j = 0; j < 40; ++j) {
263  file << j;
264  }
265  std::rewind(file.Get());
266 
267  // The buffer size (second arg) must be greater than the rewind
268  // amount (third arg).
269  try {
270  BufferedFile bfbad{file, 25, 25};
271  BOOST_CHECK(false);
272  } catch (const std::exception& e) {
273  BOOST_CHECK(strstr(e.what(),
274  "Rewind limit must be less than buffer size") != nullptr);
275  }
276 
277  // The buffer is 25 bytes, allow rewinding 10 bytes.
278  BufferedFile bf{file, 25, 10};
279  BOOST_CHECK(!bf.eof());
280 
281  uint8_t i;
282  bf >> i;
283  BOOST_CHECK_EQUAL(i, 0);
284  bf >> i;
285  BOOST_CHECK_EQUAL(i, 1);
286 
287  // After reading bytes 0 and 1, we're positioned at 2.
288  BOOST_CHECK_EQUAL(bf.GetPos(), 2U);
289 
290  // Rewind to offset 0, ok (within the 10 byte window).
291  BOOST_CHECK(bf.SetPos(0));
292  bf >> i;
293  BOOST_CHECK_EQUAL(i, 0);
294 
295  // We can go forward to where we've been, but beyond may fail.
296  BOOST_CHECK(bf.SetPos(2));
297  bf >> i;
298  BOOST_CHECK_EQUAL(i, 2);
299 
300  // If you know the maximum number of bytes that should be
301  // read to deserialize the variable, you can limit the read
302  // extent. The current file offset is 3, so the following
303  // SetLimit() allows zero bytes to be read.
304  BOOST_CHECK(bf.SetLimit(3));
305  try {
306  bf >> i;
307  BOOST_CHECK(false);
308  } catch (const std::exception& e) {
309  BOOST_CHECK(strstr(e.what(),
310  "Attempt to position past buffer limit") != nullptr);
311  }
312  // The default argument removes the limit completely.
313  BOOST_CHECK(bf.SetLimit());
314  // The read position should still be at 3 (no change).
315  BOOST_CHECK_EQUAL(bf.GetPos(), 3U);
316 
317  // Read from current offset, 3, forward until position 10.
318  for (uint8_t j = 3; j < 10; ++j) {
319  bf >> i;
320  BOOST_CHECK_EQUAL(i, j);
321  }
322  BOOST_CHECK_EQUAL(bf.GetPos(), 10U);
323 
324  // We're guaranteed (just barely) to be able to rewind to zero.
325  BOOST_CHECK(bf.SetPos(0));
326  BOOST_CHECK_EQUAL(bf.GetPos(), 0U);
327  bf >> i;
328  BOOST_CHECK_EQUAL(i, 0);
329 
330  // We can set the position forward again up to the farthest
331  // into the stream we've been, but no farther. (Attempting
332  // to go farther may succeed, but it's not guaranteed.)
333  BOOST_CHECK(bf.SetPos(10));
334  bf >> i;
335  BOOST_CHECK_EQUAL(i, 10);
336  BOOST_CHECK_EQUAL(bf.GetPos(), 11U);
337 
338  // Now it's only guaranteed that we can rewind to offset 1
339  // (current read position, 11, minus rewind amount, 10).
340  BOOST_CHECK(bf.SetPos(1));
341  BOOST_CHECK_EQUAL(bf.GetPos(), 1U);
342  bf >> i;
343  BOOST_CHECK_EQUAL(i, 1);
344 
345  // We can stream into large variables, even larger than
346  // the buffer size.
347  BOOST_CHECK(bf.SetPos(11));
348  {
349  uint8_t a[40 - 11];
350  bf >> a;
351  for (uint8_t j = 0; j < sizeof(a); ++j) {
352  BOOST_CHECK_EQUAL(a[j], 11 + j);
353  }
354  }
355  BOOST_CHECK_EQUAL(bf.GetPos(), 40U);
356 
357  // We've read the entire file, the next read should throw.
358  try {
359  bf >> i;
360  BOOST_CHECK(false);
361  } catch (const std::exception& e) {
362  BOOST_CHECK(strstr(e.what(),
363  "BufferedFile::Fill: end of file") != nullptr);
364  }
365  // Attempting to read beyond the end sets the EOF indicator.
366  BOOST_CHECK(bf.eof());
367 
368  // Still at offset 40, we can go back 10, to 30.
369  BOOST_CHECK_EQUAL(bf.GetPos(), 40U);
370  BOOST_CHECK(bf.SetPos(30));
371  bf >> i;
372  BOOST_CHECK_EQUAL(i, 30);
373  BOOST_CHECK_EQUAL(bf.GetPos(), 31U);
374 
375  // We're too far to rewind to position zero.
376  BOOST_CHECK(!bf.SetPos(0));
377  // But we should now be positioned at least as far back as allowed
378  // by the rewind window (relative to our farthest read position, 40).
379  BOOST_CHECK(bf.GetPos() <= 30U);
380 
381  // We can explicitly close the file, or the destructor will do it.
382  file.fclose();
383 
384  fs::remove(streams_test_filename);
385 }
386 
387 BOOST_AUTO_TEST_CASE(streams_buffered_file_skip)
388 {
389  fs::path streams_test_filename = m_args.GetDataDirBase() / "streams_test_tmp";
390  AutoFile file{fsbridge::fopen(streams_test_filename, "w+b")};
391  // The value at each offset is the byte offset (e.g. byte 1 in the file has the value 0x01).
392  for (uint8_t j = 0; j < 40; ++j) {
393  file << j;
394  }
395  std::rewind(file.Get());
396 
397  // The buffer is 25 bytes, allow rewinding 10 bytes.
398  BufferedFile bf{file, 25, 10};
399 
400  uint8_t i;
401  // This is like bf >> (7-byte-variable), in that it will cause data
402  // to be read from the file into memory, but it's not copied to us.
403  bf.SkipTo(7);
404  BOOST_CHECK_EQUAL(bf.GetPos(), 7U);
405  bf >> i;
406  BOOST_CHECK_EQUAL(i, 7);
407 
408  // The bytes in the buffer up to offset 7 are valid and can be read.
409  BOOST_CHECK(bf.SetPos(0));
410  bf >> i;
411  BOOST_CHECK_EQUAL(i, 0);
412  bf >> i;
413  BOOST_CHECK_EQUAL(i, 1);
414 
415  bf.SkipTo(11);
416  bf >> i;
417  BOOST_CHECK_EQUAL(i, 11);
418 
419  // SkipTo() honors the transfer limit; we can't position beyond the limit.
420  bf.SetLimit(13);
421  try {
422  bf.SkipTo(14);
423  BOOST_CHECK(false);
424  } catch (const std::exception& e) {
425  BOOST_CHECK(strstr(e.what(), "Attempt to position past buffer limit") != nullptr);
426  }
427 
428  // We can position exactly to the transfer limit.
429  bf.SkipTo(13);
430  BOOST_CHECK_EQUAL(bf.GetPos(), 13U);
431 
432  file.fclose();
433  fs::remove(streams_test_filename);
434 }
435 
436 BOOST_AUTO_TEST_CASE(streams_buffered_file_rand)
437 {
438  // Make this test deterministic.
440 
441  fs::path streams_test_filename = m_args.GetDataDirBase() / "streams_test_tmp";
442  for (int rep = 0; rep < 50; ++rep) {
443  AutoFile file{fsbridge::fopen(streams_test_filename, "w+b")};
444  size_t fileSize = InsecureRandRange(256);
445  for (uint8_t i = 0; i < fileSize; ++i) {
446  file << i;
447  }
448  std::rewind(file.Get());
449 
450  size_t bufSize = InsecureRandRange(300) + 1;
451  size_t rewindSize = InsecureRandRange(bufSize);
452  BufferedFile bf{file, bufSize, rewindSize};
453  size_t currentPos = 0;
454  size_t maxPos = 0;
455  for (int step = 0; step < 100; ++step) {
456  if (currentPos >= fileSize)
457  break;
458 
459  // We haven't read to the end of the file yet.
460  BOOST_CHECK(!bf.eof());
461  BOOST_CHECK_EQUAL(bf.GetPos(), currentPos);
462 
463  // Pretend the file consists of a series of objects of varying
464  // sizes; the boundaries of the objects can interact arbitrarily
465  // with the CBufferFile's internal buffer. These first three
466  // cases simulate objects of various sizes (1, 2, 5 bytes).
467  switch (InsecureRandRange(6)) {
468  case 0: {
469  uint8_t a[1];
470  if (currentPos + 1 > fileSize)
471  continue;
472  bf.SetLimit(currentPos + 1);
473  bf >> a;
474  for (uint8_t i = 0; i < 1; ++i) {
475  BOOST_CHECK_EQUAL(a[i], currentPos);
476  currentPos++;
477  }
478  break;
479  }
480  case 1: {
481  uint8_t a[2];
482  if (currentPos + 2 > fileSize)
483  continue;
484  bf.SetLimit(currentPos + 2);
485  bf >> a;
486  for (uint8_t i = 0; i < 2; ++i) {
487  BOOST_CHECK_EQUAL(a[i], currentPos);
488  currentPos++;
489  }
490  break;
491  }
492  case 2: {
493  uint8_t a[5];
494  if (currentPos + 5 > fileSize)
495  continue;
496  bf.SetLimit(currentPos + 5);
497  bf >> a;
498  for (uint8_t i = 0; i < 5; ++i) {
499  BOOST_CHECK_EQUAL(a[i], currentPos);
500  currentPos++;
501  }
502  break;
503  }
504  case 3: {
505  // SkipTo is similar to the "read" cases above, except
506  // we don't receive the data.
507  size_t skip_length{static_cast<size_t>(InsecureRandRange(5))};
508  if (currentPos + skip_length > fileSize) continue;
509  bf.SetLimit(currentPos + skip_length);
510  bf.SkipTo(currentPos + skip_length);
511  currentPos += skip_length;
512  break;
513  }
514  case 4: {
515  // Find a byte value (that is at or ahead of the current position).
516  size_t find = currentPos + InsecureRandRange(8);
517  if (find >= fileSize)
518  find = fileSize - 1;
519  bf.FindByte(std::byte(find));
520  // The value at each offset is the offset.
521  BOOST_CHECK_EQUAL(bf.GetPos(), find);
522  currentPos = find;
523 
524  bf.SetLimit(currentPos + 1);
525  uint8_t i;
526  bf >> i;
527  BOOST_CHECK_EQUAL(i, currentPos);
528  currentPos++;
529  break;
530  }
531  case 5: {
532  size_t requestPos = InsecureRandRange(maxPos + 4);
533  bool okay = bf.SetPos(requestPos);
534  // The new position may differ from the requested position
535  // because we may not be able to rewind beyond the rewind
536  // window, and we may not be able to move forward beyond the
537  // farthest position we've reached so far.
538  currentPos = bf.GetPos();
539  BOOST_CHECK_EQUAL(okay, currentPos == requestPos);
540  // Check that we can position within the rewind window.
541  if (requestPos <= maxPos &&
542  maxPos > rewindSize &&
543  requestPos >= maxPos - rewindSize) {
544  // We requested a position within the rewind window.
545  BOOST_CHECK(okay);
546  }
547  break;
548  }
549  }
550  if (maxPos < currentPos)
551  maxPos = currentPos;
552  }
553  }
554  fs::remove(streams_test_filename);
555 }
556 
557 BOOST_AUTO_TEST_CASE(streams_hashed)
558 {
559  DataStream stream{};
560  HashedSourceWriter hash_writer{stream};
561  const std::string data{"bitcoin"};
562  hash_writer << data;
563 
564  HashVerifier hash_verifier{stream};
565  std::string result;
566  hash_verifier >> result;
567  BOOST_CHECK_EQUAL(data, result);
568  BOOST_CHECK_EQUAL(hash_writer.GetHash(), hash_verifier.GetHash());
569 }
570 
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:389
void ignore(size_t nSize)
Definition: streams.cpp:53
void Write(uint64_t data, int nbits)
Write the nbits least significant bits of a 64-bit int to the output stream.
Definition: streams.h:351
Wrapper around an AutoFile& that implements a ring buffer to deserialize from.
Definition: streams.h:470
void SkipTo(const uint64_t file_pos)
Move the read position ahead in the stream to the given position.
Definition: streams.h:543
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:147
void Xor(const std::vector< unsigned char > &key)
XOR the contents of this stream with a certain key.
Definition: streams.h:276
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
Definition: setup_common.h:246
Reads data from an underlying stream, while hashing the read data.
Definition: hash.h:151
Writes data to an underlying source stream, while hashing the written data.
Definition: hash.h:185
A Span is an object that can refer to a contiguous sequence of objects.
Definition: span.h:98
Minimal stream for reading from an existing byte array by Span.
Definition: streams.h:101
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:33
const std::string test1
BOOST_AUTO_TEST_SUITE_END()
FILE * fopen(const fs::path &p, const char *mode)
Definition: fs.cpp:26
#define BOOST_CHECK_THROW(stmt, excMatch)
Definition: object.cpp:19
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18
#define BOOST_CHECK(expr)
Definition: object.cpp:17
#define VARINT(obj)
Definition: serialize.h:498
BOOST_AUTO_TEST_CASE(xor_file)
Basic testing setup.
Definition: setup_common.h:54
@ ZEROS
Seed with a compile time constant of zeros.
static uint64_t InsecureRandRange(uint64_t range)
Definition: random.h:59
static void SeedInsecureRand(SeedRand seed=SeedRand::SEED)
Definition: random.h:35
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.