Skip to content

Commit

Permalink
Update non-confirmable request tests
Browse files Browse the repository at this point in the history
Non-confirmable request should not send any retries and timeout after maxRTT time.
  • Loading branch information
GiedriusM committed Jan 27, 2017
1 parent bc76bcb commit 331e1de
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions test/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,34 +657,34 @@ describe('request', function() {
setImmediate(fastForward.bind(null, increase, max - increase))
}

it('should error after ~247 seconds', function (done) {
it('should error after ~202 seconds', function (done) {
var req = doReq()

req.on('error', function (err) {
expect(err).to.have.property('message', 'No reply in 247s')
expect(err).to.have.property('retransmitTimeout', 247)
expect(err).to.have.property('message', 'No reply in 202s')
expect(err).to.have.property('retransmitTimeout', 202)
done()
})

fastForward(1000, 247 * 1000)
fastForward(1000, 202*1000)
})

it('should timeout after ~247 seconds', function (done) {
it('should timeout after ~202 seconds', function (done) {
var req = doReq()

req.on('error', function () {
})

req.on('timeout', function (err) {
expect(err).to.have.property('message', 'No reply in 247s')
expect(err).to.have.property('retransmitTimeout', 247)
expect(err).to.have.property('message', 'No reply in 202s')
expect(err).to.have.property('retransmitTimeout', 202)
done()
})

fastForward(1000, 247 * 1000)
fastForward(1000, 202 * 1000)
})

it('should retry four times before erroring', function (done) {
it('should not retry before erroring', function (done) {
var req = doReq()
, messages = 0

Expand All @@ -693,15 +693,14 @@ describe('request', function() {
})

req.on('error', function (err) {
// original one plus 4 retries
expect(messages).to.eql(5)
expect(messages).to.eql(1)
done()
})

fastForward(100, 247 * 1000)
})

it('should retry four times before 45s', function (done) {
it('should not retry before 45s', function (done) {
var req = doReq()
, messages = 0

Expand All @@ -710,8 +709,7 @@ describe('request', function() {
})

setTimeout(function () {
// original one plus 4 retries
expect(messages).to.eql(5)
expect(messages).to.eql(1)
done()
}, 45 * 1000)

Expand Down

0 comments on commit 331e1de

Please sign in to comment.