public function testDistance() { $data_a = ['id' => str_repeat('FF', N / 8)]; $node_a = KademliaTestFactory::constructNode($data_a); $zeros = Kademlia\Node::hexId2bin(str_repeat('00', N / 8)); $this->assertEqual($node_a->distanceTo($node_a), $zeros); $data_b = ['id' => str_repeat('FF', N / 8)]; $data_b['id'][2 * N / 8 - 1] = 'E'; $node_b = KademliaTestFactory::constructNode($data_b); $one = Kademlia\Node::hexid2bin(str_repeat('0', 2 * N / 8 - 1) . '1'); $this->assertEqual($node_a->distanceTo($node_b), $one); }