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

Yahya/5005-fix-flakey-libp2p-test #99

Merged
merged 41 commits into from Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c7f603a
fixes peer manager non-blocking start
yhassanzadeh13 Oct 27, 2020
ddc375f
fixes peer manager assertion issue
yhassanzadeh13 Oct 27, 2020
d1f92e9
adds RequireConcurrentCallsReturnBefore
yhassanzadeh13 Oct 27, 2020
236baf2
refactors logs at debug level
yhassanzadeh13 Oct 27, 2020
e807c5b
fixes wait group negative count issue
yhassanzadeh13 Oct 27, 2020
d8800f7
adds error level logs
yhassanzadeh13 Oct 28, 2020
c54dc5e
Merge remote-tracking branch 'origin/master' into yahya/5005-fix-flak…
yhassanzadeh13 Oct 28, 2020
3e74856
adds free port function
yhassanzadeh13 Oct 28, 2020
cf8f6db
fixes libp2p tests
yhassanzadeh13 Oct 28, 2020
e0d6e9b
refactors unnecessary suite nested calls
yhassanzadeh13 Oct 28, 2020
b3b9441
adds more unittest utils
yhassanzadeh13 Oct 28, 2020
3b4cb6d
simplifies some tests
yhassanzadeh13 Oct 28, 2020
c4a6de8
adjusts timeouts
yhassanzadeh13 Oct 28, 2020
af9e5d6
fixes TestConcurrentOnDemandPeerUpdate
yhassanzadeh13 Oct 28, 2020
b4fe909
Update network/gossip/libp2p/libp2pNode_test.go
yhassanzadeh13 Oct 28, 2020
fe48531
Update network/gossip/libp2p/libp2pNode_test.go
yhassanzadeh13 Oct 28, 2020
553b5be
Update network/gossip/libp2p/peerManager.go
yhassanzadeh13 Oct 28, 2020
57aa665
fixes lint issues
yhassanzadeh13 Oct 28, 2020
dbc419f
makes allocated ports concurrency safe
yhassanzadeh13 Oct 28, 2020
7a87076
Update network/gossip/libp2p/libp2pNode_test.go
yhassanzadeh13 Oct 28, 2020
cc27eb3
fixes deferring closing streams
yhassanzadeh13 Oct 28, 2020
0572633
Merge remote-tracking branch 'origin/yahya/5005-fix-flakey-libp2p-tes…
yhassanzadeh13 Oct 28, 2020
ae48d42
fixes TestConcurrentOnDemandPeerUpdate
yhassanzadeh13 Oct 28, 2020
4ba7992
fixes log issue
yhassanzadeh13 Oct 28, 2020
7f73b52
adds error assertion
yhassanzadeh13 Oct 28, 2020
2beb7bf
fixes failure issue
yhassanzadeh13 Oct 28, 2020
976fd27
fixes lint issue
yhassanzadeh13 Oct 28, 2020
50dc9ab
fixes unittest error
yhassanzadeh13 Oct 28, 2020
431ede2
Update network/gossip/libp2p/peerManager_test.go
yhassanzadeh13 Oct 29, 2020
93b0f1b
Update network/gossip/libp2p/test/testUtil.go
yhassanzadeh13 Oct 29, 2020
24a8840
encapsulates port allocator test helper
yhassanzadeh13 Oct 29, 2020
9e2fc91
Merge remote-tracking branch 'origin/yahya/5005-fix-flakey-libp2p-tes…
yhassanzadeh13 Oct 29, 2020
cc4fad9
fixes concurrent access on mock run method
yhassanzadeh13 Oct 29, 2020
0305d6a
Merge remote-tracking branch 'origin/master' into yahya/5005-fix-flak…
yhassanzadeh13 Oct 29, 2020
c294613
updates peer manager with ready done aware
yhassanzadeh13 Oct 30, 2020
0eac3ad
Merge remote-tracking branch 'origin/master' into yahya/5005-fix-flak…
yhassanzadeh13 Oct 30, 2020
e32feea
updates go mod
yhassanzadeh13 Oct 30, 2020
dc96082
fixes small commented code
yhassanzadeh13 Oct 30, 2020
2dea2f8
fixes comments
yhassanzadeh13 Oct 30, 2020
14e5a0b
adds require return before
yhassanzadeh13 Oct 30, 2020
43390c6
Merge remote-tracking branch 'origin/master' into yahya/5005-fix-flak…
yhassanzadeh13 Oct 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 7 additions & 9 deletions crypto/bls_test.go
Expand Up @@ -128,7 +128,7 @@ func TestAggregateSignatures(t *testing.T) {
sks := make([]PrivateKey, 0, sigsNum)
pks := make([]PublicKey, 0, sigsNum)
seed := make([]byte, KeyGenSeedMinLenBLSBLS12381)
var aggSig,expectedSig Signature
var aggSig, expectedSig Signature

// create the signatures
for i := 0; i < sigsNum; i++ {
Expand Down Expand Up @@ -161,7 +161,6 @@ func TestAggregateSignatures(t *testing.T) {
fmt.Sprintf("Verification of %s failed, signature should be %s private keys are %s, input is %x",
aggSig, expectedSig, sks, input))
})


