Testpublic class Test extends Object
Fields Summary |
---|
protected static long | next_sha1_seed |
Methods Summary |
---|
protected static byte[] | getSHA1()
return( new SHA1Simple().calculateHash( ( "" + ( next_sha1_seed++ )).getBytes()));
| public static void | main(java.lang.String[] args)
randomTest();
| protected static void | randomTest()
DHTRouter router = DHTRouterFactory.create( 20, 5, 5, getSHA1(), null, com.aelitis.azureus.core.dht.impl.Test.getLogger());
router.setAdapter(
new DHTRouterAdapter()
{
public void requestAdd(DHTRouterContact contact) {
// TODO Auto-generated method stub
}
public void requestLookup(byte[] id, String description) {
// TODO Auto-generated method stub
}
public void requestPing(DHTRouterContact contact) {
// TODO Auto-generated method stub
}
});
for (int i=0;i<1000000;i++){
byte[] id = getSHA1();
DHTRouterContact cont = router.contactKnown( id, null);
}
router.print();
| protected static void | simpleTest()
DHTRouter router = DHTRouterFactory.create( 1, 1,1, new byte[]{ 0 }, null, com.aelitis.azureus.core.dht.impl.Test.getLogger());
router.setAdapter(
new DHTRouterAdapter()
{
public void requestAdd(DHTRouterContact contact) {
// TODO Auto-generated method stub
}
public void requestLookup(byte[] id, String description) {
// TODO Auto-generated method stub
}
public void requestPing(DHTRouterContact contact) {
// TODO Auto-generated method stub
}
});
byte[][] node_ids ={
{ toByte( "11111111" ) },
{ toByte( "01111111" ) },
{ toByte( "00101111" ) },
{ toByte( "00100111" ) },
//{ toByte( "00111111" ) },
};
for (int i=0;i<node_ids.length;i++){
router.contactKnown( node_ids[i], null );
}
// byte[] node_id = new byte[]{ 1,1,1,1 }; //new SHA1Hasher().calculateHash( (""+i).getBytes());
router.print();
| protected static byte | toByte(java.lang.String str)
int res = 0;
for (int i=0;i<8;i++){
if ( str.charAt(i) == '1" ){
res += 1<<(7-i);
}
}
return((byte)res);
|
|