Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/config-next/nonce-a.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"sampleratio": 1
},
"grpc": {
"maxConnectionAge": "30m",
"maxConnectionAge": "1s",
"services": {
"nonce.NonceService": {
"clientNames": [
Expand Down
2 changes: 1 addition & 1 deletion test/config-next/nonce-b.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"sampleratio": 1
},
"grpc": {
"maxConnectionAge": "30m",
"maxConnectionAge": "1s",
"services": {
"nonce.NonceService": {
"clientNames": [
Expand Down
2 changes: 1 addition & 1 deletion test/config/nonce-a.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"debugAddr": ":8111",
"grpc": {
"maxConnectionAge": "30m",
"maxConnectionAge": "1s",
"address": ":9101",
"services": {
"nonce.NonceService": {
Expand Down
2 changes: 1 addition & 1 deletion test/config/nonce-b.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"debugAddr": ":8111",
"grpc": {
"maxConnectionAge": "30m",
"maxConnectionAge": "1s",
"address": ":9101",
"services": {
"nonce.NonceService": {
Expand Down
24 changes: 24 additions & 0 deletions test/integration/nonce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ package integration

import (
"context"
"google.golang.org/protobuf/types/known/emptypb"
"testing"
"time"

"github.com/jmhodges/clock"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -46,6 +48,11 @@ func TestNonceBalancer_NoBackendMatchingPrefix(t *testing.T) {

clk := clock.New()

getNonceConn, err := bgrpc.ClientSetup(c.NotWFE.GetNonceService, tlsConfig, metrics.NoopRegisterer, clk)
test.AssertNotError(t, err, "Failed to load credentials and create gRPC connection to get nonce service")

gnc := nonce.NewGetter(getNonceConn)

redeemNonceConn, err := bgrpc.ClientSetup(c.NotWFE.RedeemNonceService, tlsConfig, metrics.NoopRegisterer, clk)
test.AssertNotError(t, err, "Failed to load credentials and create gRPC connection to redeem nonce service")
rnc := nonce.NewRedeemer(redeemNonceConn)
Expand All @@ -59,4 +66,21 @@ func TestNonceBalancer_NoBackendMatchingPrefix(t *testing.T) {
gotRPCStatus, ok := status.FromError(err)
test.Assert(t, ok, "Failed to convert error to status")
test.AssertEquals(t, gotRPCStatus, nb.ErrNoBackendsMatchPrefix)

var nonces []*noncepb.NonceMessage
for i := 0; i < 300; i++ {
nonceMsg, err := gnc.Nonce(ctx, &emptypb.Empty{})
test.AssertNotError(t, err, "getting nonce")

nonces = append(nonces, nonceMsg)
}

for _, nonceMsg := range nonces {
ctx := context.WithValue(ctx, nonce.PrefixCtxKey{}, nonceMsg.Nonce[:nonce.PrefixLen])
ctx = context.WithValue(ctx, nonce.HMACKeyCtxKey{}, rncKey)

_, err = rnc.Redeem(ctx, &noncepb.NonceMessage{Nonce: nonceMsg.Nonce})
test.AssertNotError(t, err, "redeeming nonce")
time.Sleep(10 * time.Millisecond)
}
}
Loading