Merge pull request #1265 from eordano/fix/1052

Remove BuilderMockV0
This commit is contained in:
Matias Alejo Garcia 2014-09-08 15:08:12 -03:00
commit ff7b6d6ad8
5 changed files with 10 additions and 47 deletions

View file

@ -1,26 +0,0 @@
'use strict';
var bitcore = require('bitcore');
var Transaction = bitcore.Transaction;
function BuilderMockV0 (data) {
this.vanilla = data;
this.tx = new Transaction();
this.tx.parse(new Buffer(data.tx, 'hex'));
};
BuilderMockV0.prototype.build = function() {
return this.tx;
};
BuilderMockV0.prototype.getSelectedUnspent = function() {
return [];
};
BuilderMockV0.prototype.toObj = function() {
return this.vanilla;
};
module.exports = BuilderMockV0;

View file

@ -4,7 +4,6 @@ var bitcore = require('bitcore');
var _ = require('underscore');
var util = bitcore.util;
var Transaction = bitcore.Transaction;
var BuilderMockV0 = require('./BuilderMockV0');;
var TransactionBuilder = bitcore.TransactionBuilder;
var Script = bitcore.Script;
var Key = bitcore.Key;
@ -134,12 +133,7 @@ TxProposal.fromObj = function(o, forceOpts) {
}
o.builder = TransactionBuilder.fromObj(o.builderObj);
} catch (e) {
// backwards (V0) compatatibility fix.
if (!o.version) {
o.builder = new BuilderMockV0(o.builderObj);
o.readonly = 1;
};
throw new Error("Invalid or Incompatible Backup Detected.");
}
return new TxProposal(o);
};

View file

@ -1,11 +1,9 @@
'use strict';
var BuilderMockV0 = require('./BuilderMockV0');;
var bitcore = require('bitcore');
var util = bitcore.util;
var Transaction = bitcore.Transaction;
var BuilderMockV0 = require('./BuilderMockV0');;
var TxProposal = require('./TxProposal');;
var TxProposal = require('./TxProposal');
var Script = bitcore.Script;
var Key = bitcore.Key;
var buffertools = bitcore.buffertools;

View file

@ -133,7 +133,7 @@ describe('TxProposal', function() {
builderObj: b.toObj(),
inputChainPaths: ['m/1'],
});
}).should.throw('Invalid');
}).should.throw('Invalid or Incompatible Backup Detected');
});

View file

@ -432,16 +432,13 @@ describe('WalletFactory model', function() {
wf.network.start.getCall(0).args[0].privkey.length.should.equal(64); //privkey is hex of private key buffer
});
});
describe('dont break backwards compatibility of wallets', function() {
it('should be able to import unencrypted legacy wallet TxProposal: v0', function() {
var wf = new WalletFactory(config, '0.0.5');
var w = wf.fromObj(JSON.parse(legacyO));
describe('break backwards compatibility with older versions', function() {
it('should\'nt be able to import unencrypted legacy wallet TxProposal: v0', function() {
should.exist(w);
w.id.should.equal('55d4bd062d32f90a');
should.exist(w.publicKeyRing.getCopayerId);
should.exist(w.txProposals.toObj());
should.exist(w.privateKey.toObj());
(function() {
var wf = new WalletFactory(config, '0.0.5');
var w = wf.fromObj(JSON.parse(legacyO));
}).should.throw('Invalid or Incompatible Backup Detected');
});
it('should be able to import simple 1-of-1 encrypted legacy testnet wallet', function(done) {