-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Coordination window borderline blocks
Here we add two methods to the `coordinationWindow` type: The `activePhaseEndBlock` denotes the end block of the active communication phase and will be used to complete communication in the right moment. The `endBlock` denotes the end block of the whole window and will be used to complete the coordination procedure.
- Loading branch information
1 parent
cba7d03
commit ef27aea
Showing
2 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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,61 @@ | ||
package tbtc | ||
|
||
import ( | ||
"github.com/keep-network/keep-core/internal/testutils" | ||
"testing" | ||
) | ||
|
||
func TestCoordinationWindow_ActivePhaseEndBlock(t *testing.T) { | ||
window := newCoordinationWindow(900) | ||
|
||
testutils.AssertIntsEqual( | ||
t, | ||
"active phase end block", | ||
980, | ||
int(window.activePhaseEndBlock()), | ||
) | ||
} | ||
|
||
func TestCoordinationWindow_EndBlock(t *testing.T) { | ||
window := newCoordinationWindow(900) | ||
|
||
testutils.AssertIntsEqual( | ||
t, | ||
"end block", | ||
1000, | ||
int(window.endBlock()), | ||
) | ||
} | ||
|
||
func TestCoordinationWindow_IsAfterActivePhase(t *testing.T) { | ||
window := newCoordinationWindow(1800) | ||
|
||
previousWindow := newCoordinationWindow(900) | ||
sameWindow := newCoordinationWindow(1800) | ||
nextWindow := newCoordinationWindow(2700) | ||
|
||
testutils.AssertBoolsEqual( | ||
t, | ||
"result for nil", | ||
true, | ||
window.isAfter(nil), | ||
) | ||
testutils.AssertBoolsEqual( | ||
t, | ||
"result for previous window", | ||
true, | ||
window.isAfter(previousWindow), | ||
) | ||
testutils.AssertBoolsEqual( | ||
t, | ||
"result for same window", | ||
false, | ||
window.isAfter(sameWindow), | ||
) | ||
testutils.AssertBoolsEqual( | ||
t, | ||
"result for next window", | ||
false, | ||
window.isAfter(nextWindow), | ||
) | ||
} |