mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
5aac06f04e
* begin move * use same import path * imports * regen protos * regen * no rename * generate ssz * gaz * fmt * edit build file * imports * modify * remove generated files * remove protos * edit imports in prysm * beacon chain all builds * edit script * add generated pbs * add replace rules * license for ethereumapis protos * change visibility * fmt * update build files to gaz ignore * use proper form * edit imports * wrap block * revert scripts * revert go mod
65 lines
2.4 KiB
Go
65 lines
2.4 KiB
Go
package blockchain
|
|
|
|
import (
|
|
"testing"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/interfaces"
|
|
"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: "\"Finished applying state transition\" prefix=blockchain slot=0",
|
|
},
|
|
{name: "has attestation",
|
|
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{Attestations: []*ethpb.Attestation{{}}}},
|
|
want: "\"Finished applying state transition\" attestations=1 prefix=blockchain slot=0",
|
|
},
|
|
{name: "has deposit",
|
|
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{
|
|
Attestations: []*ethpb.Attestation{{}},
|
|
Deposits: []*ethpb.Deposit{{}}}},
|
|
want: "\"Finished applying state transition\" attestations=1 deposits=1 prefix=blockchain slot=0",
|
|
},
|
|
{name: "has attester slashing",
|
|
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{
|
|
AttesterSlashings: []*ethpb.AttesterSlashing{{}}}},
|
|
want: "\"Finished applying state transition\" attesterSlashings=1 prefix=blockchain slot=0",
|
|
},
|
|
{name: "has proposer slashing",
|
|
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{
|
|
ProposerSlashings: []*ethpb.ProposerSlashing{{}}}},
|
|
want: "\"Finished applying state transition\" prefix=blockchain proposerSlashings=1 slot=0",
|
|
},
|
|
{name: "has exit",
|
|
b: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{
|
|
VoluntaryExits: []*ethpb.SignedVoluntaryExit{{}}}},
|
|
want: "\"Finished applying state transition\" prefix=blockchain slot=0 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: "\"Finished applying state transition\" 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(interfaces.WrappedPhase0BeaconBlock(tt.b))
|
|
require.LogsContain(t, hook, tt.want)
|
|
})
|
|
}
|
|
}
|