From 6ce6320046ecf81219896a88a574d0baee8fdb2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Barrila=CC=81?= Date: Mon, 14 Jul 2025 11:09:27 +0200 Subject: [PATCH 1/4] change deliver message_annotation type --- lib/message.js | 2 +- test/messages.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/lib/message.js b/lib/message.js index ac6e213..eb05b46 100644 --- a/lib/message.js +++ b/lib/message.js @@ -287,7 +287,7 @@ define_outcome({ fields:[ {name:'delivery_failed', type:'boolean'}, {name:'undeliverable_here', type:'boolean'}, - {name:'message_annotations', type:'map'} + {name:'message_annotations', type:'symbolic_map'} ]}); module.exports = message; diff --git a/test/messages.ts b/test/messages.ts index b7e39a5..c0fcdf8 100644 --- a/test/messages.ts +++ b/test/messages.ts @@ -385,6 +385,7 @@ describe('acknowledgement', function() { outcome.state = 'released'; outcome.delivery_failed = context.delivery!.remote_state!.delivery_failed; outcome.undeliverable_here = context.delivery!.remote_state!.undeliverable_here; + outcome.message_annotations = context.delivery!.remote_state!.message_annotations; }); server.on('rejected', function (context: rhea.EventContext) { outcome.state = 'rejected'; @@ -492,6 +493,32 @@ describe('acknowledgement', function() { }); client.connect(listener.address() as any).attach_receiver({autoaccept: false}); }); + it('explicit modify with annotations', function(done: Function) { + server.options.treat_modified_as_released = false; + server.on('modified', function (context: rhea.EventContext) { + assert.equal(outcome.state, undefined); + outcome.state = 'modified'; + outcome.delivery_failed = context.delivery!.remote_state!.delivery_failed; + outcome.undeliverable_here = context.delivery!.remote_state!.undeliverable_here; + outcome.message_annotations = context.delivery!.remote_state!.message_annotations; + }); + server.once('sendable', function (context: rhea.EventContext) { + context.sender!.send({body:'modify-me'}); + }); + client.on('message', function(context: rhea.EventContext) { + assert.equal(context!.message!.body, 'modify-me'); + (context as any).delivery!.modified({delivery_failed:true, undeliverable_here: true, message_annotations: {"x-opt-annotation": "annotation-value"}}); + }); + client.on('connection_close', function (context: rhea.EventContext) { + assert.equal(outcome.state, 'modified'); + assert.equal(outcome.delivery_failed, true); + assert.equal(outcome.undeliverable_here, true); + assert.deepStrictEqual(outcome.message_annotations, {"x-opt-annotation": "annotation-value"}) + context.connection.close(); + done(); + }); + client.connect(listener.address() as any).attach_receiver({autoaccept: false}); + }); it('modified as released', function(done: Function) { server.once('sendable', function (context) { context.sender!.send({body:'try-again'}); @@ -509,6 +536,25 @@ describe('acknowledgement', function() { }); client.connect(listener.address() as any).attach_receiver({autoaccept: false}); }); + it('modified as released with annotations', function(done: Function) { + server.once('sendable', function (context) { + context.sender!.send({body:'try-again'}); + }); + client.on('message', function(context: rhea.EventContext) { + assert.equal(context.message!.body, 'try-again'); + context.delivery!.release({delivery_failed:true, undeliverable_here: true, message_annotations: {"x-opt-annotation": "annotation-value"}}); + }); + client.on('connection_close', function (context: rhea.EventContext) { + assert.equal(outcome.state, 'released'); + assert.equal(outcome.delivery_failed, true); + assert.equal(outcome.undeliverable_here, true); + assert.deepStrictEqual(outcome.message_annotations, {"x-opt-annotation": "annotation-value"}) + context.connection.close(); + done(); + }); + client.connect(listener.address() as any).attach_receiver({autoaccept: false}); + }); + }); describe('fragmentation', function() { From bc153676c2f3e3a9b3db17ec5dd923e4976d4cd7 Mon Sep 17 00:00:00 2001 From: magne Date: Mon, 14 Jul 2025 14:47:08 +0200 Subject: [PATCH 2/4] fix: change map to symbolic map for message_annotations on modified outcome --- lib/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/message.js b/lib/message.js index eb05b46..ac6e213 100644 --- a/lib/message.js +++ b/lib/message.js @@ -287,7 +287,7 @@ define_outcome({ fields:[ {name:'delivery_failed', type:'boolean'}, {name:'undeliverable_here', type:'boolean'}, - {name:'message_annotations', type:'symbolic_map'} + {name:'message_annotations', type:'map'} ]}); module.exports = message; From a387b6a06a380b3e014f3c0b33b61e2dda38e65e Mon Sep 17 00:00:00 2001 From: magne Date: Mon, 14 Jul 2025 14:56:44 +0200 Subject: [PATCH 3/4] chore: rollback of unnecessary tests --- test/messages.ts | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/test/messages.ts b/test/messages.ts index c0fcdf8..b7e39a5 100644 --- a/test/messages.ts +++ b/test/messages.ts @@ -385,7 +385,6 @@ describe('acknowledgement', function() { outcome.state = 'released'; outcome.delivery_failed = context.delivery!.remote_state!.delivery_failed; outcome.undeliverable_here = context.delivery!.remote_state!.undeliverable_here; - outcome.message_annotations = context.delivery!.remote_state!.message_annotations; }); server.on('rejected', function (context: rhea.EventContext) { outcome.state = 'rejected'; @@ -493,32 +492,6 @@ describe('acknowledgement', function() { }); client.connect(listener.address() as any).attach_receiver({autoaccept: false}); }); - it('explicit modify with annotations', function(done: Function) { - server.options.treat_modified_as_released = false; - server.on('modified', function (context: rhea.EventContext) { - assert.equal(outcome.state, undefined); - outcome.state = 'modified'; - outcome.delivery_failed = context.delivery!.remote_state!.delivery_failed; - outcome.undeliverable_here = context.delivery!.remote_state!.undeliverable_here; - outcome.message_annotations = context.delivery!.remote_state!.message_annotations; - }); - server.once('sendable', function (context: rhea.EventContext) { - context.sender!.send({body:'modify-me'}); - }); - client.on('message', function(context: rhea.EventContext) { - assert.equal(context!.message!.body, 'modify-me'); - (context as any).delivery!.modified({delivery_failed:true, undeliverable_here: true, message_annotations: {"x-opt-annotation": "annotation-value"}}); - }); - client.on('connection_close', function (context: rhea.EventContext) { - assert.equal(outcome.state, 'modified'); - assert.equal(outcome.delivery_failed, true); - assert.equal(outcome.undeliverable_here, true); - assert.deepStrictEqual(outcome.message_annotations, {"x-opt-annotation": "annotation-value"}) - context.connection.close(); - done(); - }); - client.connect(listener.address() as any).attach_receiver({autoaccept: false}); - }); it('modified as released', function(done: Function) { server.once('sendable', function (context) { context.sender!.send({body:'try-again'}); @@ -536,25 +509,6 @@ describe('acknowledgement', function() { }); client.connect(listener.address() as any).attach_receiver({autoaccept: false}); }); - it('modified as released with annotations', function(done: Function) { - server.once('sendable', function (context) { - context.sender!.send({body:'try-again'}); - }); - client.on('message', function(context: rhea.EventContext) { - assert.equal(context.message!.body, 'try-again'); - context.delivery!.release({delivery_failed:true, undeliverable_here: true, message_annotations: {"x-opt-annotation": "annotation-value"}}); - }); - client.on('connection_close', function (context: rhea.EventContext) { - assert.equal(outcome.state, 'released'); - assert.equal(outcome.delivery_failed, true); - assert.equal(outcome.undeliverable_here, true); - assert.deepStrictEqual(outcome.message_annotations, {"x-opt-annotation": "annotation-value"}) - context.connection.close(); - done(); - }); - client.connect(listener.address() as any).attach_receiver({autoaccept: false}); - }); - }); describe('fragmentation', function() { From 77302c1f8f1fc99b8fed084b3f091bda72f1d1ed Mon Sep 17 00:00:00 2001 From: magne Date: Mon, 14 Jul 2025 14:59:38 +0200 Subject: [PATCH 4/4] fix: updating message_annotations type --- lib/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/message.js b/lib/message.js index ac6e213..eb05b46 100644 --- a/lib/message.js +++ b/lib/message.js @@ -287,7 +287,7 @@ define_outcome({ fields:[ {name:'delivery_failed', type:'boolean'}, {name:'undeliverable_here', type:'boolean'}, - {name:'message_annotations', type:'map'} + {name:'message_annotations', type:'symbolic_map'} ]}); module.exports = message;