@@ -458,6 +458,7 @@ describe('Wallet service', function() {
458
458
} ) ;
459
459
} ) ;
460
460
461
+
461
462
describe ( 'Address derivation strategy' , function ( ) {
462
463
var server ;
463
464
beforeEach ( function ( ) {
@@ -1249,7 +1250,7 @@ describe('Wallet service', function() {
1249
1250
} ) ;
1250
1251
} ) ;
1251
1252
1252
- it ( 'should create address' , function ( done ) {
1253
+ it ( 'should create address ' , function ( done ) {
1253
1254
server . createAddress ( { } , function ( err , address ) {
1254
1255
should . not . exist ( err ) ;
1255
1256
should . exist ( address ) ;
@@ -1377,6 +1378,113 @@ describe('Wallet service', function() {
1377
1378
} ) ;
1378
1379
} ) ;
1379
1380
1381
+ describe ( 'shared wallets (BIP44/BCH)' , function ( ) {
1382
+ beforeEach ( function ( done ) {
1383
+ helpers . createAndJoinWallet ( 2 , 2 , {
1384
+ coin : 'bch'
1385
+ } , function ( s , w ) {
1386
+ server = s ;
1387
+ wallet = w ;
1388
+ done ( ) ;
1389
+ } ) ;
1390
+ } ) ;
1391
+
1392
+ it ( 'should create address' , function ( done ) {
1393
+ server . createAddress ( { } , function ( err , address ) {
1394
+ should . not . exist ( err ) ;
1395
+ should . exist ( address ) ;
1396
+ address . walletId . should . equal ( wallet . id ) ;
1397
+ address . network . should . equal ( 'livenet' ) ;
1398
+ address . address . should . equal ( 'HBf8isgS8EXG1r3X6GP89FmooUmiJ42wHS' ) ;
1399
+ address . isChange . should . be . false ;
1400
+ address . path . should . equal ( 'm/0/0' ) ;
1401
+ address . type . should . equal ( 'P2SH' ) ;
1402
+ address . coin . should . equal ( 'bch' ) ;
1403
+ server . getNotifications ( { } , function ( err , notifications ) {
1404
+ should . not . exist ( err ) ;
1405
+ var notif = _ . find ( notifications , {
1406
+ type : 'NewAddress'
1407
+ } ) ;
1408
+ should . exist ( notif ) ;
1409
+ notif . data . address . should . equal ( address . address ) ;
1410
+ done ( ) ;
1411
+ } ) ;
1412
+ } ) ;
1413
+ } ) ;
1414
+
1415
+ it ( 'should create many addresses on simultaneous requests' , function ( done ) {
1416
+ var N = 5 ;
1417
+ async . mapSeries ( _ . range ( N ) , function ( i , cb ) {
1418
+ server . createAddress ( { } , cb ) ;
1419
+ } , function ( err , addresses ) {
1420
+ addresses . length . should . equal ( N ) ;
1421
+ _ . each ( _ . range ( N ) , function ( i ) {
1422
+ addresses [ i ] . path . should . equal ( 'm/0/' + i ) ;
1423
+ } ) ;
1424
+ // No two identical addresses
1425
+ _ . uniq ( _ . pluck ( addresses , 'address' ) ) . length . should . equal ( N ) ;
1426
+ done ( ) ;
1427
+ } ) ;
1428
+ } ) ;
1429
+
1430
+ it ( 'should not create address if unable to store it' , function ( done ) {
1431
+ sinon . stub ( server . storage , 'storeAddressAndWallet' ) . yields ( 'dummy error' ) ;
1432
+ server . createAddress ( { } , function ( err , address ) {
1433
+ should . exist ( err ) ;
1434
+ should . not . exist ( address ) ;
1435
+
1436
+ server . getMainAddresses ( { } , function ( err , addresses ) {
1437
+ addresses . length . should . equal ( 0 ) ;
1438
+
1439
+ server . storage . storeAddressAndWallet . restore ( ) ;
1440
+ server . createAddress ( { } , function ( err , address ) {
1441
+ should . not . exist ( err ) ;
1442
+ should . exist ( address ) ;
1443
+ done ( ) ;
1444
+ } ) ;
1445
+ } ) ;
1446
+ } ) ;
1447
+ } ) ;
1448
+ } ) ;
1449
+
1450
+
1451
+ describe ( '1-1 wallet (BIP44/BCH/Testnet)' , function ( ) {
1452
+ beforeEach ( function ( done ) {
1453
+ helpers . createAndJoinWallet ( 1 , 1 , {
1454
+ coin : 'bch' ,
1455
+ network : 'testnet' ,
1456
+ } , function ( s , w ) {
1457
+ server = s ;
1458
+ wallet = w ;
1459
+ done ( ) ;
1460
+ } ) ;
1461
+ } ) ;
1462
+
1463
+ it ( 'should create address' , function ( done ) {
1464
+ server . createAddress ( { } , function ( err , address ) {
1465
+ should . not . exist ( err ) ;
1466
+ should . exist ( address ) ;
1467
+ address . walletId . should . equal ( wallet . id ) ;
1468
+ address . network . should . equal ( 'testnet' ) ;
1469
+ address . address . should . equal ( 'mrM5kMkqZccK5MxZYSsM3SjqdMaNKLJgrJ' ) ;
1470
+ address . isChange . should . be . false ;
1471
+ address . path . should . equal ( 'm/0/0' ) ;
1472
+ address . type . should . equal ( 'P2PKH' ) ;
1473
+ address . coin . should . equal ( 'bch' ) ;
1474
+ server . getNotifications ( { } , function ( err , notifications ) {
1475
+ should . not . exist ( err ) ;
1476
+ var notif = _ . find ( notifications , {
1477
+ type : 'NewAddress'
1478
+ } ) ;
1479
+ should . exist ( notif ) ;
1480
+ notif . data . address . should . equal ( address . address ) ;
1481
+ done ( ) ;
1482
+ } ) ;
1483
+ } ) ;
1484
+ } ) ;
1485
+ } ) ;
1486
+
1487
+
1380
1488
describe ( '1-of-1 (BIP44 & P2PKH)' , function ( ) {
1381
1489
beforeEach ( function ( done ) {
1382
1490
helpers . createAndJoinWallet ( 1 , 1 , function ( s , w ) {
0 commit comments