@Test
  public void concurrentUpdate() throws Exception {
    final int keyCount = 1000;
    try (final KeyValueStorage store = createStore()) {

      final CountDownLatch finishedLatch = new CountDownLatch(2);
      final Function<byte[], Thread> updater =
          (value) ->
              new Thread(
                  () -> {
                    try {
                      for (int i = 0; i < keyCount; i++) {
                        KeyValueStorageTransaction tx = store.startTransaction();
                        tx.put(Bytes.minimalBytes(i).toArrayUnsafe(), value);
                        tx.commit();
                      }
                    } finally {
                      finishedLatch.countDown();
                    }
                  });

      // Run 2 concurrent transactions that write a bunch of values to the same keys
      final byte[] a = Bytes.of(10).toArrayUnsafe();
      final byte[] b = Bytes.of(20).toArrayUnsafe();
      updater.apply(a).start();
      updater.apply(b).start();

      finishedLatch.await();

      for (int i = 0; i < keyCount; i++) {
        final byte[] key = Bytes.minimalBytes(i).toArrayUnsafe();
        final byte[] actual = store.get(key).get();
        assertThat(Arrays.equals(actual, a) || Arrays.equals(actual, b)).isTrue();
      }
    }
  }
Concurrent update.

@throws Exception the exception
testutil/src/main/java/org/hyperledger/besu/kvstore/AbstractKeyValueStorageTest.java