Skip to content

Commit 168362a

Browse files
authored
There are 2 different time packages used in the work. During real work, this is the same thing, but during tests, these times move at different speeds. Because of this, in the TestRateLimitClientNumChange test for the alice part, it was sometimes assumed that this client was not there for a long time, although he was waiting for his limit. (#5455)
It's fixed now. Signed-off-by: Fedor Partanskiy <fredprtnsk@gmail.com>
1 parent dadd739 commit 168362a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

orderer/common/throttle/ratelimit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (srl *SharedRateLimiter) LimitRate(client string) {
8282
return
8383
}
8484
// Mark budget as allocated and exit
85-
cs.lastSeen.Store(time.Now())
85+
cs.lastSeen.Store(srl.Time.Now())
8686
atomic.StoreUint32(&cs.budgetUsed, 0)
8787
}
8888

@@ -114,7 +114,7 @@ func (srl *SharedRateLimiter) getOrCreateState(client string) *clientState {
114114
budget: make(chan struct{}, 1),
115115
}
116116

117-
cs.lastSeen.Store(time.Now())
117+
cs.lastSeen.Store(srl.Time.Now())
118118

119119
srl.clients[client] = cs
120120

orderer/common/throttle/ratelimit_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func TestRateLimitClientNumChange(t *testing.T) {
163163
}
164164
defer rl.Stop()
165165

166-
t.Run("", func(t *testing.T) {
166+
t.Run("client", func(t *testing.T) {
167167
start := time.Now()
168168

169169
var wg sync.WaitGroup
@@ -199,7 +199,7 @@ func TestRateLimitClientNumChange(t *testing.T) {
199199
// should have all the quota available to itself.
200200
clock.Sleep(time.Second * 2)
201201

202-
t.Run("", func(t *testing.T) {
202+
t.Run("alice", func(t *testing.T) {
203203
transactions := 10000
204204

205205
start := clock.Now()

0 commit comments

Comments
 (0)