private static void writeRandomRLPData(
      final RLPOutput out, final Random random, final AtomicInteger listDepth) {
    switch (random.nextInt(12)) {
      case 0:
        // Write empty byte string
        out.writeBytes(Bytes.EMPTY);
        break;
      case 1:
        // Small single byte
        out.writeByte((byte) random.nextInt(128));
        break;
      case 2:
        // Large single byte
        byte value = (byte) (random.nextInt(128) + 128);
        out.writeByte(value);
        break;
      case 3:
        // Small byte string
        int smallBytesSize = random.nextInt(54) + 2;
        out.writeBytes(randomBytes(random, smallBytesSize));
        break;
      case 4:
        // Large byte string
        int largeBytesSize = random.nextInt(500) + 56;
        out.writeBytes(randomBytes(random, largeBytesSize));
        break;
      case 5:
        // Close list
        if (listDepth.get() == 0) {
          // If we're outside of a list try again
          writeRandomRLPData(out, random, listDepth);
          return;
        }
        out.endList();
        listDepth.decrementAndGet();
        break;
      default:
        // Start list
        out.startList();
        listDepth.incrementAndGet();
        break;
    }
  }
Generate a random rlp-encoded value.

@param randomSeed Seed to use for random generation.
@return a random rlp-encoded value
ethereum/rlp/src/test-support/java/org/hyperledger/besu/ethereum/rlp/util/RLPTestUtil.java