Ali sends a message without first claiming e2e keys. Set the expectations
and check the results.

@return {promise} which resolves to the ciphertext for Bob's device.
962185
function aliSendsMessage() {
    return Promise.all([
        sendMessage(aliTestClient.client),
        expectAliSendMessageRequest(),
    ]).spread(function(_, ciphertext) {
        return ciphertext;
    });
}
1174505
function () {
      const encodeABI = contract.deploy(options).encodeABI();
      txParams.data = encodeABI;

      return new Promise(function (onResolve, onReject) {
        web3Provider.eth.sendTransaction(txParams)
          .on('transactionHash', function(transactionHash){
            onResolve(transactionHash)
          })
          .on('error', onReject);
      });
    }
1145878
function aesDecrypt(msg, key, iv) {
    var logger = getLogger('security.cipher.aesDecrypt');
    var encryptedMsg = buffer2WordArray(msg);
    var keyWordArray = buffer2WordArray(key);
    var ivWordArray = buffer2WordArray(iv);
    if (logger.isDebugEnabled()) {
        logger.debug('encryptedMsg = %s\nkeyWordArray = %s\nivWordArray = %s',
            JSON.stringify(encryptedMsg), JSON.stringify(keyWordArray), JSON.stringify(ivWordArray));
    }
    var decryptedWordArray = CryptoJS.AES.decrypt({ciphertext: encryptedMsg}, keyWordArray, {
        iv: ivWordArray,
        padding: CryptoJS.pad.NoPadding,
        mode: CryptoJS.mode.IGE
    });
    if (logger.isDebugEnabled()) {
        logger.debug('decryptedWordArray = %s', JSON.stringify(decryptedWordArray));
    }
    return wordArray2Buffer(decryptedWordArray);
}
613731
function sendText(payload: {
  to: string,
  from: string,
  message: string,
  statusCallback: string,
}): Promise<null | TwilioResponse> {
  if (!(process.env.TWILIO_ACCOUNT_SID && process.env.TWILIO_AUTH_TOKEN)) {
    logErr(
      new Error(
        "Could not send text message, missing required Twilio env vars"
      ),
      { payload }
    );
    return Promise.resolve(null);
  } else if (!Twilio) {
    Twilio = require("twilio");
  }

  return new Twilio(
    process.env.TWILIO_ACCOUNT_SID,
    process.env.TWILIO_AUTH_TOKEN
  ).messages.create({
    to: `+1${payload.to}`,
    from: `+1${payload.from}`,
    body: payload.message,
    statusCallback: payload.statusCallback,
  });
}
583563
function() {

        /* Prepare our message */
        var message = { proxy: { proxy: clone, arguments: arguments }};

        /* Is this "new F()" or a normal call? */
        if (this instanceof Invocable) {
          message.newInstance = true;
          ProxyPromise.call(this, message, send);
          this.asProxy(true);
        } else {
          return new ProxyPromise(message, send);
        }
      }
888547
function deferPromise() {
    var resolve = null, reject = null;
    var promise = new Bluebird(function () {
        resolve = arguments[0];
        reject = arguments[1];
    });
    return {
        resolve: resolve,
        reject: reject,
        promise: promise
    };
}
1189898
function(privKey) {
      validatePrivKey(privKey);
      var raw_keys = curve25519.keyPair(privKey);
      if (raw_keys instanceof Promise) {
        return raw_keys.then(processKeys);
      } else {
        return processKeys(raw_keys);
      }
    }
628892
function () {
	    	var deferred = $q.defer();
	    	var promise = deferred.promise;
            
            function ok(value){
                deferred.resolve(value);
            }
            
            function errorCallback(error){
                deferred.reject(new Error(error));
            }
            
            if($window.plugins){
                $window.plugins.appPreferences.show()
                    .then(ok, errorCallback);
            } else {
                deferred.reject(new Error(this.pluginNotEnabledMessage));
            }
	    	
	    	this.decoratePromise(promise);
	    	return promise;
	    }
652422
function hashMessage(msg) {
  const sha1 = crypto.createHash('sha1');
  sha1.update(msg);
  return sha1.digest('hex');
}
428311
function (e) {
                if (e instanceof java.util.NoSuchElementException || e.message.startsWith("java.util.NoSuchElementException")) {
                    // Empty stream
                    return Promise.resolve();
                }
                return Promise.reject(e);
            }
249004
function() {
      let undelivered = this.published.reset();
      if (undelivered.length > 0) {
        return Promise.map(undelivered, (message) => {
          return this.channel.publish(message);
        });
      }
      return Promise.resolve(true);
    }
