mirror of https://github.com/BTCPrivate/copay.git
add test for sendTx
This commit is contained in:
parent
697dea673a
commit
2fe08a258d
|
@ -487,17 +487,17 @@ Wallet.prototype.sendTx = function(ntxid, cb) {
|
|||
|
||||
var tx = txp.builder.build();
|
||||
if (!tx.isComplete()) return;
|
||||
this.log('[Wallet.js.231] BROADCASTING TX!!!'); //TODO
|
||||
this.log('Broadcasting Transaction');
|
||||
|
||||
var scriptSig = tx.ins[0].getScript();
|
||||
var size = scriptSig.serialize().length;
|
||||
|
||||
var txHex = tx.serialize().toString('hex');
|
||||
this.log('[Wallet.js.261:txHex:]', txHex); //TODO
|
||||
this.log('Raw transaction: ', txHex);
|
||||
|
||||
var self = this;
|
||||
this.blockchain.sendRawTransaction(txHex, function(txid) {
|
||||
self.log('BITCOIND txid:', txid); //TODO
|
||||
self.log('BITCOIND txid:', txid);
|
||||
if (txid) {
|
||||
self.txProposals.setSent(ntxid, txid);
|
||||
self.sendTxProposals(null, ntxid);
|
||||
|
|
|
@ -18,7 +18,6 @@ var Wallet = require('./Wallet');
|
|||
function WalletFactory(config, version) {
|
||||
var self = this;
|
||||
config = config || {};
|
||||
console.log('asd');
|
||||
|
||||
this.storage = new Storage(config.storage);
|
||||
this.network = new Network(config.network);
|
||||
|
|
|
@ -34,8 +34,10 @@ describe('Wallet model', function() {
|
|||
throw ();
|
||||
});
|
||||
|
||||
var createW = function(netKey) {
|
||||
var createW = function(netKey, N) {
|
||||
|
||||
var c = JSON.parse(JSON.stringify(config));
|
||||
if (!N) N = c.totalCopayers;
|
||||
|
||||
if (netKey) c.netKey = netKey;
|
||||
c.privateKey = new copay.PrivateKey({
|
||||
|
@ -44,8 +46,8 @@ describe('Wallet model', function() {
|
|||
|
||||
c.publicKeyRing = new copay.PublicKeyRing({
|
||||
networkName: c.networkName,
|
||||
requiredCopayers: c.requiredCopayers,
|
||||
totalCopayers: c.totalCopayers,
|
||||
requiredCopayers: Math.min(N, c.requiredCopayers),
|
||||
totalCopayers: N,
|
||||
});
|
||||
var copayerEPK = c.privateKey.deriveBIP45Branch().extendedPublicKeyString()
|
||||
c.publicKeyRing.addCopayer(copayerEPK);
|
||||
|
@ -101,14 +103,15 @@ describe('Wallet model', function() {
|
|||
"confirmations": 7
|
||||
}];
|
||||
|
||||
var createW2 = function(privateKeys) {
|
||||
var createW2 = function(privateKeys, N) {
|
||||
if (!N) N = 3;
|
||||
var netKey = 'T0FbU2JLby0=';
|
||||
var w = createW(netKey);
|
||||
var w = createW(netKey, N);
|
||||
should.exist(w);
|
||||
|
||||
var pkr = w.publicKeyRing;
|
||||
|
||||
for (var i = 0; i < 4; i++) {
|
||||
for (var i = 0; i < N-1; i++) {
|
||||
if (privateKeys) {
|
||||
var k = privateKeys[i];
|
||||
pkr.addCopayer(k ? k.deriveBIP45Branch().extendedPublicKeyString() : null);
|
||||
|
@ -459,5 +462,17 @@ describe('Wallet model', function() {
|
|||
w.reject(ntxid);
|
||||
});
|
||||
});
|
||||
it('should create & sign & send a transaction', function(done) {
|
||||
|
||||
var w = createW2(null, 1);
|
||||
var utxo = createUTXO(w);
|
||||
w.blockchain.fixUnspent(utxo);
|
||||
w.createTx(toAddress, amountSatStr, function(ntxid) {
|
||||
w.sendTx(ntxid, function(txid) {
|
||||
txid.length.should.equal(64);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue