Commit Graph

28 Commits

Author SHA1 Message Date
tomFlowee c7192dff41 Add text-limit argument to writeHex
The BufferPool::writeHex() method takes a string-pointer, we add an int
max-number-of-chars to be parsed on that string.
This allows us to not just stop at the first non-hex char, but also
after a set number of characters.

This effectively allows us to use non-zere-terminated strings as
argument too.
2024-10-03 14:07:10 +02:00
tomFlowee 6a84a262cc Add more ConstBuffer helper methods
This adds endsWith() and an extra startsWith() overload.

We also added tests for the case when either the argument or the object
are empty and specify the behavior. I copied the behavior of QString.

See unit tests that specify the behavior with empties.
2024-06-11 17:57:17 +02:00
tomFlowee bc47a700a4 Refactor; wrap BufferPool in shared_ptr
As we moved most of the creation of a BufferPool to be via the
Streaming::pool() method, which uses a thread-local, it makes sense
to start cleaning up the design and make it more modern C++.
The above mentioned method would return a reference and you'd see
loads of places use `auto &pool =` which is less than ideal.

As the number of places where we actually instantiate a BufferPool
goes down, the usage of some sort of smart pointer makes more sense.

This now makes all APIs use BufferPool be wrapped in a shared_ptr.
2023-12-21 15:23:23 +01:00
tomFlowee 1e3a4aeee3 Add out of bounds check for MessageParser 2023-07-09 17:09:07 +02:00
tomFlowee b5b493542b Rework base58 and tests
The unit tests testing base58 encoding were using univalue JSON
parsing, since we deprecatd univalue to be a hub-private lib
this has now been ported to Qts JSON parser.
Which also makes the clunky cmake hack nice to replace with the
QRC files concept.

As I was in there anyway, the base58 methods being global scope
C-style methods has now been fixed by putting them in a namespace.
2022-12-13 11:34:54 +01:00
tomFlowee 7b29af9c19 Port base58_tests from boost to QTestLib 2022-12-13 11:34:54 +01:00
tomFlowee e9563bdad0 Move univalue tests to belong to the hub tests.
As this is not actually used outside of the Hub, it really makes
more sense to make this testing part of the hub testing.
Also makes it easier to compile.
2022-12-13 11:34:54 +01:00
tomFlowee 0663515da0 Fix naming of tests 2022-04-06 11:46:40 +02:00
tomFlowee 26262783de Allow mid(1, 0) to be called
This now creates a zero size, empty, result.
2022-02-10 18:02:50 +01:00
tomFlowee 41e00b134f Add convenience methods on ConstBuffer
this adds indexOf() and toString()
2022-01-25 23:59:54 +01:00
tomFlowee ae78dd0bb8 Update email address 2021-06-20 22:44:44 +02:00
tomFlowee 7406cd6ecf Remove dead code (xor of stream). 2021-03-16 19:34:33 +01:00
tomFlowee 407dd2f2ab Simplify messageparser.
Remove some unused methods and complexity.
2021-01-06 19:37:27 +01:00
TomZ a966ffb129 Remove the hardcoded max message size.
We already had in place the blockSizeAcceptLimit as the limit
on messages, which is now the only limit.

In practice this means when the operator sets the maximum mining
size that we adjust the blockSizeAcceptLimit, if they only set the
blockSizeAcceptLimit, we use that (plus a margin) to limit messages
both on the p2p layer and on the RPC (JSON) layer we change the
limit to be twice the blockSizeAcceptLimit (copied those numbers
from BCHN).
2020-11-10 18:33:07 +01:00
TomZ 7e648699e7 Port some more test to qtestlib 2020-07-05 18:59:09 +02:00
TomZ 190394f0d7 Move bswap test to use qtestlib 2020-07-05 14:03:27 +02:00
TomZ f716847705 Move univalue tests to qtestlib 2020-07-05 12:50:50 +02:00
TomZ 34db927e0a Move unit test to qtestlib 2020-07-05 12:34:11 +02:00
TomZ 72f1f3733c make clang happy; implicit coversion 2020-05-27 12:14:27 +02:00
TomZ 09b4e5050e Make link under strictness rules
This re-adds the flowee_utils lib which was implied and should have
been auto-added by cmake, but it failed to link for AUR strictness
settings.
2020-03-19 16:08:56 +01:00
TomZ f7f4ea0093 make testing/streaming not link to flowee_server
Also split the testlib into two static libraries and avoid
recompile of the base test file in each test that used it.
2019-12-30 17:55:48 +01:00
TomZ 3315aec93f Add ConstBuffer::operator==() 2019-12-30 17:37:23 +01:00
TomZ 0b152570ee Add ConstBuffer::startsWith()
and include unit test.
2019-08-26 20:48:12 +02:00
TomZ e7a7ada953 Cleanup dependencies a bit more.
This means that for apps like 'pos' no longer link against libSSL

The streams no longer zero-after-free, there are no secrets transported
in datastreams so this is useless and avoids linking in one OpenSSL
call.

The insecure_rand() method depended on the openssl code to seed it with
randomness. Now replaced with a proven current-time-milliseconds.
This is enough in those cases because it was always meant to be an
insecure random.
2019-08-24 22:25:10 +02:00
TomZ 4a877fcbfa Add unit test for MessageBuilder::reply() 2019-06-26 22:50:20 +02:00
TomZ 557c2000f2 Move CKey to live in utils as well 2019-03-13 22:43:25 +01:00
TomZ cfe690320d Move various standalone simple classes into utils
The 'server' library has always been a catch-all and
ideally only the hub links it in (far future goal).
In line with this I move a list of files out of server
into the utils lib.
I choose 'utils' because all these are plain old data
objects that many crypto apps will find useful.

now in utils/primitives/
* CScript
* CPubKey
* CTransaction
* CBlock
* FastTransaction
* FastBlock
* CScript

streams.h is now in utils/streaming/
hash.h is now in utils/
2019-03-11 15:40:42 +01:00
TomZ 18d032a556 Transfer more to QTestLib
As boost testlib is extremely IDE unfriendly, as well as human
unfriendly with lots of macros for basic C++ functions (like methods!!)
this is better for me.

But the real reason is that its just unstable. I get double deletes
on some releases of boost and I'm missing plain features that all
other test frameworks have.
For instance a QCOMPARE shows what is expected vs what we got. Boost
just fails.
In QTestLib I can mark a test as "expect fail" an idea that boost
tried and failed (can easily create false positives).
2018-12-28 16:21:49 +01:00