Skip to content

Commit

Permalink
Fix logged errs (#5645)
Browse files Browse the repository at this point in the history
* fuzz tests, validators stream, and attestation fixed
* hastst
* signinig root fuzz test
* Merge refs/heads/master into fix-logged-errs
* Merge branch 'master' into fix-logged-errs
* Merge branch 'fix-logged-errs' of github.com:prysmaticlabs/prysm into fix-logged-errs
* add head fetchers to inforstream tests
  • Loading branch information
farazdagi committed Apr 28, 2020
1 parent 44b93d9 commit f84e5ad
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 124 deletions.
123 changes: 23 additions & 100 deletions beacon-chain/core/blocks/block_operations_fuzz_test.go
Expand Up @@ -25,12 +25,8 @@ func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(att)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
if _, err = ProcessAttestationNoVerify(ctx, s, att); err != nil {
t.Log(err)
}
_, err = ProcessAttestationNoVerify(ctx, s, att)
_ = err
}
}

Expand All @@ -44,12 +40,8 @@ func TestFuzzProcessBlockHeader_10000(t *testing.T) {
fuzzer.Fuzz(block)

s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
if _, err = ProcessBlockHeader(s, block); err != nil {
t.Log(err)
}
_, err = ProcessBlockHeader(s, block)
_ = err
}
}

Expand All @@ -70,13 +62,9 @@ func TestFuzzverifyDepositDataSigningRoot_10000(t *testing.T) {
fuzzer.Fuzz(&p)
fuzzer.Fuzz(&s)
fuzzer.Fuzz(&d)
if err := verifySignature(ba, pubkey[:], sig[:], domain[:]); err != nil {
t.Log(err)
}
if err := verifySignature(ba, p, s, d); err != nil {
t.Log(err)
}

err := verifySignature(ba, pubkey[:], sig[:], domain[:])
err = verifySignature(ba, p, s, d)
_ = err
}
}

Expand Down Expand Up @@ -117,12 +105,8 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) {
s, err := beaconstate.InitializeFromProto(&ethereum_beacon_p2p_v1.BeaconState{
Eth1DataVotes: stateVotes,
})
if err != nil {
t.Log(err)
}
if _, err := Eth1DataHasEnoughSupport(s, eth1data); err != nil {
t.Log(err)
}
_, err = Eth1DataHasEnoughSupport(s, eth1data)
_ = err
}

}
Expand All @@ -136,12 +120,8 @@ func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(block)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
if _, err = ProcessBlockHeaderNoVerify(s, block); err != nil {
t.Log(err)
}
_, err = ProcessBlockHeaderNoVerify(s, block)
_ = err
}
}

Expand All @@ -154,9 +134,6 @@ func TestFuzzProcessRandao_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(blockBody)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessRandao(s, blockBody)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody)
Expand All @@ -173,9 +150,6 @@ func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(blockBody)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessRandaoNoVerify(s, blockBody)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody)
Expand All @@ -192,9 +166,6 @@ func TestFuzzProcessProposerSlashings_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(blockBody)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessProposerSlashings(ctx, s, blockBody)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody)
Expand All @@ -210,12 +181,8 @@ func TestFuzzVerifyProposerSlashing_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(proposerSlashing)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
if err := VerifyProposerSlashing(s, proposerSlashing); err != nil {
t.Log(err)
}
err = VerifyProposerSlashing(s, proposerSlashing)
_ = err
}
}

Expand All @@ -228,9 +195,6 @@ func TestFuzzProcessAttesterSlashings_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(blockBody)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessAttesterSlashings(ctx, s, blockBody)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody)
Expand All @@ -247,12 +211,8 @@ func TestFuzzVerifyAttesterSlashing_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(attesterSlashing)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
if err := VerifyAttesterSlashing(ctx, s, attesterSlashing); err != nil {
t.Log(err)
}
err = VerifyAttesterSlashing(ctx, s, attesterSlashing)
_ = err
}
}

Expand Down Expand Up @@ -287,9 +247,6 @@ func TestFuzzProcessAttestations_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(blockBody)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessAttestations(ctx, s, blockBody)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody)
Expand All @@ -306,9 +263,6 @@ func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(blockBody)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessAttestationsNoVerify(ctx, s, blockBody)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody)
Expand All @@ -325,9 +279,6 @@ func TestFuzzProcessAttestation_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(attestation)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessAttestation(ctx, s, attestation)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, attestation)
Expand All @@ -344,12 +295,8 @@ func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(idxAttestation)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
if err := VerifyIndexedAttestation(ctx, s, idxAttestation); err != nil {
t.Log(err)
}
err = VerifyIndexedAttestation(ctx, s, idxAttestation)
_ = err
}
}

Expand All @@ -362,12 +309,8 @@ func TestFuzzVerifyAttestation_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(attestation)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
if err := VerifyAttestation(ctx, s, attestation); err != nil {
t.Log(err)
}
err = VerifyAttestation(ctx, s, attestation)
_ = err
}
}

Expand All @@ -380,9 +323,6 @@ func TestFuzzProcessDeposits_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(blockBody)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessDeposits(ctx, s, blockBody)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody)
Expand All @@ -400,9 +340,6 @@ func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(deposit)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessPreGenesisDeposit(ctx, s, deposit)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, deposit)
Expand All @@ -419,9 +356,6 @@ func TestFuzzProcessDeposit_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(deposit)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessDeposit(s, deposit)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, deposit)
Expand All @@ -437,12 +371,8 @@ func TestFuzzverifyDeposit_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(deposit)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
if err := verifyDeposit(s, deposit); err != nil {
t.Log(err)
}
err = verifyDeposit(s, deposit)
_ = err
}
}

