<commit_before>const assert = require('assert')
const spawn = require('child_process').spawn
const hepjs = require('hep-js')
const dgram = require('dgram')
const command = '../src/captagent'
const ipserver = '127.0.0.1'
const iptarget = '127.0.0.1'

/*
 * Start Captagent, Check Exit Code
 */
describe('CaptAgent HEP Basic', () => {
  let args = [
    "-n"
  ]

  let decoded
  let network
  var sipmessage = 'SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP there.com:5060\r\nFrom: LittleGuy <sip:<EMAIL>>\r\nTo: LittleGuy <sip:<EMAIL>>\r\nCall-ID: 12345678<EMAIL>\r\nCSeq: 2 REGISTER\r\n\r\n'
  var in_socket = dgram.createSocket('udp4')
  var out_socket = dgram.createSocket('udp4')

  before((done) => {

    let captagent = spawn(command, args);

    in_socket.on('message', (message,socket) => {
      decoded = hepjs.decapsulate(message);
      network = socket;
      captagent.kill();
    })
    in_socket.on('listening', function () {
	    captagent.stdout.on('data', (data) => {
	      if(!data.includes('ready')) return;
	      var udpmessage = new Buffer(sipmessage);
	      out_socket.send(udpmessage, 0, udpmessage.length, 5060, iptarget, function(err) {
	        if (err) done()
    	  });
    	})
    	captagent.on('close', () => {
		in_socket.close();
		out_socket.close();
		done()
	})

    })
    in_socket.bind(9061, ipserver)
  })
	
  it('HEP should originate from 127.0.0.1', () => {
    assert.ok(network.address === '127.0.0.1');
  })
  it('should return HEP data', () => {
    assert.ok(decoded.payload.length > 0);
  })
 })
<commit_msg>Update hep.js<commit_after>const assert = require('assert')
const spawn = require('child_process').spawn
const hepjs = require('hep-js')
const dgram = require('dgram')
const command = '../src/captagent'
const ipserver = '0.0.0.0'
const iptarget = '127.0.0.1'

/*
 * Start Captagent, Check Exit Code
 */
describe('CaptAgent HEP Basic', () => {
  let args = [
    "-n"
  ]

  let decoded
  let network
  var sipmessage = 'SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP there.com:5060\r\nFrom: LittleGuy <sip:<EMAIL>>\r\nTo: LittleGuy <sip:<EMAIL>>\r\nCall-ID: 123456789@there.com\r\nCSeq: 2 REGISTER\r\n\r\n'
  var in_socket = dgram.createSocket('udp4')
  var out_socket = dgram.createSocket('udp4')

  before((done) => {

    let captagent = spawn(command, args);

    in_socket.on('message', (message,socket) => {
      decoded = hepjs.decapsulate(message);
      network = socket;
      captagent.kill();
    })
    in_socket.on('listening', function () {
	    captagent.stdout.on('data', (data) => {
	      if(!data.includes('ready')) return;
	      var udpmessage = new Buffer(sipmessage);
	      out_socket.send(udpmessage, 0, udpmessage.length, 5060, iptarget, function(err) {
	        if (err) done()
    	  });
    	})
    	captagent.on('close', () => {
		in_socket.close();
		out_socket.close();
		done()
	})

    })
    in_socket.bind(9061, ipserver)
  })
	
  it('HEP should originate from 127.0.0.1', () => {
    assert.ok(network.address === '127.0.0.1');
  })
  it('should return HEP data', () => {
    assert.ok(decoded);
  })
  it('should return HEP payload', () => {
    assert.ok(decoded.payload.length > 0);
  })
 })

{'fraction_non_alphanumeric': 0.18353831598864712, 'fraction_numerical': 0.03500473036896878, 'mean_word_length': 3.1627296587926508, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 9, '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': '1940261', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1177, 'n_words': 218}