server_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package lnd
  2. import (
  3. "testing"
  4. "github.com/lightningnetwork/lnd/lncfg"
  5. )
  6. // TestShouldPeerBootstrap tests that we properly skip network bootstrap for
  7. // the developer networks, and also if bootstrapping is explicitly disabled.
  8. func TestShouldPeerBootstrap(t *testing.T) {
  9. t.Parallel()
  10. testCases := []struct {
  11. cfg *Config
  12. shouldBoostrap bool
  13. }{
  14. // Simnet active, no bootstrap.
  15. {
  16. cfg: &Config{
  17. Bitcoin: &lncfg.Chain{
  18. SimNet: true,
  19. },
  20. },
  21. },
  22. // Regtest active, no bootstrap.
  23. {
  24. cfg: &Config{
  25. Bitcoin: &lncfg.Chain{
  26. RegTest: true,
  27. },
  28. },
  29. },
  30. // Signet active, no bootstrap.
  31. {
  32. cfg: &Config{
  33. Bitcoin: &lncfg.Chain{
  34. SigNet: true,
  35. },
  36. },
  37. },
  38. // Mainnet active, but bootstrap disabled, no bootstrap.
  39. {
  40. cfg: &Config{
  41. Bitcoin: &lncfg.Chain{
  42. MainNet: true,
  43. },
  44. NoNetBootstrap: true,
  45. },
  46. },
  47. // Mainnet active, should bootstrap.
  48. {
  49. cfg: &Config{
  50. Bitcoin: &lncfg.Chain{
  51. MainNet: true,
  52. },
  53. },
  54. shouldBoostrap: true,
  55. },
  56. // Testnet active, should bootstrap.
  57. {
  58. cfg: &Config{
  59. Bitcoin: &lncfg.Chain{
  60. TestNet3: true,
  61. },
  62. },
  63. shouldBoostrap: true,
  64. },
  65. }
  66. for i, testCase := range testCases {
  67. bootstrapped := shouldPeerBootstrap(testCase.cfg)
  68. if bootstrapped != testCase.shouldBoostrap {
  69. t.Fatalf("#%v: expected bootstrap=%v, got bootstrap=%v",
  70. i, testCase.shouldBoostrap, bootstrapped)
  71. }
  72. }
  73. }