send TX tests
This commit is contained in:
parent
ce8aeee3a9
commit
f3a152ca30
|
@ -58,7 +58,6 @@ Verifier.checkTxProposal = function(data, txp) {
|
||||||
if (WalletUtils.xPubToCopayerId(xPubKey) === txp.creatorId) return true;
|
if (WalletUtils.xPubToCopayerId(xPubKey) === txp.creatorId) return true;
|
||||||
});
|
});
|
||||||
if (!creatorXPubKey) return false;
|
if (!creatorXPubKey) return false;
|
||||||
|
|
||||||
var creatorSigningPubKey = (new Bitcore.HDPublicKey(creatorXPubKey)).derive('m/1/0').publicKey.toString();
|
var creatorSigningPubKey = (new Bitcore.HDPublicKey(creatorXPubKey)).derive('m/1/0').publicKey.toString();
|
||||||
|
|
||||||
var hash = WalletUtils.getProposalHash(txp.toAddress, txp.amount, txp.message);
|
var hash = WalletUtils.getProposalHash(txp.toAddress, txp.amount, txp.message);
|
||||||
|
|
|
@ -457,7 +457,6 @@ API.prototype.signTxProposal = function(txp, cb) {
|
||||||
return cb(new ServerCompromisedError('Server sent fake transaction proposal'));
|
return cb(new ServerCompromisedError('Server sent fake transaction proposal'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Derive proper key to sign, for each input
|
//Derive proper key to sign, for each input
|
||||||
var privs = [],
|
var privs = [],
|
||||||
derived = {};
|
derived = {};
|
||||||
|
|
|
@ -109,6 +109,9 @@ WalletUtils.UNITS = {
|
||||||
};
|
};
|
||||||
|
|
||||||
WalletUtils.parseAmount = function(text) {
|
WalletUtils.parseAmount = function(text) {
|
||||||
|
if (!_.isString(text))
|
||||||
|
text = text.toString();
|
||||||
|
|
||||||
var regex = '^(\\d*(\\.\\d{0,8})?)\\s*(' + _.keys(WalletUtils.UNITS).join('|') + ')?$';
|
var regex = '^(\\d*(\\.\\d{0,8})?)\\s*(' + _.keys(WalletUtils.UNITS).join('|') + ')?$';
|
||||||
var match = new RegExp(regex, 'i').exec(text.trim());
|
var match = new RegExp(regex, 'i').exec(text.trim());
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
it('Send and broadcast in 1-1 wallet', function(done) {
|
||||||
helpers.createAndJoinWallet(clients, 1, 1, function(err, w) {
|
helpers.createAndJoinWallet(clients, 1, 1, function(err, w) {
|
||||||
clients[0].createAddress(function(err, x0) {
|
clients[0].createAddress(function(err, x0) {
|
||||||
|
@ -363,19 +363,52 @@ describe('client API ', function() {
|
||||||
should.exist(x0.address);
|
should.exist(x0.address);
|
||||||
blockExplorerMock.setUtxo(x0, 10, 1);
|
blockExplorerMock.setUtxo(x0, 10, 1);
|
||||||
var opts = {
|
var opts = {
|
||||||
amount: 1000,
|
amount: 10000,
|
||||||
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
|
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
|
||||||
message: 'hola 1-1',
|
message: 'hola 1-1',
|
||||||
};
|
};
|
||||||
clients[0].sendTxProposal(opts, function(err, x) {
|
clients[0].sendTxProposal(opts, function(err, x) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
console.log('[clientApi.js.372]',x); //TODO
|
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();
|
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) {
|
describe('TODO', function(x) {
|
||||||
it('should detect fake addresses ', function(done) {
|
it('should detect fake addresses ', function(done) {
|
||||||
|
|
Loading…
Reference in New Issue