### Question:
Address { public static boolean isValid(String address) { try { Bech32.HrpAndData data = Bech32.bech32Decode(address); if (!Arrays.equals(data.getHrp(), Constants.ADDRESS_PREFIX.getBytes())) return false; byte[] converted = BytesUtil.convertBits(data.getData(), 5, 8, false); int convertedLength = converted != null ? converted.length : 0; return convertedLength >= 2 && convertedLength <= 40; } catch (Exception ignored) { return false; } } Address(PrivateKey privateKey);  Address(PublicKey publicKey);  Address(String address); static boolean isValid(String address); byte[] getBytes(); @Override String toString();  }### Answer:
@Test public void testEncodeDecode() { Assert.assertTrue(Address.isValid(TEST_ADDRESS)); Bech32.HrpAndData data = Bech32.bech32Decode(TEST_ADDRESS); Assert.assertEquals("080301090f051414170f04160200111d0314131b1c1b1e041a080d091f1a1f06", Hex.toHexString(data.getData())); Assert.assertEquals(TEST_ADDRESS, Bech32.bech32Encode(Constants.ADDRESS_PREFIX, data.getData())); byte[] convertedUp = BytesUtil.convertBits(data.getData(), 5, 8, false); Assert.assertEquals("40c2979694bbc961023d1d27be6fc4d21a9febe6", Hex.toHexString(convertedUp)); byte[] convertedDown = BytesUtil.convertBits(convertedUp, 8, 5, true); Assert.assertEquals("080301090f051414170f04160200111d0314131b1c1b1e041a080d091f1a1f06", Hex.toHexString(convertedDown)); Assert.assertEquals(TEST_ADDRESS, Bech32.bech32Encode(Constants.ADDRESS_PREFIX, convertedDown)); }
@Test public void testVerification() { Assert.assertTrue(Address.isValid("bnb1grpf0955h0ykzq3ar5nmum7y6gdfl6lxfn46h2")); Assert.assertTrue(Address.isValid("bnb1hlly02l6ahjsgxw9wlcswnlwdhg4xhx38yxpd5")); Assert.assertFalse(Address.isValid("pnb1grpf0955h0ykzq3ar5nmum7y6gdfl6lxfn46h2")); Assert.assertFalse(Address.isValid("bnb1grpf0955h0ykzq3ar5nmum7y6gdfl6lxfn46h3")); }