aboutsummaryrefslogtreecommitdiff
path: root/src/test/serialize_tests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright headers to 2018DrahtBot2018-07-271-1/+1
|
* scripted-diff: Remove trailing whitespacesJoão Barbosa2018-07-241-2/+2
| | | | | | | | -BEGIN VERIFY SCRIPT- sed --in-place'' --regexp-extended 's/[[:space:]]+$//g' $(git grep -I --files-with-matches --extended-regexp '[[:space:]]+$' -- src test ':!*.svg' ':!src/crypto/sha256_sse4*' ':!src/leveldb' ':!src/qt/locale' ':!src/secp256k1' ':!src/univalue') -END VERIFY SCRIPT-
* tests: Avoid copies of CTransactionMarcoFalke2018-04-111-3/+4
|
* test: Fix sign for expected valuesKarl-Johan Alm2018-04-111-27/+27
| | | | A number of BOOST_CHECK_EQUAL calls would result in warnings about signs.
* Add native support for serializing char arrays without FLATDATAPieter Wuille2018-03-211-6/+10
| | | | | | | | | | | | Support is added to serialize arrays of type char or unsigned char directly, without any wrappers. All invocations of the FLATDATA wrappers that are obsoleted by this are removed. This includes a patch by Russell Yanofsky to make char casting type safe. The serialization of CSubNet is changed to serialize a bool directly rather than though FLATDATA. This makes the serialization independent of the size of the bool type (and will use 1 byte everywhere).
* Add static_assert to prevent VARINT(<signed value>)Russell Yanofsky2018-03-151-13/+13
| | | | | | | | | Using VARINT with signed types is dangerous because negative values will appear to serialize correctly, but then deserialize as positive values mod 128. This commit changes the VARINT macro to trigger an error by default if called with an signed value, and updates broken uses of VARINT to pass a special flag that lets them keep working with no change in behavior.
* Merge READWRITEMANY into READWRITEPieter Wuille2018-03-131-1/+1
|
* Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa2018-01-031-1/+1
|
* scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider2017-11-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
* [trivial] Fix typos in commentspracticalswift2017-01-271-2/+2
|
* Merge #9281: Refactor: Remove using namespace <xxx> from bench/ & test/ sourcesMarcoFalke2017-01-051-3/+2
|\ | | | | | | 73f4119 Refactoring: Removed using namespace <xxx> from bench/ and test/ source files. (Karl-Johan Alm)
| * Refactoring: Removed using namespace <xxx> from bench/ and test/ source files.Karl-Johan Alm2017-01-021-3/+2
| |
* | Increment MIT Licence copyright header year on files modified in 2016isle29832016-12-311-1/+1
|/ | | | | | Edited via: $ contrib/devtools/copyright_header.py update .
* Make CTransaction actually immutablePieter Wuille2016-12-021-3/+3
|
* Get rid of nType and nVersionPieter Wuille2016-11-071-2/+2
| | | | | | | | | | | Remove the nType and nVersion as parameters to all serialization methods and functions. There is only one place where it's read and has an impact (in CAddress), and even there it does not impact any of the recursively invoked serializers. Instead, the few places that need nType or nVersion are changed to read it directly from the stream object, through GetType() and GetVersion() methods which are added to all stream classes.
* serialization: teach serializers variadicsCory Fields2016-11-031-1/+70
| | | | Also add a variadic CDataStream ctor for ease-of-use.
* tests: add varints_bitpatterns testWladimir J. van der Laan2016-04-091-0/+21
| | | | | | | | | The current tests for varint only check that serialization-deserialization is a roundtrip. That is a useful test, but it is also good to check for some exact bit patterns, to prevent a code change that changes the serialization format from going undetected. As the varint functions are templated, also check with different types.
* Bump copyright headers to 2015MarcoFalke2015-12-131-1/+1
|
* tests: add a BasicTestingSetup and apply to all testsWladimir J. van der Laan2015-03-121-1/+2
| | | | | | | | Make sure that chainparams and logging is properly initialized. Doing this for every test may be overkill, but this initialization is so simple that that does not matter. This should fix the travis issues.
* Add serialize float/double testsWladimir J. van der Laan2015-03-061-3/+93
|
* src/serialize.h: base serialization level endianness neutralityWladimir J. van der Laan2015-03-061-0/+24
| | | | Serialization type-safety and endianness compatibility.
* Remove references to X11 licenceMichael Ford2014-12-161-1/+1
|
* boost: split stream classes out of serialize.hCory Fields2014-10-221-0/+1
| | | | serialization now has no dependencies.
* Add licenses for tests and test dataWladimir J. van der Laan2014-03-181-0/+4
| | | | | | | | - Add license headers to source files (years based on commit dates) in `src/test` as well as `qa` - Add `README.md` to `src/test/data` specifying MIT license Fixes #3848
* Improve unit test code not to compare with explanatory messages for each ↵Kangmo2013-12-161-4/+6
| | | | | | | platform. Instead, use have an exception object to check if the string returned by what() on the raised exception matches the string returned by what() on the expected exception instance. This way, we do not need to list all different possible explanatory strings for different platforms in the test code, and make it simple. (The idea is by Cory Fields.)
* Fix unit test error on OSX 10.9 using Apple LLVM v5.0.Kangmo2013-12-151-1/+6
| | | | | | | | | | | | | | | | | | | | | Before the fix, there were 6 errors such as : serialize_tests.cpp:77: error in "noncanonical": incorrect exception std::ios_base::failure is caught It turns out that ex.what() returns following string instead of "non-canonical ReadCompactSize()" "non-canonical ReadCompactSize(): unspecified iostream_category error" After the fix, unit test passed. The test ran using Apple LLVM v5.0 on OSX 10.9 and the unit test error happened because of different error messages by different compilers. g++ --version on my development environment. ``` Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin13.0.0 Thread model: posix ```
* Cleanup code using forward declarations.Brandon Dahler2013-11-101-7/+6
| | | | | | | | | Use misc methods of avoiding unnecesary header includes. Replace int typedefs with int##_t from stdint.h. Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h. Normalize QT_VERSION ifs where possible. Resolve some indirect dependencies as direct ones. Remove extern declarations from .cpp files.
* Bug fix: CDataStream::GetAndClear() when nReadPos > 0Gavin Andresen2013-10-291-0/+48
| | | | | | | | | | | | Changed CDataStream::GetAndClear() to use the most obvious get get and clear instead of a tricky swap(). Added a unit test for CDataStream insert/erase/GetAndClear. Note: GetAndClear() is not performance critical, it is used only by the send-a-message-to-the-network code. Bug was not noticed before now because the send-a-message code never erased from the stream.
* Reject non-canonically-encoded sizesGavin Andresen2013-08-091-0/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The length of vectors, maps, sets, etc are serialized using Write/ReadCompactSize -- which, unfortunately, do not use a unique encoding. So deserializing and then re-serializing a transaction (for example) can give you different bits than you started with. That doesn't cause any problems that we are aware of, but it is exactly the type of subtle mismatch that can lead to exploits. With this pull, reading a non-canonical CompactSize throws an exception, which means nodes will ignore 'tx' or 'block' or other messages that are not properly encoded. Please check my logic... but this change is safe with respect to causing a network split. Old clients that receive non-canonically-encoded transactions or blocks deserialize them into CTransaction/CBlock structures in memory, and then re-serialize them before relaying them to peers. And please check my logic with respect to causing a blockchain split: there are no CompactSize fields in the block header, so the block hash is always canonical. The merkle root in the block header is computed on a vector<CTransaction>, so any non-canonical encoding of the transactions in 'tx' or 'block' messages is erased as they are read into memory by old clients, and does not affect the block hash. And, as noted above, old clients re-serialize (with canonical encoding) 'tx' and 'block' messages before relaying to peers.
* Fix signed/unsigned comparison warningsGavin Andresen2013-04-031-2/+2
|
* Compact serialization for variable-length integersPieter Wuille2012-10-201-0/+45
Variable-length integers: bytes are a MSB base-128 encoding of the number. The high bit in each byte signifies whether another digit follows. To make the encoding is one-to-one, one is subtracted from all but the last digit. Thus, the byte sequence a[] with length len, where all but the last byte has bit 128 set, encodes the number: (a[len-1] & 0x7F) + sum(i=1..len-1, 128^i*((a[len-i-1] & 0x7F)+1)) Properties: * Very small (0-127: 1 byte, 128-16511: 2 bytes, 16512-2113663: 3 bytes) * Every integer has exactly one encoding * Encoding does not depend on size of original integer type