github.com/kotalco/kotal@v0.3.0/clients/ethereum2/lighthouse_beacon_node_test.go (about) 1 package ethereum2 2 3 import ( 4 "fmt" 5 6 ethereum2v1alpha1 "github.com/kotalco/kotal/apis/ethereum2/v1alpha1" 7 sharedAPI "github.com/kotalco/kotal/apis/shared" 8 "github.com/kotalco/kotal/controllers/shared" 9 10 . "github.com/onsi/ginkgo/v2" 11 . "github.com/onsi/gomega" 12 ) 13 14 var _ = Describe("Lighthouse beacon node", func() { 15 16 node := ethereum2v1alpha1.BeaconNode{ 17 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 18 Client: ethereum2v1alpha1.LighthouseClient, 19 Network: "mainnet", 20 }, 21 } 22 client, _ := NewClient(&node) 23 24 It("Should get correct command", func() { 25 Expect(client.Command()).To(ConsistOf("lighthouse", "bn")) 26 }) 27 28 It("Should get correct env", func() { 29 Expect(client.Env()).To(BeNil()) 30 }) 31 32 It("Should get correct home dir", func() { 33 Expect(client.HomeDir()).To(Equal(LighthouseHomeDir)) 34 }) 35 36 cases := []struct { 37 title string 38 node *ethereum2v1alpha1.BeaconNode 39 result []string 40 }{ 41 { 42 title: "beacon node syncing mainnet", 43 node: ðereum2v1alpha1.BeaconNode{ 44 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 45 Client: ethereum2v1alpha1.LighthouseClient, 46 Network: "mainnet", 47 Logging: sharedAPI.TraceLogs, 48 }, 49 }, 50 result: []string{ 51 LighthouseDataDir, 52 LighthouseNetwork, 53 "mainnet", 54 LighthouseDebugLevel, 55 string(sharedAPI.TraceLogs), 56 }, 57 }, 58 { 59 title: "beacon node syncing mainnet", 60 node: ðereum2v1alpha1.BeaconNode{ 61 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 62 Client: ethereum2v1alpha1.LighthouseClient, 63 Network: "mainnet", 64 ExecutionEngineEndpoint: "https://localhost:8551", 65 JWTSecretName: "jwt-secret", 66 FeeRecipient: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", 67 }, 68 }, 69 result: []string{ 70 LighthouseDataDir, 71 LighthouseNetwork, 72 "mainnet", 73 LighthouseExecutionEngineEndpoint, 74 "https://localhost:8551", 75 LighthouseJwtSecretFile, 76 fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(client.HomeDir())), 77 LighthouseFeeRecipient, 78 "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", 79 }, 80 }, 81 { 82 title: "beacon node syncing mainnet and http enabled with checkpoint syncing", 83 node: ðereum2v1alpha1.BeaconNode{ 84 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 85 Client: ethereum2v1alpha1.LighthouseClient, 86 Network: "mainnet", 87 ExecutionEngineEndpoint: "https://localhost:8551", 88 JWTSecretName: "jwt-secret", 89 REST: true, 90 CheckpointSyncURL: "https://kotal.cloud/eth2/beacon/checkpoint", 91 }, 92 }, 93 result: []string{ 94 LighthouseDataDir, 95 LighthouseNetwork, 96 "mainnet", 97 LighthouseExecutionEngineEndpoint, 98 "https://localhost:8551", 99 LighthouseJwtSecretFile, 100 fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(client.HomeDir())), 101 LighthouseHTTP, 102 LighthouseAllowOrigins, 103 "*", 104 LighthouseCheckpointSyncUrl, 105 "https://kotal.cloud/eth2/beacon/checkpoint", 106 }, 107 }, 108 { 109 title: "beacon node syncing mainnet and http enabled with port", 110 node: ðereum2v1alpha1.BeaconNode{ 111 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 112 Client: ethereum2v1alpha1.LighthouseClient, 113 Network: "mainnet", 114 ExecutionEngineEndpoint: "https://localhost:8551", 115 JWTSecretName: "jwt-secret", 116 REST: true, 117 RESTPort: 4444, 118 }, 119 }, 120 result: []string{ 121 LighthouseDataDir, 122 LighthouseNetwork, 123 "mainnet", 124 LighthouseExecutionEngineEndpoint, 125 "https://localhost:8551", 126 LighthouseJwtSecretFile, 127 fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(client.HomeDir())), 128 LighthouseHTTP, 129 LighthouseHTTPPort, 130 "4444", 131 LighthouseAllowOrigins, 132 "*", 133 }, 134 }, 135 { 136 title: "beacon node syncing mainnet with http enabled with port and host", 137 node: ðereum2v1alpha1.BeaconNode{ 138 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 139 Client: ethereum2v1alpha1.LighthouseClient, 140 Network: "mainnet", 141 ExecutionEngineEndpoint: "https://localhost:8551", 142 JWTSecretName: "jwt-secret", 143 REST: true, 144 RESTPort: 4444, 145 }, 146 }, 147 result: []string{ 148 LighthouseDataDir, 149 LighthouseNetwork, 150 "mainnet", 151 LighthouseExecutionEngineEndpoint, 152 "https://localhost:8551", 153 LighthouseJwtSecretFile, 154 fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(client.HomeDir())), 155 LighthouseHTTP, 156 LighthouseHTTPPort, 157 "4444", 158 LighthouseHTTPAddress, 159 "0.0.0.0", 160 LighthouseAllowOrigins, 161 "*", 162 }, 163 }, 164 { 165 title: "beacon node syncing mainnet with p2p port, http enabled with port and host", 166 node: ðereum2v1alpha1.BeaconNode{ 167 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 168 Client: ethereum2v1alpha1.LighthouseClient, 169 P2PPort: 7891, 170 Network: "mainnet", 171 ExecutionEngineEndpoint: "https://localhost:8551", 172 JWTSecretName: "jwt-secret", 173 REST: true, 174 RESTPort: 4444, 175 }, 176 }, 177 result: []string{ 178 LighthouseDataDir, 179 LighthousePort, 180 "7891", 181 LighthouseDiscoveryPort, 182 "7891", 183 LighthouseNetwork, 184 "mainnet", 185 LighthouseExecutionEngineEndpoint, 186 "https://localhost:8551", 187 LighthouseJwtSecretFile, 188 fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(client.HomeDir())), 189 LighthouseHTTP, 190 LighthouseHTTPPort, 191 "4444", 192 LighthouseHTTPAddress, 193 "0.0.0.0", 194 LighthouseAllowOrigins, 195 "*", 196 }, 197 }, 198 } 199 200 for _, c := range cases { 201 func() { 202 cc := c 203 It(fmt.Sprintf("Should create correct client arguments for %s", cc.title), func() { 204 cc.node.Default() 205 client, _ := NewClient(cc.node) 206 args := client.Args() 207 Expect(args).To(ContainElements(cc.result)) 208 }) 209 }() 210 } 211 212 })