Skip to content

Commit 718259a

Browse files
Addressing comments
1 parent f4ec6cd commit 718259a

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

ratelimits/limiter_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func setup(t *testing.T) (context.Context, map[string]*Limiter, *TransactionBuil
5959
}, newTestTransactionBuilder(t), clk, randIP.String()
6060
}
6161

62-
func mustReset(t *testing.T, l *Limiter, ctx context.Context, limit *Limit, bucketKey string) {
62+
func resetBucket(t *testing.T, l *Limiter, ctx context.Context, limit *Limit, bucketKey string) {
6363
t.Helper()
6464
txn, err := newResetTransaction(limit, bucketKey)
6565
test.AssertNotError(t, err, "txn should be valid")
@@ -161,8 +161,8 @@ func TestLimiter_CheckWithLimitOverrides(t *testing.T) {
161161
test.AssertEquals(t, d.resetIn, time.Millisecond*50)
162162

163163
// Reset between tests.
164-
mustReset(t, l, testCtx, overriddenLimit, overriddenBucketKey)
165-
mustReset(t, l, testCtx, normalLimit, normalBucketKey)
164+
resetBucket(t, l, testCtx, overriddenLimit, overriddenBucketKey)
165+
resetBucket(t, l, testCtx, normalLimit, normalBucketKey)
166166

167167
// Spend the same bucket but in a batch with a Transaction that is
168168
// check-only. This should succeed, but the decision should reflect
@@ -244,7 +244,7 @@ func TestLimiter_CheckWithLimitOverrides(t *testing.T) {
244244
test.AssertEquals(t, d.resetIn, time.Millisecond*50)
245245

246246
// Reset between tests.
247-
mustReset(t, l, testCtx, overriddenLimit, overriddenBucketKey)
247+
resetBucket(t, l, testCtx, overriddenLimit, overriddenBucketKey)
248248
})
249249
}
250250
}
@@ -283,7 +283,7 @@ func TestLimiter_InitializationViaCheckAndSpend(t *testing.T) {
283283
test.AssertEquals(t, d.retryIn, time.Duration(0))
284284

285285
// Reset our bucket.
286-
mustReset(t, l, testCtx, limit, bucketKey)
286+
resetBucket(t, l, testCtx, limit, bucketKey)
287287

288288
// Similar to above, but we'll use Spend() to actually initialize
289289
// the bucket. Spend should return the same result as Check.
@@ -404,7 +404,7 @@ func TestLimiter_RefundAndReset(t *testing.T) {
404404
test.AssertEquals(t, d.remaining, int64(0))
405405
test.AssertEquals(t, d.resetIn, time.Second)
406406

407-
mustReset(t, l, testCtx, limit, bucketKey)
407+
resetBucket(t, l, testCtx, limit, bucketKey)
408408

409409
// Attempt to spend 20 more requests, this should succeed.
410410
d, err = l.Spend(testCtx, txn20)

ratelimits/source_redis.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,6 @@ func (r *RedisSource) BatchDelete(ctx context.Context, bucketKeys []string) erro
242242
return nil
243243
}
244244

245-
// Delete deletes the TAT at the specified bucketKey ('name:id'). A nil return
246-
// value does not indicate that the bucketKey existed.
247-
func (r *RedisSource) Delete(ctx context.Context, bucketKey string) error {
248-
return r.BatchDelete(ctx, []string{bucketKey})
249-
}
250-
251245
// Ping checks that each shard of the *redis.Ring is reachable using the PING
252246
// command.
253247
func (r *RedisSource) Ping(ctx context.Context) error {

ratelimits/transaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ func newFQDNSetBucketKey(name Name, orderIdents identifier.ACMEIdentifiers) stri
7676
// bucket's capacity, but will never be spent/refunded.
7777
// - spend-only: when only spend is true, spending is best-effort. Regardless
7878
// of the bucket's capacity, the transaction will be considered "allowed".
79+
// - reset-only: when reset is true, the bucket will be reset to full capacity.
7980
// - allow-only: when neither check nor spend are true, the transaction will
8081
// be considered "allowed" regardless of the bucket's capacity. This is
8182
// useful for limits that are disabled.
82-
// - reset: when reset is true, the bucket will be reset to full capacity.
8383
//
8484
// The zero value of Transaction is an allow-only transaction and is valid even if
8585
// it would fail validateTransaction (for instance because cost and burst are zero).

0 commit comments

Comments
 (0)