fix test 13

This commit is contained in:
Manuel Araoz 2014-08-19 15:50:42 -04:00
parent 50348a171f
commit f22c3e3be2
1 changed files with 12 additions and 23 deletions

View File

@ -170,32 +170,21 @@ describe('Network / Async', function() {
}); });
it('should not reject data sent from a peer with a really big new nonce', function() { it('should not reject data sent from a peer with a really big new nonce', function() {
var n = createN(); var n1 = createN(pk1);
n.privkey = key2.private.toString('hex'); var n2 = createN(pk2);
n.key = null; n2._deletePeer = sinon.spy();
n.networkNonces = {};
n.networkNonces[(new bitcore.SIN(key1.public)).toString()] = new Buffer('5000000000000001', 'hex'); //previously used nonce
var message = { var message = {
type: 'hello', type: 'hello',
copayerId: key1.public.toString('hex') copayerId: cid1
}; };
var messagestr = JSON.stringify(message); n2.networkNonces = {};
var messagebuf = new Buffer(messagestr); n2.networkNonces[cid1] = new Buffer('5000000000000001', 'hex'); //previously used nonce
var nonce = new Buffer('5000000000000002', 'hex')
var opts = { var enc = n1.encode(cid2, message, nonce);
nonce: new Buffer('5000000000000002', 'hex') n2._onMessage(enc);
}; //message send with new nonce n2._deletePeer.calledOnce.should.equal(false);
var encoded = n._encode(key2.public, key1, messagebuf, opts); n2.getHexNonces()[cid1].toString('hex').should.equal('0000000000000001');
var encodedstr = JSON.stringify(encoded);
var encodeduint = new Buffer(encodedstr);
var isInbound = true;
var peerId = new bitcore.SIN(key1.public);
n._deletePeer = sinon.spy();
n._onMessage(encodeduint, isInbound, peerId);
n._deletePeer.calledOnce.should.equal(false); n._deletePeer.calledOnce.should.equal(false);
}); });