-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
fa5d3bd
commit 5c9f380
Showing
6 changed files
with
256 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package common | ||
|
||
import ( | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestGetByzantineThreshold(t *testing.T) { | ||
cases := []struct { | ||
n, expected int | ||
}{ | ||
{0, 0}, | ||
{1, 0}, | ||
{2, 0}, | ||
{3, 0}, | ||
{4, 1}, | ||
{5, 1}, | ||
{6, 1}, | ||
{9, 2}, | ||
{10, 3}, | ||
// Additional cases can be added here | ||
} | ||
|
||
for _, c := range cases { | ||
got := GetByzantineThreshold(c.n) | ||
require.Equal(t, c.expected, got) | ||
} | ||
} | ||
|
||
func TestGetSuperMajorityThreshold(t *testing.T) { | ||
cases := []struct { | ||
n, expected int | ||
}{ | ||
{0, 0}, | ||
{1, 1}, | ||
{2, 2}, | ||
{3, 3}, | ||
{4, 3}, | ||
{5, 4}, | ||
{6, 5}, | ||
{9, 7}, | ||
{10, 7}, | ||
// Additional cases can be added here | ||
} | ||
|
||
for _, c := range cases { | ||
got := GetSuperMajorityThreshold(c.n) | ||
require.Equal(t, c.expected, got) | ||
} | ||
} |
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
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
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