public function testBase58CheckEncodeP2SH()
 {
     $cnt = (getenv('BITCOINLIB_EXTENSIVE_TESTING') ?: 1) * 50;
     for ($i = 0; $i < $cnt; $i++) {
         // random, 20-byte string.
         $hex = (string) bin2hex(mcrypt_create_iv(20, \MCRYPT_DEV_URANDOM));
         // 'manually' create address
         $encode = BitcoinLib::base58_encode_checksum($this->p2shAddressVersion . $hex);
         $decode = BitcoinLib::base58_decode_checksum($encode);
         // validate 'manually' created address
         $this->assertTrue(BitcoinLib::validate_address($encode, $this->addressVersion, $this->p2shAddressVersion));
         // validate 'manually' created address without specifying the address version
         //  relying on the defaults
         $this->assertTrue(BitcoinLib::validate_address($encode));
         // validate 'manually' created address
         //  disable address version and P2S address version specifically
         $this->assertTrue(BitcoinLib::validate_address($encode, false, null));
         $this->assertFalse(BitcoinLib::validate_address($encode, null, false));
         // validate 'manually'
         $this->assertTrue($hex == $decode);
         // create address
         $check2 = BitcoinLib::hash160_to_address($hex, $this->p2shAddressVersion);
         // validate created address
         $this->assertTrue(BitcoinLib::validate_address($check2, $this->addressVersion, $this->p2shAddressVersion));
         // validate created address without specifying the address version
         //  relying on the defaults
         $this->assertTrue(BitcoinLib::validate_address($check2));
         // validate created address
         //  disable address version and P2S address version specifically
         $this->assertTrue(BitcoinLib::validate_address($check2, false, null));
         $this->assertFalse(BitcoinLib::validate_address($check2, null, false));
         // validate 'manually'
         $this->assertTrue($check2 == $encode);
         // create address,  without specifying the address version
         //  relying on the defaults
         $check3 = BitcoinLib::hash160_to_address($hex, 'p2sh');
         // validate created address
         $this->assertTrue(BitcoinLib::validate_address($check3, $this->addressVersion, $this->p2shAddressVersion));
         // validate created address without specifying the address version
         //  relying on the defaults
         $this->assertTrue(BitcoinLib::validate_address($check3));
         // validate created address
         //  disable address version and P2S address version specifically
         $this->assertTrue(BitcoinLib::validate_address($check3, false, null));
         $this->assertFalse(BitcoinLib::validate_address($check3, null, false));
         // validate 'manually'
         $this->assertTrue($check3 == $encode);
     }
 }