Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cressie176 committed Nov 24, 2024
1 parent 7d5f460 commit 6add58c
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions test/callback_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,34 +214,33 @@ suite('sending messages', function() {
});
});

channel_test('saturate buffer', function(ch, done) {
var channelOptions = {};

channel_test('find high watermark', function(ch, done) {
var msg = randomString();
var baseline = 0;
ch.assertQueue('', {exclusive: true}, function(e, q) {
if (e !== null) return done(e);
let ok;
for (let i = 0; i < 2047; i++) {
ok = ch.sendToQueue(q.queue, Buffer.from(msg));
if (!ok) break;
}

assert.equal(ok, false);
while (ch.sendToQueue(q.queue, Buffer.from(msg))) {
baseline++;
};
channelOptions.highWaterMark = baseline * 2;
done();
});
})
});

channel_test('set high watermark (making it harder to saturate the buffer', { highWaterMark: 4092 }, function(ch, done) {
channel_test('set high watermark', channelOptions, function(ch, done) {
var msg = randomString();
ch.assertQueue('', {exclusive: true}, function(e, q) {
if (e !== null) return done(e);
let ok;
for (let i = 0; i < 4092; i++) {
var ok;
for (var i = 0; i < channelOptions.highWaterMark; i++) {
ok = ch.sendToQueue(q.queue, Buffer.from(msg));
assert.equal(ok, true);
}
done();
});
});

});

suite('ConfirmChannel', function() {
Expand All @@ -260,27 +259,27 @@ suite('ConfirmChannel', function() {
ch.waitForConfirms(done);
});

confirm_channel_test('saturate buffer', function(ch, done) {
var channelOptions = {};

confirm_channel_test('find high watermark', function(ch, done) {
var msg = randomString();
var baseline = 0;
ch.assertQueue('', {exclusive: true}, function(e, q) {
if (e !== null) return done(e);
let ok;
for (let i = 0; i < 2047; i++) {
ok = ch.sendToQueue(q.queue, Buffer.from(msg));
if (!ok) break;
}

assert.equal(ok, false);
while (ch.sendToQueue(q.queue, Buffer.from(msg))) {
baseline++;
};
channelOptions.highWaterMark = baseline * 2;
done();
});
})
});

confirm_channel_test('set high watermark (making it harder to saturate the buffer', { highWaterMark: 4092 }, function(ch, done) {
confirm_channel_test('set high watermark', channelOptions, function(ch, done) {
var msg = randomString();
ch.assertQueue('', {exclusive: true}, function(e, q) {
if (e !== null) return done(e);
let ok;
for (let i = 0; i < 4092; i++) {
var ok;
for (var i = 0; i < channelOptions.highWaterMark; i++) {
ok = ch.sendToQueue(q.queue, Buffer.from(msg));
assert.equal(ok, true);
}
Expand Down

0 comments on commit 6add58c

Please sign in to comment.