public function testRandomBase58()
{
$this->specify("base58 does not generate a valid string", function () {
$lens = [2, 12, 16, 24, 48, 100];
$random = new Random();
$isValid = function ($base58) {
$alphabet = array_merge(range("A", "H"), range("J", "N"), range("P", "Z"), range("a", "k"), range("m", "z"), range("1", "9"));
return preg_match('#^[^' . join('', $alphabet) . ']+$#i', $base58) === 0;
};
foreach ($lens as $len) {
$actual = $random->base58($len);
expect(strlen($actual))->equals($len);
expect($isValid($actual))->true();
}
$actual = $random->base58();
expect(strlen($actual))->equals(16);
expect($isValid($actual))->true();
});
}