-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Hide beacon operation field in log if it's 0 #8330
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
896fa11
Hide beacon operation field if it's 0
terencechain 05b8db6
Update test
terencechain 908e21c
Merge branch 'develop' into better-process-blk-logging
rauljordan bd56be2
Merge branch 'develop' into better-process-blk-logging
rauljordan 41b2468
Merge branch 'develop' into better-process-blk-logging
rauljordan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,63 @@ | ||
package blockchain | ||
|
||
import ( | ||
"testing" | ||
|
||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" | ||
"github.com/prysmaticlabs/prysm/shared/testutil/require" | ||
logTest "github.com/sirupsen/logrus/hooks/test" | ||
) | ||
|
||
func Test_logStateTransitionData(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
b *ethpb.BeaconBlock | ||
want string | ||
}{ | ||
{name: "empty block body", | ||
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{}}, | ||
want: "slot=0", | ||
}, | ||
{name: "has attestation", | ||
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{Attestations: []*ethpb.Attestation{{}}}}, | ||
want: "attestations=1", | ||
}, | ||
{name: "has deposit", | ||
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ | ||
Attestations: []*ethpb.Attestation{{}}, | ||
Deposits: []*ethpb.Deposit{{}}}}, | ||
want: "deposits=1", | ||
}, | ||
{name: "has attester slashing", | ||
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ | ||
AttesterSlashings: []*ethpb.AttesterSlashing{{}}}}, | ||
want: "attesterSlashings=1", | ||
}, | ||
{name: "has proposer slashing", | ||
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ | ||
ProposerSlashings: []*ethpb.ProposerSlashing{{}}}}, | ||
want: "proposerSlashings=1", | ||
}, | ||
{name: "has exit", | ||
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ | ||
VoluntaryExits: []*ethpb.SignedVoluntaryExit{{}}}}, | ||
want: "voluntaryExits=1", | ||
}, | ||
{name: "has everything", | ||
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ | ||
Attestations: []*ethpb.Attestation{{}}, | ||
Deposits: []*ethpb.Deposit{{}}, | ||
AttesterSlashings: []*ethpb.AttesterSlashing{{}}, | ||
ProposerSlashings: []*ethpb.ProposerSlashing{{}}, | ||
VoluntaryExits: []*ethpb.SignedVoluntaryExit{{}}}}, | ||
want: "attestations=1 attesterSlashings=1 deposits=1 prefix=blockchain proposerSlashings=1 slot=0 voluntaryExits=1", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
hook := logTest.NewGlobal() | ||
t.Run(tt.name, func(t *testing.T) { | ||
logStateTransitionData(tt.b) | ||
require.LogsContain(t, hook, tt.want) | ||
}) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only tests if the string contains attestations, maybe we should add an additional test to make sure the other ones are not there.