<commit_before>'use strict';

var _ = require('lodash');
var chai = require('chai');
var sinon = require('sinon');
var should = chai.should();
var Bitcore = require('bitcore-lib');

var Utils = require('../lib/common/utils');

describe('Utils', function() {
  describe('#hashMessage', function() {
    it('should create a hash', function() {
      var res = Utils.hashMessage('hola');
      res.toString('hex').should.equal('4102b8a140ec642feaa1c645345f714bc7132d4fd2f7f6202db8db305a96172f');
    });
  });

  describe.only('#xPubToCopayerId', function() {
    it('should generate copayerId', function() {
      var xpub = Bitcore.HDPublicKey.fromString('<KEY>');
      var res = Utils.xPubToCopayerId('btc', 'xpub');
      res.should.equal('7296cfd7d812726a25b9d7c582b93738389fa66328cdd47cc67dbf98f1ff68a1');
    });
  });



  describe('#signMessage', function() {
    it('should sign a message', function() {
      var sig = Utils.signMessage('hola', '09458c090a69a38368975fb68115df2f4b0ab7d1bc463fc60c67aa1730641d6c');
      should.exist(sig);
      sig.should.equal('3045022100f2e3369dd4813d4d42aa2ed74b5cf8e364a8fa13d43ec541e4bc29525e0564c302205b37a7d1ca73f684f91256806cdad4b320b4ed3000bee2e388bcec106e0280e0');
    });
    it('should fail to sign with wrong args', function() {
      (function() {
        Utils.signMessage('hola', '03bec86ad4a8a91fe7c11ec06af27246ec55094db3d86098b7d8b2f12afe47627f');
      }).should.throw('Number');
    });
  });

  describe('#verifyMessage', function() {
    it('should fail to verify a malformed signature', function() {
      var res = Utils.verifyMessage('hola', 'badsignature', '02555a2d45e309c00cc8c5090b6ec533c6880ab2d3bc970b3943def989b3373f16');
      should.exist(res);
      res.should.equal(false);
    });
    it('should fail to verify a null signature', function() {<commit_msg>add tests to copayerId<commit_after>'use strict';

var _ = require('lodash');
var chai = require('chai');
var sinon = require('sinon');
var should = chai.should();
var Bitcore = require('bitcore-lib');

var Utils = require('../lib/common/utils');

describe('Utils', function() {
  describe('#hashMessage', function() {
    it('should create a hash', function() {
      var res = Utils.hashMessage('hola');
      res.toString('hex').should.equal('4102b8a140ec642feaa1c645345f714bc7132d4fd2f7f6202db8db305a96172f');
    });
  });

  describe.only('#xPubToCopayerId', function() {
    it('should generate copayerId', function() {
      var xpub = Bitcore.HDPublicKey.fromString('<KEY>');
      var res = Utils.xPubToCopayerId('btc', 'xpub');
      res.should.equal('<KEY>');
    });

    it('should generate copayerId', function() {
      var xpub = Bitcore.HDPublicKey.fromString('<KEY>');
      var res = Utils.xPubToCopayerId('bch', 'xpub');
      res.should.equal('<KEY>');
    });
 
  });



  describe('#signMessage', function() {
    it('should sign a message', function() {
      var sig = Utils.signMessage('hola', '09458c090a69a38368975fb68115df2f4b0ab7d1bc463fc60c67aa1730641d6c');
      should.exist(sig);
      sig.should.equal('3045022100f2e3369dd4813d4d42aa2ed74b5cf8e364a8fa13d43ec541e4bc29525e0564c302205b37a7d1ca73f684f91256806cdad4b320b4ed3000bee2e388bcec106e0280e0');
    });
    it('should fail to sign with wrong args', function() {
      (function() {
        Utils.signMessage('hola', '03bec86ad4a8a91fe7c11ec06af27246ec55094db3d86098b7d8b2f12afe47627f');
      }).should.throw('Number');
    });
  });

  describe('#verifyMessage', function() {
    it('should fail to verify a malformed signature', function() {
      var res = Utils.verifyMessage('hola', 'badsignature', '02555a2d45e309c00cc8c5090b6ec533c6880ab2d3bc970b3943def989b3373f16');
      should.exist(res);
      res.should.equal(false);
    });
    it('should fail to verify a null signature', function() {
{'fraction_non_alphanumeric': 0.14875816993464053, 'fraction_numerical': 0.14614379084967322, 'mean_word_length': 4.727544910179641, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '2969618', 'n_tokens_mistral': 1704, 'n_tokens_neox': 1413, 'n_words': 207}