Skip to content

Commit 81cd1cb

Browse files
committed
apply review feedback
1 parent b545af3 commit 81cd1cb

File tree

10 files changed

+27
-23
lines changed

10 files changed

+27
-23
lines changed

integration/localnet/bootstrap.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const (
3030
DockerComposeFile = "./docker-compose.nodes.yml"
3131
DockerComposeFileVersion = "3.7"
3232
PrometheusTargetsFile = "./targets.nodes.json"
33-
DefaultAccessGatewayName = "access_1"
3433
DefaultObserverName = "observer"
3534
DefaultLogLevel = "DEBUG"
3635
DefaultGOMAXPROCS = 8
@@ -468,9 +467,9 @@ func prepareObserverService(i int, observerName string, agPublicKey string) Serv
468467

469468
observerService := defaultService(DefaultObserverName, dataDir, profilerDir, i)
470469
observerService.Command = append(observerService.Command,
471-
fmt.Sprintf("--bootstrap-node-addresses=%s:%d", DefaultAccessGatewayName, AccessPubNetworkPort),
470+
fmt.Sprintf("--bootstrap-node-addresses=%s:%d", testnet.PrimaryAN, AccessPubNetworkPort),
472471
fmt.Sprintf("--bootstrap-node-public-keys=%s", agPublicKey),
473-
fmt.Sprintf("--upstream-node-addresses=%s:%d", DefaultAccessGatewayName, SecuredRPCPort),
472+
fmt.Sprintf("--upstream-node-addresses=%s:%d", testnet.PrimaryAN, SecuredRPCPort),
474473
fmt.Sprintf("--upstream-node-public-keys=%s", agPublicKey),
475474
fmt.Sprintf("--observer-networking-key-path=/bootstrap/private-root-information/%s_key", observerName),
476475
"--bind=0.0.0.0:0",
@@ -480,7 +479,7 @@ func prepareObserverService(i int, observerName string, agPublicKey string) Serv
480479
)
481480

482481
// observer services rely on the access gateway
483-
observerService.DependsOn = append(observerService.DependsOn, DefaultAccessGatewayName)
482+
observerService.DependsOn = append(observerService.DependsOn, testnet.PrimaryAN)
484483
observerService.Ports = []string{
485484
// Flow API ports come in pairs, open and secure. While the guest port is always
486485
// the same from the guest's perspective, the host port numbering accounts for the presence
@@ -643,12 +642,12 @@ func openAndTruncate(filename string) (*os.File, error) {
643642

644643
func getAccessGatewayPublicKey(flowNodeContainerConfigs []testnet.ContainerConfig) (string, error) {
645644
for _, container := range flowNodeContainerConfigs {
646-
if container.ContainerName == DefaultAccessGatewayName {
645+
if container.ContainerName == testnet.PrimaryAN {
647646
// remove the "0x"..0000 portion of the key
648647
return container.NetworkPubKey().String()[2:], nil
649648
}
650649
}
651-
return "", fmt.Errorf("Unable to find public key for Access Gateway expected in container '%s'", DefaultAccessGatewayName)
650+
return "", fmt.Errorf("Unable to find public key for Access Gateway expected in container '%s'", testnet.PrimaryAN)
652651
}
653652

654653
func prepareObserverServices(dockerServices Services, flowNodeContainerConfigs []testnet.ContainerConfig) Services {
@@ -685,7 +684,7 @@ func prepareObserverServices(dockerServices Services, flowNodeContainerConfigs [
685684
}
686685
fmt.Println()
687686
fmt.Println("Observer services bootstrapping data generated...")
688-
fmt.Printf("Access Gateway (%s) public network libp2p key: %s\n\n", DefaultAccessGatewayName, agPublicKey)
687+
fmt.Printf("Access Gateway (%s) public network libp2p key: %s\n\n", testnet.PrimaryAN, agPublicKey)
689688

690689
return dockerServices
691690
}

integration/testnet/network.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ const (
9797
// DefaultFlowPort default gossip network port
9898
DefaultFlowPort = 2137
9999

100+
// PrimaryAN is the container name for the primary access node to use for API requests
101+
PrimaryAN = "access_1"
102+
100103
DefaultViewsInStakingAuction uint64 = 5
101104
DefaultViewsInDKGPhase uint64 = 50
102105
DefaultViewsInEpoch uint64 = 180
@@ -643,7 +646,7 @@ type ObserverConfig struct {
643646

644647
func (net *FlowNetwork) addObserver(t *testing.T, conf ObserverConfig) {
645648
if conf.BootstrapAccessName == "" {
646-
conf.BootstrapAccessName = "access_1"
649+
conf.BootstrapAccessName = PrimaryAN
647650
}
648651

649652
// Setup directories

integration/tests/access/access_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (s *AccessSuite) SetupTest() {
8989
func (s *AccessSuite) TestAPIsAvailable() {
9090

9191
s.T().Run("TestHTTPProxyPortOpen", func(t *testing.T) {
92-
httpProxyAddress := s.net.ContainerByName("access_1").Addr(testnet.GRPCWebPort)
92+
httpProxyAddress := s.net.ContainerByName(testnet.PrimaryAN).Addr(testnet.GRPCWebPort)
9393

9494
conn, err := net.DialTimeout("tcp", httpProxyAddress, 1*time.Second)
9595
require.NoError(s.T(), err, "http proxy port not open on the access node")
@@ -101,7 +101,7 @@ func (s *AccessSuite) TestAPIsAvailable() {
101101
ctx, cancel := context.WithTimeout(s.ctx, 1*time.Second)
102102
defer cancel()
103103

104-
grpcAddress := s.net.ContainerByName("access_1").Addr(testnet.GRPCPort)
104+
grpcAddress := s.net.ContainerByName(testnet.PrimaryAN).Addr(testnet.GRPCPort)
105105
conn, err := grpc.DialContext(ctx, grpcAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
106106
require.NoError(t, err, "failed to connect to access node")
107107
defer conn.Close()

integration/tests/access/observer_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ type ObserverSuite struct {
3535
func (s *ObserverSuite) TearDownTest() {
3636
if s.net != nil {
3737
s.net.Remove()
38+
s.net = nil
3839
}
3940
if s.cancel != nil {
4041
s.cancel()
42+
s.cancel = nil
4143
}
4244
}
4345

@@ -121,7 +123,7 @@ func (s *ObserverSuite) TestObserver() {
121123
})
122124

123125
// stop the upstream access container
124-
err = s.net.StopContainerByName(ctx, "access_1")
126+
err = s.net.StopContainerByName(ctx, testnet.PrimaryAN)
125127
require.NoError(t, err)
126128

127129
t.Run("HandledByUpstream", func(t *testing.T) {
@@ -156,7 +158,7 @@ func (s *ObserverSuite) TestObserver() {
156158
}
157159

158160
func (s *ObserverSuite) getAccessClient() (accessproto.AccessAPIClient, error) {
159-
return s.getClient(s.net.ContainerByName("access_1").Addr(testnet.GRPCPort))
161+
return s.getClient(s.net.ContainerByName(testnet.PrimaryAN).Addr(testnet.GRPCPort))
160162
}
161163

162164
func (s *ObserverSuite) getObserverClient() (accessproto.AccessAPIClient, error) {

integration/tests/admin/command_runner_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,13 @@ func (suite *CommandRunnerSuite) TestTLS() {
462462

463463
suite.SetupCommandRunner(admin.WithTLS(serverConfig))
464464

465-
c := &http.Client{
465+
httpClient := &http.Client{
466466
Transport: &http.Transport{
467467
TLSClientConfig: clientConfig,
468468
},
469469
}
470470

471-
adminClient := client.NewAdminClient(suite.httpAddress, client.WithTLS(true), client.WithHTTPClient(c))
471+
adminClient := client.NewAdminClient(suite.httpAddress, client.WithTLS(true), client.WithHTTPClient(httpClient))
472472

473473
data := map[string]interface{}{"key": "value"}
474474
resp, err := adminClient.RunCommand(context.Background(), "foo", data)

integration/tests/bft/base_suite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (b *BaseSuite) Ghost() *client.GhostClient {
4040

4141
// AccessClient returns a client to interact with the access node api on testnet.
4242
func (b *BaseSuite) AccessClient() *testnet.Client {
43-
client, err := b.Net.ContainerByName("access_1").TestnetClient()
43+
client, err := b.Net.ContainerByName(testnet.PrimaryAN).TestnetClient()
4444
require.NoError(b.T(), err, "could not get access client")
4545
return client
4646
}

integration/tests/epochs/suite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (s *Suite) SetupTest() {
113113
s.Track(s.T(), s.ctx, s.Ghost())
114114

115115
// use AN1 for test-related queries - the AN join/leave test will replace AN2
116-
client, err := s.net.ContainerByName("access_1").TestnetClient()
116+
client, err := s.net.ContainerByName(testnet.PrimaryAN).TestnetClient()
117117
require.NoError(s.T(), err)
118118

119119
s.client = client

integration/tests/execution/suite.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (s *Suite) Ghost() *client.GhostClient {
3838
}
3939

4040
func (s *Suite) AccessClient() *testnet.Client {
41-
client, err := s.net.ContainerByName("access_1").TestnetClient()
41+
client, err := s.net.ContainerByName(testnet.PrimaryAN).TestnetClient()
4242
require.NoError(s.T(), err, "could not get access client")
4343
return client
4444
}
@@ -94,7 +94,7 @@ func (s *Suite) SendExecutionAdminCommand(ctx context.Context, command string, d
9494
}
9595

9696
func (s *Suite) AccessPort() string {
97-
return s.net.ContainerByName("access_1").Port(testnet.GRPCPort)
97+
return s.net.ContainerByName(testnet.PrimaryAN).Port(testnet.GRPCPort)
9898
}
9999

100100
func (s *Suite) MetricsPort() string {

integration/tests/mvp/mvp_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestMVP_Bootstrap(t *testing.T) {
6565

6666
flowNetwork.Start(ctx)
6767

68-
client, err := flowNetwork.ContainerByName("access_1").TestnetClient()
68+
client, err := flowNetwork.ContainerByName(testnet.PrimaryAN).TestnetClient()
6969
require.NoError(t, err)
7070

7171
t.Log("@@ running mvp test 1")
@@ -144,7 +144,7 @@ func runMVPTest(t *testing.T, ctx context.Context, net *testnet.FlowNetwork) {
144144

145145
chain := net.Root().Header.ChainID.Chain()
146146

147-
serviceAccountClient, err := net.ContainerByName("access_1").TestnetClient()
147+
serviceAccountClient, err := net.ContainerByName(testnet.PrimaryAN).TestnetClient()
148148
require.NoError(t, err)
149149

150150
latestBlockID, err := serviceAccountClient.GetLatestBlockID(ctx)
@@ -245,7 +245,7 @@ func runMVPTest(t *testing.T, ctx context.Context, net *testnet.FlowNetwork) {
245245
t.Log(fundCreationTxRes)
246246

247247
accountClient, err := testnet.NewClientWithKey(
248-
net.ContainerByName("access_1").Addr(testnet.GRPCPort),
248+
net.ContainerByName(testnet.PrimaryAN).Addr(testnet.GRPCPort),
249249
newAccountAddress,
250250
accountPrivateKey,
251251
chain,

integration/tests/verification/suite.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ func (s *Suite) Ghost() *client.GhostClient {
4141

4242
// AccessClient returns a client to interact with the access node api on testnet.
4343
func (s *Suite) AccessClient() *testnet.Client {
44-
client, err := s.net.ContainerByName("access_1").TestnetClient()
44+
client, err := s.net.ContainerByName(testnet.PrimaryAN).TestnetClient()
4545
require.NoError(s.T(), err, "could not get access client")
4646
return client
4747
}
4848

4949
// AccessPort returns the port number of access node api on testnet.
5050
func (s *Suite) AccessPort() string {
51-
return s.net.ContainerByName("access_1").Port(testnet.GRPCPort)
51+
return s.net.ContainerByName(testnet.PrimaryAN).Port(testnet.GRPCPort)
5252
}
5353

5454
func (s *Suite) MetricsPort() string {

0 commit comments

Comments
 (0)