Commit Graph

11 Commits

Author SHA1 Message Date
Ben Ramsey 0d7b8c2b7a Update coding style to include PSR-12, among other options
This also includes heavy use of slevomat/coding-standard to apply
various checks to the code, based on maintainer (me) preference.
2020-01-18 12:13:55 -06:00
Ben Ramsey 81f0f9a9b4 Clean-up tests and use PHPStan max level for tests 2020-01-18 12:13:09 -06:00
Ben Ramsey 5d7ee63f1c Update dev requirements and test suite for PHP 7+ only 2020-01-18 12:13:07 -06:00
Ben Ramsey 692175901d Fix RandomNodeProvider behavior on 32-bit systems
The 6 bytes obtained from `random_bytes()` is a 48-bit integer, which
cannot be converted to decimal on a 32-bit system, without being
implicitly cast to a float by PHP. This was causing problems with
setting the multicast bit, and it led to non-random node values.

This new approach splits the 6 bytes up into two 3-byte values, each a
24-bit integer, and applies the multicast bit to the most significant
bits before re-combining the bytes as a string.
2019-11-30 20:26:42 -08:00
Ben Ramsey 657add4b3c Fix mock invocation assertions 2019-11-30 09:10:09 -08:00
Martin Hujer f3e0fed2d7 Drop remnants of HHVM from tests
It was removed from Travis in c479cdd42f
2019-11-30 09:10:09 -08:00
Ben Ramsey 749b30e3f9 Add random node test that asserts multicast bit against random values 2017-09-22 15:46:04 -05:00
Ben Ramsey 5c38d41ccb Use sprintf() to prefix zeros on the returned node hex string 2017-09-22 13:03:41 -05:00
Ben Ramsey 1ec0826a40 Set the multicast bit for random nodes, according to RFC 4122, §4.5
Borrows the idea from cf1c981414 to
properly set the multicast bit to the "least significant bit of the
first octet of the node ID."

When merged, this will close #171 and #170
2017-09-22 12:54:15 -05:00
Ben Ramsey aab08bb08a Use random_bytes() to generate a random node 2017-09-22 12:26:34 -05:00
Andreas Möller 7ff6fff06d Fix: Move tests one up 2016-09-15 08:31:27 +02:00