MCPcopy
hub / github.com/canopy-network/canopy / TestGetNonSigners

Function TestGetNonSigners

lib/consensus_test.go:413–517  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

411}
412
413func TestGetNonSigners(t *testing.T) {
414 // pre-create a message to sign
415 msg := &QuorumCertificate{BlockHash: []byte("message")}
416 // pre-create the validator set
417 vs, er := NewValidatorSet(&ConsensusValidators{
418 ValidatorSet: []*ConsensusValidator{
419 {
420 PublicKey: newTestPublicKeyBytes(t),
421 VotingPower: 1,
422 },
423 {
424 PublicKey: newTestPublicKeyBytes(t, 1),
425 VotingPower: 1,
426 },
427 {
428 PublicKey: newTestPublicKeyBytes(t, 2),
429 VotingPower: 1,
430 },
431 },
432 })
433 require.NoError(t, er)
434 // pre-create some public keys
435 pub1, err := crypto.BytesToBLS12381Point(newTestPublicKeyBytes(t))
436 require.NoError(t, err)
437 pub2, err := crypto.BytesToBLS12381Point(newTestPublicKeyBytes(t, 1))
438 require.NoError(t, err)
439 pub3, err := crypto.BytesToBLS12381Point(newTestPublicKeyBytes(t, 2))
440 require.NoError(t, err)
441 // pre-create some multi-keys
442 multiKey1, err := crypto.NewMultiBLSFromPoints([]kyber.Point{pub1, pub2, pub3}, nil)
443 require.NoError(t, err)
444 multiKey2, multiKey3 := multiKey1.Copy(), multiKey1.Copy()
445 // pre-create signatures
446 for i := 0; i < 3; i++ {
447 signature := newTestKeyGroup(t, i).PrivateKey.Sign(msg.SignBytes())
448 // full
449 require.NoError(t, multiKey1.AddSigner(signature, i))
450 // partial
451 if i != 0 {
452 require.NoError(t, multiKey2.AddSigner(signature, i))
453 }
454 }
455 // create the aggregate signatures
456 asFull, err := multiKey1.AggregateSignatures()
457 require.NoError(t, err)
458 partial, err := multiKey2.AggregateSignatures()
459 require.NoError(t, err)
460 noSigners, err := multiKey3.AggregateSignatures()
461 require.NoError(t, err)
462 // define test cases
463 tests := []struct {
464 name string
465 detail string
466 as *AggregateSignature
467 expectedNonSigners [][]byte
468 expectedNonSignerPercet uint64
469 }{
470 {

Callers

nothing calls this directly

Calls 14

SignBytesMethod · 0.95
BytesToBLS12381PointFunction · 0.92
NewMultiBLSFromPointsFunction · 0.92
NewValidatorSetFunction · 0.85
RunMethod · 0.80
EqualMethod · 0.80
newTestPublicKeyBytesFunction · 0.70
newTestKeyGroupFunction · 0.70
CopyMethod · 0.65
SignMethod · 0.65
AddSignerMethod · 0.65
AggregateSignaturesMethod · 0.65

Tested by

no test coverage detected