private Envelope nextEnvelope(boolean withBuffer) {
return nextEnvelope(withBuffer, false);
}
private Envelope nextEnvelope(int bufferSize, AbstractEvent... events) {
Envelope env = new Envelope(random.nextInt(), new JobID(), new ChannelID());
if (bufferSize > 0) {
byte[] data = new byte[bufferSize];
random.nextBytes(data);
env.setBuffer(spy(new Buffer(new MemorySegment(data), bufferSize, RECYCLER)));