Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Fix Transaction().fromObject() #181

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

antouhou
Copy link

@antouhou antouhou commented Dec 8, 2017

If instance of Transaction is passed to Transaction.fromObject(), the method will crash. I believe this is a very rare use case, since nobody noticed it before. Better when it's fixed anyway :)

@BJGDEV
Copy link

BJGDEV commented Dec 27, 2017

test/integration/server.js

'use strict';

var _ = require('lodash');
var async = require('async');

var chai = require('chai');
var sinon = require('sinon');
var should = chai.should();
var log = require('npmlog');
log.debug = log.verbose;
log.level = 'info';

var Bitcore = require('bitcore-lib');

var Common = require('../../lib/common');
var Utils = Common.Utils;
var Constants = Common.Constants;
var Defaults = Common.Defaults;

var Model = require('../../lib/model');

var WalletService = require('../../lib/server');

var TestData = require('../testdata');
var helpers = require('./helpers');
var storage, blockchainExplorer, request;

describe('Wallet service', function() {
before(function(done) {
helpers.before(done);
});
beforeEach(function(done) {
helpers.beforeEach(function(res) {
storage = res.storage;
blockchainExplorer = res.blockchainExplorer;
request = res.request;
done();
});
});
after(function(done) {
helpers.after(done);
});

describe('#getServiceVersion', function() {
it('should get version from package', function() {
WalletService.getServiceVersion().should.equal('bws-' + require('../../package').version);
});
});

describe('#getInstance', function() {
it('should get server instance', function() {
var server = WalletService.getInstance({
clientVersion: 'bwc-2.9.0',
});
server.clientVersion.should.equal('bwc-2.9.0');
});
it('should not get server instance for BWC lower than v1.2', function() {
var err;
try {
var server = WalletService.getInstance({
clientVersion: 'bwc-1.1.99',
});
} catch (ex) {
err = ex;
}
should.exist(err);
err.code.should.equal('UPGRADE_NEEDED');
});
it('should get server instance for non-BWC clients', function() {
var server = WalletService.getInstance({
clientVersion: 'dummy-1.0.0',
});
server.clientVersion.should.equal('dummy-1.0.0');
server = WalletService.getInstance({});
(server.clientVersion == null).should.be.true;
});
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants