@@ -44,12 +44,17 @@ type Besu struct {
4444 powSettings
4545}
4646
47+ // WithTestInstance sets up the execution client for testing by assigning a test logger and the testing context.
48+ // This allows for better logging and error tracking during test execution.
4749func (g * Besu ) WithTestInstance (t * testing.T ) ExecutionClient {
4850 g .l = logging .GetTestLogger (t )
4951 g .t = t
5052 return g
5153}
5254
55+ // StartContainer initializes and starts a Besu container for Ethereum execution.
56+ // It configures network settings based on the Ethereum version and returns the
57+ // network configuration along with any errors encountered during the process.
5358func (g * Besu ) StartContainer () (blockchain.EVMNetwork , error ) {
5459 var r * tc.ContainerRequest
5560 var err error
@@ -121,48 +126,69 @@ func (g *Besu) StartContainer() (blockchain.EVMNetwork, error) {
121126 return networkConfig , nil
122127}
123128
129+ // GetInternalExecutionURL returns the internal execution URL for the Besu client.
130+ // It is used to retrieve the endpoint for executing transactions in Ethereum 2.0 networks,
131+ // ensuring compatibility with the Ethereum version in use.
124132func (g * Besu ) GetInternalExecutionURL () string {
125133 if g .GetEthereumVersion () == config_types .EthereumVersion_Eth1 {
126134 panic ("eth1 node doesn't have an execution URL" )
127135 }
128136 return g .InternalExecutionURL
129137}
130138
139+ // GetExternalExecutionURL returns the external execution URL for the Besu instance.
140+ // It panics if the Ethereum version is Eth1, as Eth1 nodes do not support execution URLs.
131141func (g * Besu ) GetExternalExecutionURL () string {
132142 if g .GetEthereumVersion () == config_types .EthereumVersion_Eth1 {
133143 panic ("eth1 node doesn't have an execution URL" )
134144 }
135145 return g .ExternalExecutionURL
136146}
137147
148+ // GetInternalHttpUrl returns the internal HTTP URL of the Besu client.
149+ // This URL is essential for establishing communication with the Besu node in a private network setup.
138150func (g * Besu ) GetInternalHttpUrl () string {
139151 return g .InternalHttpUrl
140152}
141153
154+ // GetInternalWsUrl returns the internal WebSocket URL for the Besu client.
155+ // This URL is essential for establishing WebSocket connections to the Besu node for real-time data and event subscriptions.
142156func (g * Besu ) GetInternalWsUrl () string {
143157 return g .InternalWsUrl
144158}
145159
160+ // GetExternalHttpUrl returns the external HTTP URL of the Besu client.
161+ // This URL is used to interact with the Besu node from external applications or services.
146162func (g * Besu ) GetExternalHttpUrl () string {
147163 return g .ExternalHttpUrl
148164}
149165
166+ // GetExternalWsUrl returns the external WebSocket URL for the Besu client.
167+ // This URL is essential for connecting to the Besu node from external services or clients.
150168func (g * Besu ) GetExternalWsUrl () string {
151169 return g .ExternalWsUrl
152170}
153171
172+ // GetContainerName returns the name of the container associated with the Besu instance.
173+ // This function is useful for identifying and managing the container in a Docker environment.
154174func (g * Besu ) GetContainerName () string {
155175 return g .ContainerName
156176}
157177
178+ // GetContainer returns a pointer to the container associated with the Besu instance.
179+ // This function is useful for accessing the container's properties and methods in other operations.
158180func (g * Besu ) GetContainer () * tc.Container {
159181 return & g .Container
160182}
161183
184+ // GetEthereumVersion returns the current Ethereum version of the Besu instance.
185+ // This information is crucial for determining the appropriate container configuration and consensus mechanism.
162186func (g * Besu ) GetEthereumVersion () config_types.EthereumVersion {
163187 return g .ethereumVersion
164188}
165189
190+ // WaitUntilChainIsReady blocks until the Ethereum chain is ready for operations.
191+ // It is useful for ensuring that the execution client has fully synchronized with the network before proceeding with further actions.
166192func (g * Besu ) WaitUntilChainIsReady (ctx context.Context , waitTime time.Duration ) error {
167193 if g .GetEthereumVersion () == config_types .EthereumVersion_Eth1 {
168194 return nil
@@ -171,7 +197,10 @@ func (g *Besu) WaitUntilChainIsReady(ctx context.Context, waitTime time.Duration
171197 return waitForFirstBlock .WaitUntilReady (ctx , * g .GetContainer ())
172198}
173199
174- func (g * Besu ) GethConsensusMechanism () ConsensusMechanism {
200+ // GetConsensusMechanism returns the consensus mechanism used by the Besu instance.
201+ // It identifies whether the Ethereum version is Eth1 or not, returning either Proof of Authority (PoA)
202+ // or Proof of Stake (PoS) accordingly. This is useful for understanding the network's validation method.
203+ func (g * Besu ) GetConsensusMechanism () ConsensusMechanism {
175204 if g .GetEthereumVersion () == config_types .EthereumVersion_Eth1 {
176205 return ConsensusMechanism_PoA
177206 }
0 commit comments