small refactor in tests

This commit is contained in:
Ivan Socolsky 2015-02-06 20:59:59 -03:00
parent 1069619af1
commit 313ebee63d
1 changed files with 94 additions and 98 deletions

View File

@ -539,11 +539,16 @@ describe('Copay server', function() {
describe('#verifyMessageSignature', function() {
beforeEach(function() {
var server, wallet;
beforeEach(function(done) {
helpers.createAndJoinWallet('123', 2, 2, function(s, w) {
server = s;
wallet = w;
done();
});
});
it('should successfully verify message signature', function(done) {
helpers.createAndJoinWallet('123', 2, 2, function(server) {
var opts = {
message: aText,
signature: aTextSignature,
@ -554,10 +559,8 @@ describe('Copay server', function() {
done();
});
});
});
it('should fail to verify message signature for different copayer', function(done) {
helpers.createAndJoinWallet('123', 2, 2, function() {
var opts = {
message: aText,
signature: aTextSignature,
@ -571,14 +574,18 @@ describe('Copay server', function() {
});
});
});
});
describe('#createAddress', function() {
beforeEach(function() {
var server, wallet;
beforeEach(function(done) {
helpers.createAndJoinWallet('123', 2, 2, function(s, w) {
server = s;
wallet = w;
done();
});
});
it('should create main address', function(done) {
helpers.createAndJoinWallet('123', 2, 2, function(server) {
server.createAddress({
isChange: false,
}, function(err, address) {
@ -589,11 +596,9 @@ describe('Copay server', function() {
done();
});
});
});
it('should create change address', function(done) {
helpers.createAndJoinWallet('123', 2, 2, function(server) {
server.createAddress({
isChange: true,
}, function(err, address) {
@ -604,10 +609,8 @@ describe('Copay server', function() {
done();
});
});
});
it('should create many addresses on simultaneous requests', function(done) {
helpers.createAndJoinWallet('123', 2, 2, function(server) {
async.map(_.range(10), function(i, cb) {
server.createAddress({
isChange: false,
@ -621,11 +624,8 @@ describe('Copay server', function() {
done();
});
});
});
it('should not create address if unable to store wallet', function(done) {
helpers.createAndJoinWallet('123', 2, 2, function(server) {
var storeWalletStub = sinon.stub(server.storage, 'storeWallet');
storeWalletStub.yields('dummy error');
@ -651,11 +651,8 @@ describe('Copay server', function() {
});
});
});
});
it('should not create address if unable to store addresses', function(done) {
helpers.createAndJoinWallet('123', 2, 2, function(server) {
var storeAddressStub = sinon.stub(server.storage, 'storeAddress');
storeAddressStub.yields('dummy error');
@ -682,7 +679,6 @@ describe('Copay server', function() {
});
});
});
});
describe('#createTx', function() {
var server, wallet;