spec/integ/megolm-integ.spec.js
function encryptOlmEvent(opts) {
    expect(opts.senderKey).toBeTruthy();
    expect(opts.p2pSession).toBeTruthy();
    expect(opts.recipient).toBeTruthy();

    const plaintext = {
        content: opts.plaincontent || {},
        recipient: opts.recipient.userId,
        recipient_keys: {
            ed25519: opts.recipient.getSigningKey(),
        },
        sender: opts.sender || '@bob:xyz',
        type: opts.plaintype || 'm.test',
    };

    const event = {
        content: {
            algorithm: 'm.olm.v1.curve25519-aes-sha2',
            ciphertext: {},
            sender_key: opts.senderKey,
        },
        sender: opts.sender || '@bob:xyz',
        type: 'm.room.encrypted',
    };
    event.content.ciphertext[opts.recipient.getDeviceKey()] =
        opts.p2pSession.encrypt(JSON.stringify(plaintext));
    return event;
}
function encryptOlmEvent(opts) {
    expect(opts.senderKey).toBeTruthy();
    expect(opts.p2pSession).toBeTruthy();
    expect(opts.recipient).toBeTruthy();

    const plaintext = {
        content: opts.plaincontent || {},
        recipient: opts.recipient.userId,
        recipient_keys: {
            ed25519: opts.recipient.getSigningKey(),
        },
        sender: opts.sender || '@bob:xyz',
        type: opts.plaintype || 'm.test',
    };

    const event = {
        content: {
            algorithm: 'm.olm.v1.curve25519-aes-sha2',
            ciphertext: {},
            sender_key: opts.senderKey,
        },
        sender: opts.sender || '@bob:xyz',
        type: 'm.room.encrypted',
    };
    event.content.ciphertext[opts.recipient.getDeviceKey()] =
        opts.p2pSession.encrypt(JSON.stringify(plaintext));
    return event;
}
function encryptOlmEvent ( opts ) { expect ( opts . senderKey ) . toBeTruthy ( ) ; expect ( opts . p2pSession ) . toBeTruthy ( ) ; expect ( opts . recipient ) . toBeTruthy ( ) ; const plaintext = { content : opts . plaincontent || { } , recipient : opts . recipient . userId , recipient_keys : { ed25519 : opts . recipient . getSigningKey ( ) , } , sender : opts . sender || '@bob:xyz' , type : opts . plaintype || 'm.test' , } ; const event = { content : { algorithm : 'm.olm.v1.curve25519-aes-sha2' , ciphertext : { } , sender_key : opts . senderKey , } , sender : opts . sender || '@bob:xyz' , type : 'm.room.encrypted' , } ; event . content . ciphertext [ opts . recipient . getDeviceKey ( ) ] = opts . p2pSession . encrypt ( JSON . stringify ( plaintext ) ) ; return event ; }
encrypt an event with olm

@param {object} opts
@param {string=} opts.sender
@param {string} opts.senderKey
@param {Olm.Session} opts.p2pSession
@param {TestClient} opts.recipient
@param {object=} opts.plaincontent
@param {string=} opts.plaintype

@return {object} event
encrypt an event with olm