mirror of https://github.com/status-im/js-waku.git
feat!: return `REMOTE_PEER_REJECTED` if remote peer rejected the message
This commit is contained in:
parent
6807185f3b
commit
053b6545ad
|
@ -146,14 +146,19 @@ class LightPush extends BaseProtocol implements ILightPush {
|
|||
return { recipients, error: SendError.DECODE_FAILED };
|
||||
}
|
||||
|
||||
if (response?.isSuccess) {
|
||||
recipients.some((recipient) => recipient.equals(peer.id)) ||
|
||||
recipients.push(peer.id);
|
||||
} else {
|
||||
if (!response) {
|
||||
log("Remote peer fault: No response in PushRPC");
|
||||
return { recipients, error: SendError.REMOTE_PEER_FAULT };
|
||||
}
|
||||
|
||||
if (!response.isSuccess) {
|
||||
log("Remote peer rejected the message: ", response.info);
|
||||
return { recipients, error: SendError.REMOTE_PEER_REJECTED };
|
||||
}
|
||||
|
||||
recipients.some((recipient) => recipient.equals(peer.id)) ||
|
||||
recipients.push(peer.id);
|
||||
|
||||
return { recipients };
|
||||
});
|
||||
|
||||
|
|
|
@ -79,10 +79,16 @@ export enum SendError {
|
|||
*/
|
||||
NO_PEER_AVAILABLE = "No peer available",
|
||||
/**
|
||||
* The remote peer did not behave as expected. Mitigation from `NO_PEER_AVAILABLE`
|
||||
* The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`
|
||||
* or `DECODE_FAILED` can be used.
|
||||
*/
|
||||
REMOTE_PEER_FAULT = "Remote peer fault"
|
||||
REMOTE_PEER_FAULT = "Remote peer fault",
|
||||
/**
|
||||
* The remote peer rejected the message. Information provided by the remote peer
|
||||
* is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
|
||||
* or `DECODE_FAILED` can be used.
|
||||
*/
|
||||
REMOTE_PEER_REJECTED = "Remote peer rejected"
|
||||
}
|
||||
|
||||
export interface SendResult {
|
||||
|
|
|
@ -86,7 +86,7 @@ describe("Waku Light Push [node only]", function () {
|
|||
});
|
||||
} else {
|
||||
expect(pushResponse.recipients.length).to.eq(0);
|
||||
expect(pushResponse.errors).to.include(SendError.NO_RPC_RESPONSE);
|
||||
expect(pushResponse.errors).to.include(SendError.REMOTE_PEER_REJECTED);
|
||||
expect(await messageCollector.waitForMessages(1)).to.eq(false);
|
||||
}
|
||||
});
|
||||
|
@ -158,7 +158,7 @@ describe("Waku Light Push [node only]", function () {
|
|||
});
|
||||
} else {
|
||||
expect(pushResponse.recipients.length).to.eq(0);
|
||||
expect(pushResponse.errors).to.include(SendError.NO_RPC_RESPONSE);
|
||||
expect(pushResponse.errors).to.include(SendError.REMOTE_PEER_REJECTED);
|
||||
expect(await messageCollector.waitForMessages(1)).to.eq(false);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue