File: util_spec.rb

package info (click to toggle)
ruby-ffi-rzmq 2.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 392 kB
  • sloc: ruby: 2,992; sh: 21; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require File.join(File.dirname(__FILE__), %w[spec_helper])

module ZMQ
  describe Util do

    if LibZMQ.version4?
      describe "curve_keypair" do

        it "returns a set of public and private keys (libsodium linked)" do
          expect(ZMQ::Util).to receive(:curve_keypair).and_return([0, 1])
          public_key, private_key = ZMQ::Util.curve_keypair

          expect(public_key).not_to eq private_key
          expect(public_key).not_to be_nil
          expect(private_key).not_to be_nil
        end

        it "raises if zmq does not support CURVE (libsodium not linked)" do
          expect do
            allow(LibZMQ).to receive(:zmq_curve_keypair).and_return(-1)
            ZMQ::Util.curve_keypair
          end.to raise_exception(ZMQ::NotSupportedError)
        end

      end
    end

  end
end