-
Notifications
You must be signed in to change notification settings - Fork 140
fix(lib/babe): Unrestricted Loop When Building Blocks (GSR-19) #2632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
edwardmack
merged 34 commits into
development
from
ed/unrestricted_loop_building_blocks_GSR-19
Oct 6, 2022
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
fdaadd6
add test, add time.Sleep in loop
edwardmack f2f05ed
add copyright notice
edwardmack e431b70
Channel based notification for queue Push
qdm12 a45be38
trying to add channel closed check
edwardmack 4ef5e81
add check when creating channel
edwardmack 4c70d07
add check in Push func to check channel status
edwardmack 02522a8
address lint issues
edwardmack 7c1add4
refactor test with nil pop result
edwardmack 046eb19
WIP, trying to make cancel channel for ticker
edwardmack bf7b414
address PR comments
edwardmack 4c336e2
formatting, remove newline
edwardmack 1121a3f
WIP: add to tests
edwardmack 5837992
wip
qdm12 d0e52d3
add to tests to increase coverage
edwardmack 35b8e1b
add check for closed channel
edwardmack f2321b4
remove nil assignment
edwardmack cf05044
remove flacky build unit tests, handled by integration tests
edwardmack 2fe32fe
remove test time channel, add intergration test
edwardmack ded3520
WIP - refactor test
edwardmack 4b2343e
updated integration test, increase coverage
edwardmack ce546cf
WIP - implement transactionState.PopChannel
edwardmack 6d96206
WIP - stub PopChannel2
edwardmack cf69b05
refactor use of pop channel
edwardmack 0ba0ae5
address linter issues, remove commented lines
edwardmack d4c6bd6
remove unused var
edwardmack 792253a
add sleep to pop channel func
edwardmack 673a395
refactor test to confirm priority
edwardmack 7808743
re-generate mocks
edwardmack ee3664b
introduce pop func to use pollTimer
edwardmack 68195bc
`PopChannel` -> `PopWithTimer`
qdm12 273258f
regenerate mocks
edwardmack c4ef178
add pop check, update pop with timer tests
edwardmack 438e4ca
pass time.Time channel to PopWithTimer, move test
edwardmack 9eb8833
regenrate mocks
edwardmack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2021 ChainSafe Systems (ON) | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
//go:build integration | ||
|
||
package transaction | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_PopWithTimer(t *testing.T) { | ||
pq := NewPriorityQueue() | ||
slotTimer := time.NewTimer(time.Second) | ||
|
||
tests := []*ValidTransaction{ | ||
{ | ||
Extrinsic: []byte("a"), | ||
Validity: &Validity{Priority: 1}, | ||
}, | ||
{ | ||
Extrinsic: []byte("b"), | ||
Validity: &Validity{Priority: 4}, | ||
}, | ||
{ | ||
Extrinsic: []byte("c"), | ||
Validity: &Validity{Priority: 2}, | ||
}, | ||
{ | ||
Extrinsic: []byte("d"), | ||
Validity: &Validity{Priority: 17}, | ||
}, | ||
{ | ||
Extrinsic: []byte("e"), | ||
Validity: &Validity{Priority: 2}, | ||
}, | ||
} | ||
|
||
expected := []int{3, 1, 2, 4, 0} | ||
|
||
for _, test := range tests { | ||
pq.Push(test) | ||
} | ||
|
||
counter := 0 | ||
for { | ||
txn := pq.PopWithTimer(slotTimer.C) | ||
if txn == nil { | ||
break | ||
} | ||
assert.Equal(t, tests[expected[counter]], txn) | ||
counter++ | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.