@Test
  public void testRandomNonce() throws Exception {
    Assume.assumeFalse(TinkFips.useOnlyFips());
    Assume.assumeTrue(ChaCha20Poly1305Jce.isSupported());

    byte[] key = Random.randBytes(KEY_SIZE);
    Aead aead = createInstance(key);
    byte[] message = new byte[0];
    byte[] aad = new byte[0];
    HashSet<String> ciphertexts = new HashSet<String>();
    final int samples = 1 << 10;
    for (int i = 0; i < samples; i++) {
      byte[] ct = aead.encrypt(message, aad);
      String ctHex = Hex.encode(ct);
      assertFalse(ciphertexts.contains(ctHex));
      ciphertexts.add(ctHex);
    }
    assertEquals(samples, ciphertexts.size());
  }
This is a very simple test for the randomness of the nonce. The test simply checks that the
multiple ciphertexts of the same message are distinct.
java_src/src/test/java/com/google/crypto/tink/aead/internal/ChaCha20Poly1305JceTest.java