Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #225 from bookchin/master
Browse files Browse the repository at this point in the history
v1.3.4
  • Loading branch information
bookchin authored Jun 29, 2016
2 parents 3068347 + 68fd7a3 commit 511adae
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/network/protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ Protocol.prototype._handleConsign = function(params, callback) {

var contract = item.contracts[params.contact.nodeID];
var t = Date.now();

if (!contract) {
return callback(new Error('Consignment is not authorized'));
}

item.trees[contract.get('renter_id')] = params.audit_tree;

try {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storj",
"version": "1.3.3",
"version": "1.3.4",
"description": "implementation of the storj protocol for node.js and the browser",
"main": "index.js",
"directories": {
Expand Down
18 changes: 18 additions & 0 deletions test/network/protocol.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var Logger = require('kad').Logger;
var KeyPair = require('../../lib/keypair');
var stream = require('readable-stream');
var constants = require('../../lib/constants');
var StorageItem = require('../../lib/storage/item');

describe('Protocol', function() {

Expand Down Expand Up @@ -234,6 +235,23 @@ describe('Protocol', function() {
});
});

it('should error if the contract is for different nodeid', function(done) {
var proto = new Protocol({
network: {
_logger: Logger(0),
_manager: {
load: sinon.stub().callsArgWith(1, null, StorageItem({}))
}
}
});
proto._handleConsign({
contact: { nodeID: 'adc83b19e793491b1c6ea0fd8b46cd9f32e592fc' }
}, function(err) {
expect(err.message).to.equal('Consignment is not authorized');
done();
});
});

it('should error if the consign is early or late', function(done) {
var proto = new Protocol({
network: {
Expand Down

0 comments on commit 511adae

Please sign in to comment.