@@ -13,6 +13,7 @@ import {
1313import { Network } from 'types' ;
1414import { defaultRepoState } from './constants' ;
1515import {
16+ createBitcoindKnotsNetworkNode ,
1617 createBitcoindNetworkNode ,
1718 createCLightningNetworkNode ,
1819 createLitdNetworkNode ,
@@ -379,6 +380,141 @@ describe('Network Utils', () => {
379380 } ) ;
380381 } ) ;
381382
383+ describe ( 'createBitcoindKnotsNetworkNode' , ( ) => {
384+ let network : Network ;
385+
386+ beforeEach ( ( ) => {
387+ network = createNetwork ( {
388+ id : 1 ,
389+ name : 'my-test' ,
390+ description : 'my-test-description' ,
391+ lndNodes : 0 ,
392+ clightningNodes : 0 ,
393+ eclairNodes : 0 ,
394+ bitcoindNodes : 1 ,
395+ bitcoindKnotsNodes : 0 ,
396+ tapdNodes : 0 ,
397+ litdNodes : 0 ,
398+ status : Status . Stopped ,
399+ repoState : defaultRepoState ,
400+ managedImages : testManagedImages ,
401+ customImages : [ ] ,
402+ manualMineCount : 6 ,
403+ } ) ;
404+ } ) ;
405+
406+ it ( 'should create a bitcoind-knots node with correct properties' , ( ) => {
407+ const node = createBitcoindKnotsNetworkNode (
408+ network ,
409+ defaultRepoState . images [ 'bitcoind-knots' ] . latest ,
410+ testNodeDocker ,
411+ ) ;
412+ expect ( node . name ) . toBe ( 'backend2' ) ;
413+ expect ( node . type ) . toBe ( 'bitcoin' ) ;
414+ expect ( node . implementation ) . toBe ( 'bitcoind-knots' ) ;
415+ expect ( node . version ) . toBe ( defaultRepoState . images [ 'bitcoind-knots' ] . latest ) ;
416+ expect ( node . status ) . toBe ( Status . Stopped ) ;
417+ expect ( node . ports . rpc ) . toBeDefined ( ) ;
418+ expect ( node . ports . p2p ) . toBeDefined ( ) ;
419+ expect ( node . ports . zmqBlock ) . toBeDefined ( ) ;
420+ expect ( node . ports . zmqTx ) . toBeDefined ( ) ;
421+ } ) ;
422+
423+ it ( 'should peer with existing bitcoin nodes' , ( ) => {
424+ const node = createBitcoindKnotsNetworkNode (
425+ network ,
426+ defaultRepoState . images [ 'bitcoind-knots' ] . latest ,
427+ testNodeDocker ,
428+ ) ;
429+ network . nodes . bitcoin . push ( node ) ;
430+ expect ( node . peers ) . toContain ( 'backend1' ) ;
431+ expect ( network . nodes . bitcoin [ 0 ] . peers ) . toContain ( 'backend2' ) ;
432+ } ) ;
433+
434+ it ( 'should have no peers when it is the first bitcoin node' , ( ) => {
435+ network . nodes . bitcoin = [ ] ;
436+ const node = createBitcoindKnotsNetworkNode (
437+ network ,
438+ defaultRepoState . images [ 'bitcoind-knots' ] . latest ,
439+ testNodeDocker ,
440+ ) ;
441+ expect ( node . peers ) . toHaveLength ( 0 ) ;
442+ } ) ;
443+ } ) ;
444+
445+ describe ( 'createNetwork with bitcoind-knots' , ( ) => {
446+ it ( 'should create a network with bitcoind-knots nodes' , ( ) => {
447+ const network = createNetwork ( {
448+ id : 1 ,
449+ name : 'knots-test' ,
450+ description : 'test with knots' ,
451+ lndNodes : 0 ,
452+ clightningNodes : 0 ,
453+ eclairNodes : 0 ,
454+ bitcoindNodes : 0 ,
455+ bitcoindKnotsNodes : 2 ,
456+ tapdNodes : 0 ,
457+ litdNodes : 0 ,
458+ status : Status . Stopped ,
459+ repoState : defaultRepoState ,
460+ managedImages : testManagedImages ,
461+ customImages : [ ] ,
462+ manualMineCount : 6 ,
463+ } ) ;
464+ expect ( network . nodes . bitcoin ) . toHaveLength ( 2 ) ;
465+ expect ( network . nodes . bitcoin [ 0 ] . implementation ) . toBe ( 'bitcoind-knots' ) ;
466+ expect ( network . nodes . bitcoin [ 1 ] . implementation ) . toBe ( 'bitcoind-knots' ) ;
467+ } ) ;
468+
469+ it ( 'should create a network with mixed bitcoind and bitcoind-knots nodes' , ( ) => {
470+ const network = createNetwork ( {
471+ id : 1 ,
472+ name : 'mixed-test' ,
473+ description : 'test with mixed backends' ,
474+ lndNodes : 0 ,
475+ clightningNodes : 0 ,
476+ eclairNodes : 0 ,
477+ bitcoindNodes : 1 ,
478+ bitcoindKnotsNodes : 1 ,
479+ tapdNodes : 0 ,
480+ litdNodes : 0 ,
481+ status : Status . Stopped ,
482+ repoState : defaultRepoState ,
483+ managedImages : testManagedImages ,
484+ customImages : [ ] ,
485+ manualMineCount : 6 ,
486+ } ) ;
487+ expect ( network . nodes . bitcoin ) . toHaveLength ( 2 ) ;
488+ expect ( network . nodes . bitcoin [ 0 ] . implementation ) . toBe ( 'bitcoind' ) ;
489+ expect ( network . nodes . bitcoin [ 1 ] . implementation ) . toBe ( 'bitcoind-knots' ) ;
490+ expect ( network . nodes . bitcoin [ 1 ] . peers ) . toContain ( 'backend1' ) ;
491+ expect ( network . nodes . bitcoin [ 0 ] . peers ) . toContain ( 'backend2' ) ;
492+ } ) ;
493+
494+ it ( 'should adjust bitcoind-knots version for LND compatibility when target version is available' , ( ) => {
495+ const network = createNetwork ( {
496+ id : 1 ,
497+ name : 'knots-lnd-test' ,
498+ description : 'test knots with lnd' ,
499+ lndNodes : 1 ,
500+ clightningNodes : 0 ,
501+ eclairNodes : 0 ,
502+ bitcoindNodes : 0 ,
503+ bitcoindKnotsNodes : 1 ,
504+ tapdNodes : 0 ,
505+ litdNodes : 0 ,
506+ status : Status . Stopped ,
507+ repoState : defaultRepoState ,
508+ managedImages : testManagedImages ,
509+ customImages : [ ] ,
510+ manualMineCount : 6 ,
511+ } ) ;
512+ expect ( network . nodes . bitcoin ) . toHaveLength ( 1 ) ;
513+ expect ( network . nodes . bitcoin [ 0 ] . implementation ) . toBe ( 'bitcoind-knots' ) ;
514+ expect ( network . nodes . bitcoin [ 0 ] . version ) . toBeDefined ( ) ;
515+ } ) ;
516+ } ) ;
517+
382518 describe ( 'createNetworkNodes' , ( ) => {
383519 let network : Network ;
384520
0 commit comments