<commit_before>var test = require('tape');
var signaller = require('..');

var runTest = module.exports = function(messenger, peers) {
  var scope;
  var altScopes;

  test('create', function(t) {
    t.plan(2);
    t.ok(scope = signaller(messenger), 'created');
    t.ok(scope.id, 'have id');
  });

  test('announce', function(t) {
    t.plan(2);
    peers.expect(t, '/announce|{"id":"' + scope.id + '"}');
    scope.announce();
  });

  test('request', function(t) {
    var target = peers.first();

    t.plan(1);
    target.expect(t, { type: 'request' });
    scope.request({ id: peers.first().id });
  });

  test('request and handle response', function(t) {
    var target = peers.first();

    t.plan(3);

    target.expect(t, { type: 'request' }, function(data) {
      target.send('/to|' + scope.id + '|/ackreq|' + data.__reqid);
    });

    scope.request({ id: 'doesnotmatter' }, function(err, channel) {
      t.ok(channel, 'got channel');
      t.equal(typeof channel.send, 'function', 'got a send function');
    });
  });

  test('convert other peers to signaller scopes', function(t) {
    t.plan(peers.length);
<commit_msg>Fixed reference to send function in test peer<commit_after>var test = require('tape');
var signaller = require('..');

var runTest = module.exports = function(messenger, peers) {
  var scope;
  var altScopes;

  test('create', function(t) {
    t.plan(2);
    t.ok(scope = signaller(messenger), 'created');
    t.ok(scope.id, 'have id');
  });

  test('announce', function(t) {
    t.plan(2);
    peers.expect(t, '/announce|{"id":"' + scope.id + '"}');
    scope.announce();
  });

  test('request', function(t) {
    var target = peers.first();

    t.plan(1);
    target.expect(t, { type: 'request' });
    scope.request({ id: peers.first().id });
  });

  test('request and handle response', function(t) {
    var target = peers.first();

    t.plan(3);

    target.expect(t, { type: 'request' }, function(data) {
      target.write('/to|' + scope.id + '|/ackreq|' + data.__reqid);
    });

    scope.request({ id: 'doesnotmatter' }, function(err, channel) {
      t.ok(channel, 'got channel');
      t.equal(typeof channel.send, 'function', 'got a send function');
    });
  });

  test('convert other peers to signaller scopes', function(t) {
    t.plan(peers.length);

{'fraction_non_alphanumeric': 0.2021598272138229, 'fraction_numerical': 0.0034557235421166306, 'mean_word_length': 3.2888888888888888, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2526362', 'n_tokens_mistral': 816, 'n_tokens_neox': 799, 'n_words': 173}