// check if one the signatures is not correct
t.Run("one invalid signatures", func(t *testing.T) {
Expand All @@ -182,7 +181,6 @@ func TestAggregateSignatures(t *testing.T) {
sigs[randomIndex], err = sks[randomIndex].Sign(input, kmac)
})


// check if one the public keys is not correct
t.Run("one invalid public key", func(t *testing.T) {
randomIndex := mrand.Intn(sigsNum)
Expand Down Expand Up @@ -390,10 +388,10 @@ func TestBatchVerify(t *testing.T) {
})

// pick a random number of invalid signatures
invalidSigsNum := mrand.Intn(sigsNum-1) + 1
// generate a random permutation of indices to pick the
invalidSigsNum := mrand.Intn(sigsNum-1) + 1
// generate a random permutation of indices to pick the
// invalid signatures.
indices := make([]int, 0, sigsNum)
indices := make([]int, 0, sigsNum)
for i := 0; i < sigsNum; i++ {
indices = append(indices, i)
}
Expand Down Expand Up @@ -425,7 +423,7 @@ func TestBatchVerify(t *testing.T) {
sigs[indices[i]] = sigs[indices[i]][:3] // test the short signatures
}
}

valid, err := BatchVerifySignaturesOneMessage(pks, sigs, input, kmac)
require.NoError(t, err)
assert.Equal(t, valid, expectedValid,
Expand Down Expand Up @@ -456,7 +454,7 @@ func TestBatchVerify(t *testing.T) {
}
valid, err := BatchVerifySignaturesOneMessage(pks, sigs, input, nil)
require.Error(t, err)

assert.Equal(t, valid, expectedValid,
fmt.Sprintf("verification should fail with incorrect input lenghts, got %v", valid))
})
Expand Down Expand Up @@ -509,7 +507,7 @@ func BenchmarkBatchVerify(b *testing.B) {
// - if all signatures are invalid (valid points in G1):
// (2*2*(n-1)) pairings compared to (2*n) pairings for the simple verification.
b.Run("unhappy path", func(b *testing.B) {
// only one invalid signature
// only one invalid signature
alterSignature(sigs[sigsNum/2])
b.ResetTimer()
for i := 0; i < b.N; i++ {
Expand Down
20 changes: 10 additions & 10 deletions crypto/sign_test_utils.go
Expand Up @@ -34,13 +34,13 @@ func testGenSignVerify(t *testing.T, salg SigningAlgorithm, halg hash.Hasher) {
s, err := sk.Sign(input, halg)
require.NoError(t, err)
pk := sk.PublicKey()

// test a valid signature
result, err := pk.Verify(s, input, halg)
require.NoError(t, err)
assert.True(t, result, fmt.Sprintf(
"Verification should succeed:\n signature:%s\n message:%x\n private key:%s", s, input, sk))

// test with a different message
input[0] ^= 1
result, err = pk.Verify(s, input, halg)
Expand Down Expand Up @@ -101,16 +101,16 @@ func testEncodeDecode(t *testing.T, salg SigningAlgorithm) {

// test invalid private keys (equal to the curve group order)
groupOrder := make(map[SigningAlgorithm][]byte)
groupOrder[ECDSAP256] = []byte{255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255,
255, 255, 255, 255, 255, 188, 230, 250, 173, 167,
groupOrder[ECDSAP256] = []byte{255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255,
255, 255, 255, 255, 255, 188, 230, 250, 173, 167,
23, 158, 132, 243, 185, 202, 194, 252, 99, 37, 81}
groupOrder[ECDSASecp256k1] = []byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 254, 186, 174, 220, 230,

groupOrder[ECDSASecp256k1] = []byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 254, 186, 174, 220, 230,
175, 72, 160, 59, 191, 210, 94, 140, 208, 54, 65, 65}
groupOrder[BLSBLS12381] = []byte{0x73, 0xED, 0xA7, 0x53, 0x29, 0x9D, 0x7D, 0x48, 0x33, 0x39,
0xD8, 0x08, 0x09, 0xA1, 0xD8, 0x05, 0x53, 0xBD, 0xA4, 0x02, 0xFF, 0xFE,

groupOrder[BLSBLS12381] = []byte{0x73, 0xED, 0xA7, 0x53, 0x29, 0x9D, 0x7D, 0x48, 0x33, 0x39,
0xD8, 0x08, 0x09, 0xA1, 0xD8, 0x05, 0x53, 0xBD, 0xA4, 0x02, 0xFF, 0xFE,
0x5B, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01}
_, err = DecodePrivateKey(salg, groupOrder[salg])
require.Error(t, err, "the key decoding should fail - private key value is too large")
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/access/access_api_test.go
Expand Up @@ -57,7 +57,7 @@ func (suite *AccessSuite) SetupTest() {
conID := unittest.IdentifierFixture()
nodeConfig := testnet.NewNodeConfig(flow.RoleConsensus,
testnet.WithID(conID),
testnet.AsGhost(),
testnet.AsGhost())
nodeConfigs = append(nodeConfigs, nodeConfig)
}

Expand Down