Browse Source

remove legacy fee computation tests

activeAddress
Ivan Socolsky 9 years ago
parent
commit
70c8fdac00
No known key found for this signature in database GPG Key ID: FAECE6A05FAA4F56
  1. 183
      test/integration/server.js

183
test/integration/server.js

@ -73,7 +73,7 @@ describe('Wallet service', function() {
});
server.clientVersion.should.equal('dummy-1.0.0');
server = WalletService.getInstance({});
(clientVersion == null).should.be.true;
(server.clientVersion == null).should.be.true;
});
});
@ -113,7 +113,7 @@ describe('Wallet service', function() {
});
});
it.only('should fail when requesting for non-existent copayer', function(done) {
it('should fail when requesting for non-existent copayer', function(done) {
var message = 'hello world';
var opts = {
copayerId: 'dummy',
@ -6743,185 +6743,6 @@ describe('Wallet service', function() {
});
});
describe('Legacy', function() {
describe('Fees', function() {
var server, wallet;
beforeEach(function(done) {
helpers.createAndJoinWallet(2, 3, function(s, w) {
server = s;
wallet = w;
done();
});
});
it('should create a tx from legacy (bwc-0.0.*) client', function(done) {
helpers.stubUtxos(server, wallet, [100, 200], function() {
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, TestData.copayers[0].privKey_1H_0, {
message: 'some message'
});
var verifyStub = sinon.stub(WalletService.prototype, '_verifySignature');
verifyStub.returns(true);
WalletService.getInstanceWithAuth({
copayerId: wallet.copayers[0].id,
message: 'dummy',
signature: 'dummy',
clientVersion: 'bwc-0.0.40',
}, function(err, server) {
should.not.exist(err);
should.exist(server);
verifyStub.restore();
server.createTxLegacy(txOpts, function(err, tx) {
should.not.exist(err);
should.exist(tx);
tx.amount.should.equal(helpers.toSatoshi(80));
tx.fee.should.equal(Defaults.DEFAULT_FEE_PER_KB);
done();
});
});
});
});
it('should not return error when fetching new txps from legacy (bwc-0.0.*) client', function(done) {
helpers.stubUtxos(server, wallet, [100, 200], function() {
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, TestData.copayers[0].privKey_1H_0, {
message: 'some message'
});
server.createTxLegacy(txOpts, function(err, tx) {
should.not.exist(err);
should.exist(tx);
var verifyStub = sinon.stub(WalletService.prototype, '_verifySignature');
verifyStub.returns(true);
WalletService.getInstanceWithAuth({
copayerId: wallet.copayers[0].id,
message: 'dummy',
signature: 'dummy',
clientVersion: 'bwc-0.0.40',
}, function(err, server) {
verifyStub.restore();
should.not.exist(err);
should.exist(server);
server.getPendingTxs({}, function(err, txps) {
should.not.exist(err);
should.exist(txps);
done();
});
});
});
});
});
it('should fail to sign tx from legacy (bwc-0.0.*) client', function(done) {
helpers.stubUtxos(server, wallet, [100, 200], function() {
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, TestData.copayers[0].privKey_1H_0, {
message: 'some message'
});
server.createTxLegacy(txOpts, function(err, tx) {
should.not.exist(err);
should.exist(tx);
_.startsWith(tx.version, '1.').should.be.false;
var verifyStub = sinon.stub(WalletService.prototype, '_verifySignature');
verifyStub.returns(true);
WalletService.getInstanceWithAuth({
copayerId: wallet.copayers[0].id,
message: 'dummy',
signature: 'dummy',
clientVersion: 'bwc-0.0.40',
}, function(err, server) {
var signatures = helpers.clientSign(tx, TestData.copayers[0].xPrivKey_44H_0H_0H);
server.signTx({
txProposalId: tx.id,
signatures: signatures,
}, function(err) {
verifyStub.restore();
should.exist(err);
err.code.should.equal('UPGRADE_NEEDED');
err.message.should.contain('sign this spend proposal');
done();
});
});
});
});
});
it('should create a tx from legacy (bwc-0.0.*) client and sign it from newer client', function(done) {
helpers.stubUtxos(server, wallet, [100, 200], function() {
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, TestData.copayers[0].privKey_1H_0, {
message: 'some message'
});
var verifyStub = sinon.stub(WalletService.prototype, '_verifySignature');
verifyStub.returns(true);
WalletService.getInstanceWithAuth({
copayerId: wallet.copayers[0].id,
message: 'dummy',
signature: 'dummy',
clientVersion: 'bwc-0.0.40',
}, function(err, server) {
should.not.exist(err);
should.exist(server);
verifyStub.restore();
server.createTxLegacy(txOpts, function(err, tx) {
should.not.exist(err);
should.exist(tx);
tx.amount.should.equal(helpers.toSatoshi(80));
tx.fee.should.equal(Defaults.DEFAULT_FEE_PER_KB);
helpers.getAuthServer(wallet.copayers[0].id, function(server) {
var signatures = helpers.clientSign(tx, TestData.copayers[0].xPrivKey_44H_0H_0H);
server.signTx({
txProposalId: tx.id,
signatures: signatures,
}, function(err) {
should.not.exist(err);
done();
});
});
});
});
});
});
it('should fail with insufficient fee when invoked from legacy (bwc-0.0.*) client', function(done) {
helpers.stubUtxos(server, wallet, 1, function() {
var verifyStub = sinon.stub(WalletService.prototype, '_verifySignature');
verifyStub.returns(true);
WalletService.getInstanceWithAuth({
copayerId: wallet.copayers[0].id,
message: 'dummy',
signature: 'dummy',
clientVersion: 'bwc-0.0.40',
}, function(err, server) {
should.not.exist(err);
should.exist(server);
verifyStub.restore();
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, TestData.copayers[0].privKey_1H_0);
server.createTxLegacy(txOpts, function(err, tx) {
should.exist(err);
err.code.should.equal('INSUFFICIENT_FUNDS_FOR_FEE');
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, TestData.copayers[0].privKey_1H_0, {
feePerKb: 5000
});
server.createTxLegacy(txOpts, function(err, tx) {
should.not.exist(err);
tx.fee.should.equal(5000);
// Sign it to make sure Bitcore doesn't complain about the fees
var signatures = helpers.clientSign(tx, TestData.copayers[0].xPrivKey_44H_0H_0H);
server.signTx({
txProposalId: tx.id,
signatures: signatures,
}, function(err) {
should.not.exist(err);
done();
});
});
});
});
});
});
});
});
describe('PayPro', function() {
var server, wallet;

Loading…
Cancel
Save