2019-01-14 16:41:20 +00:00
|
|
|
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{
|
2019-01-19 02:57:51 +00:00
|
|
|
{
|
2019-01-14 16:41:20 +00:00
|
|
|
Data: &pb.AttestationData{
|
|
|
|
Slot: 123,
|
|
|
|
Shard: 456,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-01-19 02:57:51 +00:00
|
|
|
Signature: [][]byte{{'S', 'I', 'G'}},
|
2019-01-14 16:41:20 +00:00
|
|
|
}
|
|
|
|
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!")
|
|
|
|
}
|
|
|
|
}
|