test/test_decompose_message_body_in_chunks.js
/**
 * @method decompose_message_body_in_chunks
 *
 * @param message_body
 * @param msgType
 * @param chunkSize
 * @return {Array}
 *
 * wrap a message body into one or more message_chunks
 * (  use this method to build fake data blocks in tests)
 */


wrap a message body into one or more message_chunks
(  use this method to build fake data blocks in tests)
wrap a message body into one or more message_chunks ( use this method to build fake data blocks in tests )
function decompose_message_body_in_chunks(message_body, msgType, chunkSize) {
    assert(chunkSize > 24, "expecting chunkSize");
    assert(msgType.length === 3, " invalid msgType " + msgType);
    assert(message_body instanceof Buffer && message_body.length > 0, " invalid buffer");
    var sequenceNumberGenerator = new SequenceNumberGenerator();
    var options = {
        secureChannelId: 10,
        requestId: 36
    };
    var msgChunkManager = new SecureMessageChunkManager(msgType, options, null, sequenceNumberGenerator);
    var chunks = [];
    msgChunkManager.on("chunk", function (chunk) {
        if (chunk) {
            assert(chunk.length > 0);
            chunks.push(chunk);
        }
    });
    msgChunkManager.write(message_body);
    msgChunkManager.end();
    assert(chunks.length > 0, "decompose_message_body_in_chunks: must produce at least one chunk");
    return chunks;
}
function decompose_message_body_in_chunks ( message_body , msgType , chunkSize ) { assert ( chunkSize > 24 , "expecting chunkSize" ) ; assert ( msgType . length === 3 , " invalid msgType " + msgType ) ; assert ( message_body instanceof Buffer && message_body . length > 0 , " invalid buffer" ) ; var sequenceNumberGenerator = new SequenceNumberGenerator ( ) ; var options = { secureChannelId : 10 , requestId : 36 } ; var msgChunkManager = new SecureMessageChunkManager ( msgType , options , null , sequenceNumberGenerator ) ; var chunks = [ ] ; msgChunkManager . on ( "chunk" , function ( chunk ) { if ( chunk ) { assert ( chunk . length > 0 ) ; chunks . push ( chunk ) ; } } ) ; msgChunkManager . write ( message_body ) ; msgChunkManager . end ( ) ; assert ( chunks . length > 0 , "decompose_message_body_in_chunks: must produce at least one chunk" ) ; return chunks ; }
@method decompose_message_body_in_chunks
 @param message_body
 @param msgType
 @param chunkSize
 @return {Array}
@method decompose_message_body_in_chunks @param message_body @param msgType @param chunkSize @return { Array }