Skip to content

Commit 3c696ee

Browse files
fix tests
1 parent 3301dd6 commit 3c696ee

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

pkg/billing/workflow_client_test.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"google.golang.org/grpc/credentials/insecure"
1919
"google.golang.org/grpc/metadata"
2020

21-
pb "github.com/smartcontractkit/chainlink-protos/billing/go"
2221
"github.com/smartcontractkit/chainlink-common/pkg/logger"
22+
pb "github.com/smartcontractkit/chainlink-protos/billing/go"
2323
)
2424

2525
// ---------- Test Server Implementation ----------
@@ -162,15 +162,20 @@ func TestIntegration_GRPC_Insecure(t *testing.T) {
162162
defer grpcServer.Stop()
163163

164164
addr := lis.Addr().String()
165-
166165
lggr := logger.Test(t)
166+
167167
wc, err := NewWorkflowClient(addr,
168168
WithWorkflowTransportCredentials(insecure.NewCredentials()),
169169
WithWorkflowLogger(lggr),
170170
WithServerName("localhost"),
171171
)
172+
173+
assert.NoError(t, err)
174+
assert.NotNil(t, wc)
175+
176+
_, err = wc.ConsumeCredits(t.Context(), nil)
177+
172178
require.Error(t, err)
173-
assert.Nil(t, wc)
174179
}
175180

176181
// Test that CanonicalStringFromRequest returns the correct string.
@@ -275,11 +280,17 @@ func TestWorkflowClient_CustomAuthHeader(t *testing.T) {
275280
// Test that NewWorkflowClient fails when given an invalid address.
276281
func TestNewWorkflowClient_InvalidAddress(t *testing.T) {
277282
lggr := logger.Test(t)
278-
_, err := NewWorkflowClient("invalid-address",
283+
wc, err := NewWorkflowClient("invalid-address",
279284
WithWorkflowTransportCredentials(insecure.NewCredentials()),
280285
WithWorkflowLogger(lggr),
281286
WithServerName("localhost"),
282287
)
288+
289+
require.NotNil(t, wc)
290+
require.NoError(t, err)
291+
292+
_, err = wc.ConsumeCredits(t.Context(), nil)
293+
283294
require.Error(t, err, "Expected error when dialing an invalid address")
284295
}
285296

@@ -337,10 +348,16 @@ func TestWorkflowClient_RepeatedSign(t *testing.T) {
337348
func TestWorkflowClient_DialUnreachable(t *testing.T) {
338349
lggr := logger.Test(t)
339350
unreachableAddr := "192.0.2.1:12345" // Reserved for documentation.
340-
_, err := NewWorkflowClient(unreachableAddr,
351+
wc, err := NewWorkflowClient(unreachableAddr,
341352
WithWorkflowTransportCredentials(insecure.NewCredentials()),
342353
WithWorkflowLogger(lggr),
343354
WithServerName("localhost"),
344355
)
356+
357+
require.NotNil(t, wc)
358+
require.NoError(t, err)
359+
360+
_, err = wc.ConsumeCredits(t.Context(), nil)
361+
345362
require.Error(t, err, "Expected dialing an unreachable address to fail")
346363
}

0 commit comments

Comments
 (0)