Expand All @@ -455,9 +385,6 @@ func TestFuzzProcessVoluntaryExits_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(blockBody)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessVoluntaryExits(ctx, s, blockBody)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody)
Expand All @@ -473,9 +400,6 @@ func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) {
fuzzer.Fuzz(state)
fuzzer.Fuzz(blockBody)
s, err := beaconstate.InitializeFromProtoUnsafe(state)
if err != nil {
t.Log(err)
}
r, err := ProcessVoluntaryExitsNoVerify(s, blockBody)
if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody)
Expand All @@ -495,8 +419,7 @@ func TestFuzzVerifyExit_10000(t *testing.T) {
fuzzer.Fuzz(val)
fuzzer.Fuzz(fork)
fuzzer.Fuzz(&slot)
if err := VerifyExit(val, slot, fork, ve, params.BeaconConfig().ZeroHash[:]); err != nil {
t.Log(err)
}
err := VerifyExit(val, slot, fork, ve, params.BeaconConfig().ZeroHash[:])
_ = err
}
}
3 changes: 0 additions & 3 deletions beacon-chain/core/epoch/epoch_processing_fuzz_test.go
Expand Up @@ -19,8 +19,5 @@ func TestFuzzFinalUpdates_10000(t *testing.T) {
t.Fatal(err)
}
_, err = ProcessFinalUpdates(s)
if err != nil {
t.Log(err)
}
}
}
9 changes: 3 additions & 6 deletions beacon-chain/core/helpers/signing_root_test.go
Expand Up @@ -76,11 +76,8 @@ func TestFuzzverifySigningRoot_10000(t *testing.T) {
fuzzer.Fuzz(&p)
fuzzer.Fuzz(&s)
fuzzer.Fuzz(&d)
if err := VerifySigningRoot(state, pubkey[:], sig[:], domain[:]); err != nil {
t.Log(err)
}
if err := VerifySigningRoot(state, p, s, d); err != nil {
t.Log(err)
}
err := VerifySigningRoot(state, pubkey[:], sig[:], domain[:])
err = VerifySigningRoot(state, p, s, d)
_ = err
}
}
5 changes: 2 additions & 3 deletions beacon-chain/core/state/transition_fuzz_test.go
Expand Up @@ -179,9 +179,8 @@ func TestFuzzverifyOperationLengths_10000(t *testing.T) {
for i := 0; i < 10000; i++ {
fuzzer.Fuzz(state)
fuzzer.Fuzz(bb)
if err := verifyOperationLengths(state, bb); err != nil {
t.Log(err)
}
err := verifyOperationLengths(state, bb)
_ = err
}
}

Expand Down
31 changes: 22 additions & 9 deletions beacon-chain/rpc/beacon/validators_stream_test.go
Expand Up @@ -4,7 +4,9 @@ import (
"sync"
"testing"

mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
)

func TestInfostream_EpochToTimestamp(t *testing.T) {
Expand Down Expand Up @@ -67,14 +69,19 @@ func TestInfostream_HandleSetValidatorKeys(t *testing.T) {
is := &infostream{
pubKeysMutex: &sync.RWMutex{},
pubKeys: make([][]byte, 0),
headFetcher: &mock.ChainService{
State: testutil.NewBeaconState(),
},
}
for _, test := range tests {
if err := is.handleSetValidatorKeys(test.reqPubKeys); err != nil {
t.Log(err)
}
if len(is.pubKeys) != len(test.reqPubKeys) {
t.Errorf("Incorrect number of keys: expected %v, received %v", len(test.reqPubKeys), len(is.pubKeys))
}
t.Run(test.name, func(t *testing.T) {
if err := is.handleSetValidatorKeys(test.reqPubKeys); err != nil {
t.Error(err)
}
if len(is.pubKeys) != len(test.reqPubKeys) {
t.Errorf("Incorrect number of keys: expected %v, received %v", len(test.reqPubKeys), len(is.pubKeys))
}
})
}
}

Expand Down Expand Up @@ -112,13 +119,16 @@ func TestInfostream_HandleAddValidatorKeys(t *testing.T) {
is := &infostream{
pubKeysMutex: &sync.RWMutex{},
pubKeys: make([][]byte, 0),
headFetcher: &mock.ChainService{
State: testutil.NewBeaconState(),
},
}
for _, test := range tests {
if err := is.handleSetValidatorKeys(test.initialPubKeys); err != nil {
t.Log(err)
t.Error(err)
}
if err := is.handleAddValidatorKeys(test.reqPubKeys); err != nil {
t.Log(err)
t.Error(err)
}
if len(is.pubKeys) != test.finalLen {
t.Errorf("Incorrect number of keys: expected %v, received %v", len(is.pubKeys), test.finalLen)
Expand Down Expand Up @@ -160,10 +170,13 @@ func TestInfostream_HandleRemoveValidatorKeys(t *testing.T) {
is := &infostream{
pubKeysMutex: &sync.RWMutex{},
pubKeys: make([][]byte, 0),
headFetcher: &mock.ChainService{
State: testutil.NewBeaconState(),
},
}
for _, test := range tests {
if err := is.handleSetValidatorKeys(test.initialPubKeys); err != nil {
t.Log(err)
t.Error(err)
}
is.handleRemoveValidatorKeys(test.reqPubKeys)
if len(is.pubKeys) != test.finalLen {
Expand Down

0 comments on commit f84e5ad

Please sign in to comment.