Skip to content
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

adapt integration tests for consensus v2 #6685

Draft
wants to merge 4 commits into
base: feat/equivalent-messages
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 58 additions & 35 deletions integrationTests/consensus/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,39 @@
log = logger.GetOrCreate("integrationtests/consensus")
)

func encodeAddress(address []byte) string {
return hex.EncodeToString(address)
func TestConsensusBLSFullTestSingleKeys(t *testing.T) {
if testing.Short() {
t.Skip("this is not a short test")
}

runFullConsensusTest(t, blsConsensusType, 1, false)
}

func getPkEncoded(pubKey crypto.PublicKey) string {
pk, err := pubKey.ToByteArray()
if err != nil {
return err.Error()
func TestConsensusBLSFullTestMultiKeys(t *testing.T) {
if testing.Short() {
t.Skip("this is not a short test")
}

return encodeAddress(pk)
runFullConsensusTest(t, blsConsensusType, 5, false)
}

func TestConsensusBLSFullTestSingleKeys_WithEquivalentProofs(t *testing.T) {
if testing.Short() {
t.Skip("this is not a short test")
}

logger.ToggleLoggerName(true)
logger.SetLogLevel("*:DEBUG,consensus:TRACE")

Check failure on line 57 in integrationTests/consensus/consensus_test.go

View workflow job for this annotation

GitHub Actions / golangci linter

Error return value of `logger.SetLogLevel` is not checked (errcheck)

runFullConsensusTest(t, blsConsensusType, 1, true)
}

func TestConsensusBLSNotEnoughValidators(t *testing.T) {
if testing.Short() {
t.Skip("this is not a short test")
}

runConsensusWithNotEnoughValidators(t, blsConsensusType)
}

func initNodesAndTest(
Expand Down Expand Up @@ -218,10 +240,15 @@
}
}

func runFullConsensusTest(t *testing.T, consensusType string, numKeysOnEachNode int) {
func runFullConsensusTest(
t *testing.T,
consensusType string,
numKeysOnEachNode int,
withEquivalentProofs bool,
) {
numMetaNodes := uint32(4)
numNodes := uint32(4)
consensusSize := uint32(4 * numKeysOnEachNode)
consensusSize := uint32(3 * numKeysOnEachNode)
numInvalid := uint32(0)
roundTime := uint64(1000)
numCommBlock := uint64(8)
Expand All @@ -233,8 +260,15 @@
)

enableEpochsConfig := integrationTests.CreateEnableEpochsConfig()
enableEpochsConfig.EquivalentMessagesEnableEpoch = integrationTests.UnreachableEpoch
enableEpochsConfig.FixedOrderInConsensusEnableEpoch = integrationTests.UnreachableEpoch

equivalentProodsActivationEpoch := integrationTests.UnreachableEpoch
if withEquivalentProofs {
equivalentProodsActivationEpoch = 0
}

enableEpochsConfig.EquivalentMessagesEnableEpoch = equivalentProodsActivationEpoch
enableEpochsConfig.FixedOrderInConsensusEnableEpoch = equivalentProodsActivationEpoch

nodes := initNodesAndTest(
numMetaNodes,
numNodes,
Expand Down Expand Up @@ -285,22 +319,6 @@
}
}

func TestConsensusBLSFullTestSingleKeys(t *testing.T) {
if testing.Short() {
t.Skip("this is not a short test")
}

runFullConsensusTest(t, blsConsensusType, 1)
}

func TestConsensusBLSFullTestMultiKeys(t *testing.T) {
if testing.Short() {
t.Skip("this is not a short test")
}

runFullConsensusTest(t, blsConsensusType, 5)
}

func runConsensusWithNotEnoughValidators(t *testing.T, consensusType string) {
numMetaNodes := uint32(4)
numNodes := uint32(4)
Expand Down Expand Up @@ -343,14 +361,6 @@
}
}

func TestConsensusBLSNotEnoughValidators(t *testing.T) {
if testing.Short() {
t.Skip("this is not a short test")
}

runConsensusWithNotEnoughValidators(t, blsConsensusType)
}

func displayAndStartNodes(shardID uint32, nodes []*integrationTests.TestConsensusNode) {
for _, n := range nodes {
skBuff, _ := n.NodeKeys.Sk.ToByteArray()
Expand All @@ -365,3 +375,16 @@
)
}
}

func encodeAddress(address []byte) string {
return hex.EncodeToString(address)
}

func getPkEncoded(pubKey crypto.PublicKey) string {
pk, err := pubKey.ToByteArray()
if err != nil {
return err.Error()
}

return encodeAddress(pk)
}
Loading
Loading