Commit e23b817a authored by Antonin Coulibaly's avatar Antonin Coulibaly Committed by Antonin Coulibaly
Browse files

FIX(protocol): make tag optional for getNextResponse

parent 81861e4a
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -1272,20 +1272,26 @@ class GetNextResponsePDU extends PDU {
     *                               request in a TCP connection
     * @param {Buffer} keyArg - key for the value that is being returned.
     * @param {number} dbVersionArg - the version of the object in the DB
     * @param {Buffer} tagArg - the hash of the value to put.
     * @param {number} code - response code (SUCCESS, FAIL)
     * @param {Buffer} errorMessageArg - Detailed error message.
     * @param {string} algorithm - algorithm used for the tag.
     * @param {Object} optionsArg - optional :
     *                  {string} [options.algorithm] - algorithm used for the
     *                                                 tag
     *                  {Buffer} [options.tag] - the hash of the value to put.
     * @returns {Kinetic} - message structure following the kinetic protocol
     */
    constructor(
        ackSequence, keyArg, dbVersionArg, tagArg, code, errorMessageArg,
        algorithm) {
        ackSequence, keyArg, dbVersionArg, code, errorMessageArg, optionsArg) {
        super();

        const options = optionsArg || {};
        let tag = null;

        if (options.tag)
            tag = validateVersionArgument(options.tag);

        const detailedMessage = validateBufferOrStringArgument(errorMessageArg);
        const key = validateBufferOrStringArgument(keyArg);
        const tag = validateVersionArgument(tagArg);
        const dbVersion = validateVersionArgument(dbVersionArg);

        this.setCommand({
@@ -1298,8 +1304,8 @@ class GetNextResponsePDU extends PDU {
                    key,
                    dbVersion,
                    tag,
                    algorithm: validateAlgo(algorithm) ||
                        algorithms.SHA1,
                    algorithm: tag ? validateAlgo(options.algorithm) ||
                        algorithms.SHA1 : null,
                },
            },
            status: {