send TX tests

This commit is contained in:
Matias Alejo Garcia 2015-02-19 17:47:51 -03:00
parent ce8aeee3a9
commit f3a152ca30
4 changed files with 40 additions and 6 deletions

View File

@ -58,7 +58,6 @@ Verifier.checkTxProposal = function(data, txp) {
if (WalletUtils.xPubToCopayerId(xPubKey) === txp.creatorId) return true;
});
if (!creatorXPubKey) return false;
var creatorSigningPubKey = (new Bitcore.HDPublicKey(creatorXPubKey)).derive('m/1/0').publicKey.toString();
var hash = WalletUtils.getProposalHash(txp.toAddress, txp.amount, txp.message);

View File

@ -457,7 +457,6 @@ API.prototype.signTxProposal = function(txp, cb) {
return cb(new ServerCompromisedError('Server sent fake transaction proposal'));
}
//Derive proper key to sign, for each input
var privs = [],
derived = {};

View File

@ -109,6 +109,9 @@ WalletUtils.UNITS = {
};
WalletUtils.parseAmount = function(text) {
if (!_.isString(text))
text = text.toString();
var regex = '^(\\d*(\\.\\d{0,8})?)\\s*(' + _.keys(WalletUtils.UNITS).join('|') + ')?$';
var match = new RegExp(regex, 'i').exec(text.trim());

View File

@ -355,7 +355,7 @@ describe('client API ', function() {
});
describe.only('Send TXs', function() {
describe.only('Send Transactions', function() {
it('Send and broadcast in 1-1 wallet', function(done) {
helpers.createAndJoinWallet(clients, 1, 1, function(err, w) {
clients[0].createAddress(function(err, x0) {
@ -363,19 +363,52 @@ describe('client API ', function() {
should.exist(x0.address);
blockExplorerMock.setUtxo(x0, 10, 1);
var opts = {
amount: 1000,
amount: 10000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola 1-1',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
console.log('[clientApi.js.372]',x); //TODO
done();
x.requiredRejections.should.equal(1);
x.requiredSignatures.should.equal(1);
x.status.should.equal('pending');
x.changeAddress.path.should.equal('m/2147483647/1/0');
clients[0].signTxProposal(x.id, function(err, res) {
should.not.exist(err, err.message);
done();
});
});
});
});
});
it('Send and broadcast in 2-3 wallet', function(done) {
helpers.createAndJoinWallet(clients, 2, 3, function(err, w) {
clients[0].createAddress(function(err, x0) {
should.not.exist(err);
should.exist(x0.address);
blockExplorerMock.setUtxo(x0, 10, 1);
var opts = {
amount: 10000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola 1-1',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
x.status.should.equal('pending');
x.requiredRejections.should.equal(2);
x.requiredSignatures.should.equal(2);
clients[0].signTxProposal(x.id, function(err, res) {
should.not.exist(err, err.message);
done();
});
});
});
});
});
});
/*
describe('TODO', function(x) {
it('should detect fake addresses ', function(done) {