forked from premiere/premiere-libtorrent
merged random_seed assert into trunk
This commit is contained in:
parent
d2fccd8ae7
commit
30d561d0c5
|
@ -30,7 +30,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/random.hpp"
|
#include "libtorrent/random.hpp"
|
||||||
|
#include "libtorrent/assert.hpp"
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
@ -38,17 +40,25 @@ namespace libtorrent
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
boost::uint32_t x = 123456789;
|
boost::uint32_t x = 123456789;
|
||||||
|
#ifdef TORRENT_USE_ASSERTS
|
||||||
|
bool seeded = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void random_seed(boost::uint32_t v)
|
void random_seed(boost::uint32_t v)
|
||||||
{
|
{
|
||||||
x = v;
|
x = v;
|
||||||
|
#ifdef TORRENT_USE_ASSERTS
|
||||||
|
seeded = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is an xorshift random number generator
|
// this is an xorshift random number generator
|
||||||
// see: http://en.wikipedia.org/wiki/Xorshift
|
// see: http://en.wikipedia.org/wiki/Xorshift
|
||||||
boost::uint32_t random()
|
boost::uint32_t random()
|
||||||
{
|
{
|
||||||
|
TORRENT_ASSERT(seeded);
|
||||||
|
|
||||||
static boost::uint32_t y = 362436069;
|
static boost::uint32_t y = 362436069;
|
||||||
static boost::uint32_t z = 521288629;
|
static boost::uint32_t z = 521288629;
|
||||||
static boost::uint32_t w = 88675123;
|
static boost::uint32_t w = 88675123;
|
||||||
|
|
|
@ -434,6 +434,8 @@ bool get_item_cb(dht::item& i)
|
||||||
// TODO: 3 test obfuscated_get_peers
|
// TODO: 3 test obfuscated_get_peers
|
||||||
int test_main()
|
int test_main()
|
||||||
{
|
{
|
||||||
|
random_seed(time_now_hires().time_since_epoch().count());
|
||||||
|
|
||||||
dht_settings sett;
|
dht_settings sett;
|
||||||
sett.max_torrents = 4;
|
sett.max_torrents = 4;
|
||||||
sett.max_dht_items = 4;
|
sett.max_dht_items = 4;
|
||||||
|
|
|
@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/hasher.hpp"
|
#include "libtorrent/hasher.hpp"
|
||||||
#include "libtorrent/pe_crypto.hpp"
|
#include "libtorrent/pe_crypto.hpp"
|
||||||
#include "libtorrent/session.hpp"
|
#include "libtorrent/session.hpp"
|
||||||
|
#include "libtorrent/random.hpp"
|
||||||
|
|
||||||
#include "setup_transfer.hpp"
|
#include "setup_transfer.hpp"
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
|
@ -181,6 +182,8 @@ int test_main()
|
||||||
const int repcount = 128;
|
const int repcount = 128;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
random_seed(time_now_hires().time_since_epoch().count());
|
||||||
|
|
||||||
for (int rep = 0; rep < repcount; ++rep)
|
for (int rep = 0; rep < repcount; ++rep)
|
||||||
{
|
{
|
||||||
dh_key_exchange DH1, DH2;
|
dh_key_exchange DH1, DH2;
|
||||||
|
|
|
@ -34,6 +34,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/torrent_peer.hpp"
|
#include "libtorrent/torrent_peer.hpp"
|
||||||
#include "libtorrent/bitfield.hpp"
|
#include "libtorrent/bitfield.hpp"
|
||||||
#include "libtorrent/performance_counters.hpp"
|
#include "libtorrent/performance_counters.hpp"
|
||||||
|
#include "libtorrent/random.hpp"
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -269,6 +271,9 @@ int test_pick(boost::shared_ptr<piece_picker> const& p, int options = piece_pick
|
||||||
|
|
||||||
int test_main()
|
int test_main()
|
||||||
{
|
{
|
||||||
|
random_seed(time_now_hires().time_since_epoch().count());
|
||||||
|
|
||||||
|
tcp::endpoint endp;
|
||||||
piece_picker::downloading_piece st;
|
piece_picker::downloading_piece st;
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
tmp0.in_use = true;
|
tmp0.in_use = true;
|
||||||
|
|
|
@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/ip_voter.hpp"
|
#include "libtorrent/ip_voter.hpp"
|
||||||
#include "libtorrent/ip_filter.hpp"
|
#include "libtorrent/ip_filter.hpp"
|
||||||
#include "libtorrent/peer_info.hpp"
|
#include "libtorrent/peer_info.hpp"
|
||||||
|
#include "libtorrent/random.hpp"
|
||||||
|
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
#include "setup_transfer.hpp"
|
#include "setup_transfer.hpp"
|
||||||
|
@ -132,6 +133,8 @@ private:
|
||||||
|
|
||||||
int test_main()
|
int test_main()
|
||||||
{
|
{
|
||||||
|
random_seed(time_now_hires().time_since_epoch().count());
|
||||||
|
|
||||||
torrent_peer_allocator allocator;
|
torrent_peer_allocator allocator;
|
||||||
external_ip ext_ip;
|
external_ip ext_ip;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue