github.com/kotalco/kotal@v0.3.0/clients/ethereum2/nimbus_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 . "github.com/onsi/ginkgo/v2" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("Nimbus beacon node", func() { 14 15 node := ethereum2v1alpha1.BeaconNode{ 16 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 17 Client: ethereum2v1alpha1.NimbusClient, 18 Network: "mainnet", 19 }, 20 } 21 client, _ := NewClient(&node) 22 23 It("Should get correct command", func() { 24 Expect(client.Command()).To(ConsistOf("nimbus_beacon_node")) 25 }) 26 27 It("Should get correct env", func() { 28 Expect(client.Env()).To(BeNil()) 29 }) 30 31 It("Should get correct home dir", func() { 32 Expect(client.HomeDir()).To(Equal(NimbusHomeDir)) 33 }) 34 35 cases := []struct { 36 title string 37 node *ethereum2v1alpha1.BeaconNode 38 result []string 39 }{ 40 { 41 title: "beacon node syncing mainnet", 42 node: ðereum2v1alpha1.BeaconNode{ 43 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 44 Client: ethereum2v1alpha1.NimbusClient, 45 Network: "mainnet", 46 Logging: sharedAPI.DebugLogs, 47 }, 48 }, 49 result: []string{ 50 NimbusNonInteractive, 51 argWithVal(NimbusNetwork, "mainnet"), 52 argWithVal(NimbusLogging, string(sharedAPI.DebugLogs)), 53 }, 54 }, 55 { 56 title: "beacon node syncing mainnet with eth1 endpoint", 57 node: ðereum2v1alpha1.BeaconNode{ 58 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 59 Client: ethereum2v1alpha1.NimbusClient, 60 Network: "mainnet", 61 ExecutionEngineEndpoint: "https://localhost:8551", 62 JWTSecretName: "jwt-secret", 63 REST: true, 64 RESTPort: 8957, 65 CORSDomains: []string{"kotal.pro", "kotal.cloud"}, 66 }, 67 }, 68 result: []string{ 69 NimbusNonInteractive, 70 argWithVal(NimbusNetwork, "mainnet"), 71 argWithVal(NimbusExecutionEngineEndpoint, "https://localhost:8551"), 72 argWithVal(NimbusJwtSecretFile, fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(client.HomeDir()))), 73 argWithVal(NimbusRESTAddress, "0.0.0.0"), 74 argWithVal(NimbusRESTPort, "8957"), 75 argWithVal(NimbusRESTAllowOrigin, "kotal.pro,kotal.cloud"), 76 }, 77 }, 78 { 79 title: "beacon node syncing mainnet with eth1 endpoint", 80 node: ðereum2v1alpha1.BeaconNode{ 81 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 82 Client: ethereum2v1alpha1.NimbusClient, 83 Network: "mainnet", 84 ExecutionEngineEndpoint: "https://localhost:8551", 85 JWTSecretName: "jwt-secret", 86 }, 87 }, 88 result: []string{ 89 NimbusNonInteractive, 90 argWithVal(NimbusNetwork, "mainnet"), 91 argWithVal(NimbusExecutionEngineEndpoint, "https://localhost:8551"), 92 argWithVal(NimbusJwtSecretFile, fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(client.HomeDir()))), 93 }, 94 }, 95 { 96 title: "beacon node syncing mainnet with eth1 endpoint", 97 node: ðereum2v1alpha1.BeaconNode{ 98 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 99 Client: ethereum2v1alpha1.NimbusClient, 100 Network: "mainnet", 101 ExecutionEngineEndpoint: "https://localhost:8551", 102 JWTSecretName: "jwt-secret", 103 }, 104 }, 105 result: []string{ 106 NimbusNonInteractive, 107 argWithVal(NimbusNetwork, "mainnet"), 108 argWithVal(NimbusExecutionEngineEndpoint, "https://localhost:8551"), 109 argWithVal(NimbusJwtSecretFile, fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(client.HomeDir()))), 110 }, 111 }, 112 { 113 title: "beacon node syncing mainnet with eth1 endpoint", 114 node: ðereum2v1alpha1.BeaconNode{ 115 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 116 Client: ethereum2v1alpha1.NimbusClient, 117 Network: "mainnet", 118 ExecutionEngineEndpoint: "https://localhost:8551", 119 JWTSecretName: "jwt-secret", 120 }, 121 }, 122 result: []string{ 123 NimbusNonInteractive, 124 argWithVal(NimbusNetwork, "mainnet"), 125 argWithVal(NimbusExecutionEngineEndpoint, "https://localhost:8551"), 126 argWithVal(NimbusJwtSecretFile, fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(client.HomeDir()))), 127 }, 128 }, 129 { 130 title: "beacon node syncing mainnet with p2p port, eth1 endpoint", 131 node: ðereum2v1alpha1.BeaconNode{ 132 Spec: ethereum2v1alpha1.BeaconNodeSpec{ 133 Client: ethereum2v1alpha1.NimbusClient, 134 P2PPort: 7891, 135 Network: "mainnet", 136 ExecutionEngineEndpoint: "https://localhost:8551", 137 JWTSecretName: "jwt-secret", 138 FeeRecipient: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", 139 }, 140 }, 141 result: []string{ 142 NimbusNonInteractive, 143 argWithVal(NimbusTCPPort, "7891"), 144 argWithVal(NimbusUDPPort, "7891"), 145 argWithVal(NimbusNetwork, "mainnet"), 146 argWithVal(NimbusExecutionEngineEndpoint, "https://localhost:8551"), 147 argWithVal(NimbusJwtSecretFile, fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(client.HomeDir()))), 148 argWithVal(NimbusFeeRecipient, "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"), 149 }, 150 }, 151 } 152 153 for _, c := range cases { 154 func() { 155 cc := c 156 It(fmt.Sprintf("Should create correct client arguments for %s", cc.title), func() { 157 cc.node.Default() 158 client, _ := NewClient(cc.node) 159 args := client.Args() 160 Expect(args).To(ContainElements(cc.result)) 161 }) 162 }() 163 } 164 165 })