387458
function encryptMegolmEvent(opts) {
    expect(opts.senderKey).toBeTruthy();
    expect(opts.groupSession).toBeTruthy();

    const plaintext = opts.plaintext || {};
    if (!plaintext.content) {
        plaintext.content = {
            body: '42',
            msgtype: "m.text",
        };
    }
    if (!plaintext.type) {
        plaintext.type = "m.room.message";
    }
    if (!plaintext.room_id) {
        expect(opts.room_id).toBeTruthy();
        plaintext.room_id = opts.room_id;
    }

    return {
        event_id: 'test_megolm_event',
        content: {
            algorithm: "m.megolm.v1.aes-sha2",
            ciphertext: opts.groupSession.encrypt(JSON.stringify(plaintext)),
            device_id: "testDevice",
            sender_key: opts.senderKey,
            session_id: opts.groupSession.session_id(),
        },
        type: "m.room.encrypted",
    };
}
1321846
function () {
    const oThis = this
      , promiseArray = [];

    return new Promise(async function (onResolve, onReject) {
      for (var chain in setupConfig.chains) {
        promiseArray.push(oThis._isRunning(chain));
      }
      return Promise.all(promiseArray).then(onResolve);
    });
  }
555818
function AESDecipher(key, iv, bits, mode) {
  if (!(this instanceof AESDecipher))
    return new AESDecipher(key, iv, mode);

  assert(mode === 'ecb' || mode === 'cbc', 'Unknown mode.');

  this.key = new AESKey(key, bits);
  this.mode = mode;
  this.prev = iv;
  this.waiting = null;
  this.lastBlock = null;
}
361113
function () {
    for (var i=0; i<4; i++) {
      this._counter[i] = this._counter[i]+1 | 0;
      if (this._counter[i]) { break; }
    }
    return this._cipher.encrypt(this._counter);
  }
1122020
function() {
      var cert = this.keychain.getCertPem();
      if (!cert) {
        throw new CError('missing certificate').log();
      }
      var tmp = this.getDate() + '::' + cert + '::' + SECRET_CLIENT;
      var hmac = forge.hmac.create();
      hmac.start('sha256', SECRET);
      hmac.update(tmp);
      return hmac.digest().toHex();
    }
526987
async function () {
    const oThis = this
    ;

    try {
      const stakerAddress = coreAddresses.getAddressForUser('staker')
        , stakerPassphrase = coreAddresses.getPassphraseForUser('staker');

      // Validations
      if (!basicHelper.isAddressValid(stakerAddress) || !stakerPassphrase) {
        let errObj = responseHelper.error({
          internal_error_identifier: 's_sam_ss_1',
          api_error_identifier: 'invalid_staker_details',
          error_config: basicHelper.fetchErrorConfig()
        });
        return Promise.resolve(errObj);
      }
      if (!basicHelper.isAddressValid(oThis.beneficiary)) {
        let errObj = responseHelper.error({
          internal_error_identifier: 's_sam_ss_2',
          api_error_identifier: 'invalid_beneficiary_details',
          error_config: basicHelper.fetchErrorConfig()
        });
        return Promise.resolve(errObj);
      }
      if (!basicHelper.isUuidValid(oThis.uuid)) {
        let errObj = responseHelper.error({
          internal_error_identifier: 's_sam_ss_3',
          api_error_identifier: 'invalid_branded_token_uuid',
          error_config: basicHelper.fetchErrorConfig()
        });
        return Promise.resolve(errObj);
      }
      if (!basicHelper.isNonZeroWeiValid(oThis.toStakeAmount)) {
        let errObj = responseHelper.error({
          internal_error_identifier: 's_sam_ss_4',
          api_error_identifier: 'invalid_amount',
          error_config: basicHelper.fetchErrorConfig()
        });
        return Promise.resolve(errObj);
      }

      // Format wei
      oThis.toStakeAmount = basicHelper.formatWeiToString(oThis.toStakeAmount);

      const stakeTransactionHash = await openSTValueContractInteract.stake(stakerAddress, stakerPassphrase, oThis.uuid,
        oThis.toStakeAmount, oThis.beneficiary, true);

      return Promise.resolve(responseHelper.successWithData({
        transaction_uuid: uuid.v4(),
        transaction_hash: stakeTransactionHash
      }));

    } catch (err) {
      let errObj = responseHelper.error({
        internal_error_identifier: 's_sam_ss_5',
        api_error_identifier: 'something_went_wrong',
        error_config: basicHelper.fetchErrorConfig()
      });
      return Promise.resolve(errObj);
    }
  }