BitmessageContext { public List<BitmessageAddress> createDeterministicAddresses( String passphrase, int numberOfAddresses, long version, long stream, boolean shorter) { List<BitmessageAddress> result = BitmessageAddress.deterministic( passphrase, numberOfAddresses, version, stream, shorter); for (int i = 0; i < result.size(); i++) { BitmessageAddress address = result.get(i); address.setAlias("deterministic (" + (i + 1) + ")"); ctx.getAddressRepository().save(address); } return result; } private  BitmessageContext(Builder builder); AddressRepository addresses(); MessageRepository messages(); Labeler labeler(); BitmessageAddress createIdentity(boolean shorter, Feature... features); BitmessageAddress joinChan(String passphrase, String address); BitmessageAddress createChan(String passphrase); List<BitmessageAddress> createDeterministicAddresses(
        String passphrase, int numberOfAddresses, long version, long stream, boolean shorter); void broadcast(final BitmessageAddress from, final String subject, final String message); void send(final BitmessageAddress from, final BitmessageAddress to, final String subject, final String message); void send(final Plaintext msg); void startup(); void shutdown(); void synchronize(InetAddress host, int port, long timeoutInSeconds, boolean wait); CustomMessage send(InetAddress server, int port, CustomMessage request); void cleanup(); void resendUnacknowledgedMessages(); boolean isRunning(); void addContact(BitmessageAddress contact); void addSubscribtion(BitmessageAddress address); Property status(); InternalContext internals(); static final int CURRENT_VERSION; }
@Test public void ensureDeterministicAddressesAreCreated() { final int expected_size = 8; List<BitmessageAddress> addresses = ctx.createDeterministicAddresses("test", expected_size, 4, 1, false); assertEquals(expected_size, addresses.size()); Set<String> expected = new HashSet<>(expected_size); expected.add("BM-2cWFkyuXXFw6d393RGnin2RpSXj8wxtt6F"); expected.add("BM-2cX8TF9vuQZEWvT7UrEeq1HN9dgiSUPLEN"); expected.add("BM-2cUzX8f9CKUU7L8NeB8GExZvf54PrcXq1S"); expected.add("BM-2cU7MAoQd7KE8SPF7AKFPpoEZKjk86KRqE"); expected.add("BM-2cVm8ByVBacc2DVhdTNs6rmy5ZQK6DUsrt"); expected.add("BM-2cW2af1vB6kWon2WkygDHqGwfcpfAFm2Jk"); expected.add("BM-2cWdWD7UtUN4gWChgNX9pvyvNPjUZvU8BT"); expected.add("BM-2cXkYgYcUrv4fGxSHzyEScW955Cc8sDteo"); for (BitmessageAddress a : addresses) { assertTrue(expected.contains(a.getAddress())); expected.remove(a.getAddress()); } }
@Test public void ensureShortDeterministicAddressesAreCreated() { final int expected_size = 1; List<BitmessageAddress> addresses = ctx.createDeterministicAddresses("test", expected_size, 4, 1, true); assertEquals(expected_size, addresses.size()); Set<String> expected = new HashSet<>(expected_size); expected.add("BM-NBGyBAEp6VnBkFWKpzUSgxuTqVdWPi78"); for (BitmessageAddress a : addresses) { assertTrue(expected.contains(a.getAddress())); expected.remove(a.getAddress()); } }