mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
36 lines
649 B
Go
36 lines
649 B
Go
|
package hashutil_test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/gogo/protobuf/proto"
|
||
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||
|
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||
|
)
|
||
|
|
||
|
func TestHashBeaconBlock_doesntMutate(t *testing.T) {
|
||
|
a := &pb.BeaconBlock{
|
||
|
Body: &pb.BeaconBlockBody{
|
||
|
Attestations: []*pb.Attestation{
|
||
|
{
|
||
|
Data: &pb.AttestationData{
|
||
|
Slot: 123,
|
||
|
Shard: 456,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
Signature: []byte{'S', 'I', 'G'},
|
||
|
}
|
||
|
b := proto.Clone(a).(*pb.BeaconBlock)
|
||
|
|
||
|
_, err := hashutil.HashBeaconBlock(b)
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
|
||
|
if !proto.Equal(a, b) {
|
||
|
t.Error("Protos are not equal!")
|
||
|
}
|
||
|
}
|