@Test
public void errorPaths() {

    // Check what happens if we try and decode garbage.
    try {
        Address.fromBase58(testParams, "this is not a valid address!");
        fail();
    } catch (WrongNetworkException e) {
        fail();
    } catch (AddressFormatException e) {
        // Success.
    }
    // Check the empty case.
    try {
        Address.fromBase58(testParams, "");
        fail();
    } catch (WrongNetworkException e) {
        fail();
    } catch (AddressFormatException e) {
        // Success.
    }
    // Check the case of a mismatched network.
    try {
        Address.fromBase58(testParams, "Xtqn4ks8sJS7iG7S7r1Jf37eFFSJGwh8a8");
        fail();
    } catch (WrongNetworkException e) {
        // Success.
        assertEquals(e.verCode, MainNetParams.get().getAddressHeader());
        assertTrue(Arrays.equals(e.acceptableVersions, TestNet3Params.get().getAcceptableAddressCodes()));
    } catch (AddressFormatException e) {
        fail();
    }
}