Skip to content

Commit

Permalink
CAPT-252: Synacormedia bid adapter: add tmax to requests based upon p…
Browse files Browse the repository at this point in the history
…rovided timeouts. (#8526)

Co-authored-by: Timothy M. Ace <tace@imds.tv>
  • Loading branch information
ecammit and ecammit authored Jun 10, 2022
1 parent 5584057 commit f2f87e7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/synacormediaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ export const spec = {
imp: []
};

const callbackTimeout = bidderRequest.timeout;
const globalTimeout = config.getConfig('bidderTimeout');
const tmax = globalTimeout ? Math.min(globalTimeout, callbackTimeout) : callbackTimeout;
if (tmax) {
openRtbBidRequest.tmax = tmax;
}

const schain = validBidReqs[0].schain;
if (schain) {
openRtbBidRequest.source = { ext: { schain } };
Expand Down
44 changes: 44 additions & 0 deletions test/spec/modules/synacormediaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ describe('synacormediaBidAdapter ', function () {
}
};

let bidderRequestWithTimeout = {
auctionId: 'xyz123',
refererInfo: {
referer: 'https://test.com/foo/bar'
},
timeout: 3000
};

let bidderRequestWithCCPA = {
auctionId: 'xyz123',
refererInfo: {
Expand Down Expand Up @@ -295,6 +303,42 @@ describe('synacormediaBidAdapter ', function () {
expect(reqVideo.data.imp).to.eql([expectedDataVideo1]);
});

it('should return no tmax', function () {
let req = spec.buildRequests([validBidRequest], bidderRequest);
expect(req.data).to.not.have.property('tmax');
});

it('should return tmax equal to callback timeout', function () {
let req = spec.buildRequests([validBidRequest], bidderRequestWithTimeout);
expect(req.data.tmax).to.eql(bidderRequestWithTimeout.timeout);
});

it('should return tmax equal to smaller global timeout', function () {
let sandbox = sinon.sandbox.create();
sandbox.stub(config, 'getConfig').callsFake(key => {
const config = {
'bidderTimeout': bidderRequestWithTimeout.timeout - 100
};
return config[key];
});
let req = spec.buildRequests([validBidRequest], bidderRequestWithTimeout);
sandbox.restore();
expect(req.data.tmax).to.eql(bidderRequestWithTimeout.timeout - 100);
});

it('should return tmax equal to smaller callback timeout', function () {
let sandbox = sinon.sandbox.create();
sandbox.stub(config, 'getConfig').callsFake(key => {
const config = {
'bidderTimeout': bidderRequestWithTimeout.timeout + 100
};
return config[key];
});
let req = spec.buildRequests([validBidRequest], bidderRequestWithTimeout);
sandbox.restore();
expect(req.data.tmax).to.eql(bidderRequestWithTimeout.timeout);
});

it('should return multiple bids when multiple valid requests with the same seatId are used', function () {
let secondBidRequest = {
bidId: 'foobar',
Expand Down

0 comments on commit f2f87e7

Please sign in to comment.