prysm-pulse/hack/update-mockgen.sh
Manu NALEPA 0bcddb3009
Update mockgen (#11615)
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
2022-11-21 17:26:27 +01:00

71 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
# Script to update mock files after proto/prysm/v1alpha1/services.proto changes.
# Use a space to separate mock destination from its interfaces.
mock_path="testing/mock"
# github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1
# ------------------------------------------------------
proto_mocks_v1alpha1=(
"$mock_path/beacon_service_mock.go BeaconChainClient,BeaconChain_StreamChainHeadClient,BeaconChain_StreamAttestationsClient,BeaconChain_StreamBlocksClient,BeaconChain_StreamValidatorsInfoClient,BeaconChain_StreamIndexedAttestationsClient"
"$mock_path/beacon_chain_service_mock.go BeaconChain_StreamChainHeadServer,BeaconChain_StreamAttestationsServer,BeaconChain_StreamBlocksServer,BeaconChain_StreamValidatorsInfoServer,BeaconChain_StreamIndexedAttestationsServer"
"$mock_path/beacon_validator_server_mock.go BeaconNodeValidatorServer,BeaconNodeValidator_WaitForActivationServer,BeaconNodeValidator_WaitForChainStartServer,BeaconNodeValidator_StreamDutiesServer"
"$mock_path/beacon_validator_client_mock.go BeaconNodeValidatorClient,BeaconNodeValidator_WaitForChainStartClient,BeaconNodeValidator_WaitForActivationClient,BeaconNodeValidator_StreamDutiesClient"
"$mock_path/slasher_client_mock.go SlasherClient"
"$mock_path/node_service_mock.go NodeClient"
)
for ((i = 0; i < ${#proto_mocks_v1alpha1[@]}; i++)); do
file=${proto_mocks_v1alpha1[i]% *};
interfaces=${proto_mocks_v1alpha1[i]#* };
echo "generating $file for interfaces: $interfaces";
echo
GO11MODULE=on mockgen -package=mock -destination="$file" github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1 "$interfaces"
done
# github.com/prysmaticlabs/prysm/v3/proto/eth/service
# ---------------------------------------------------
proto_mocks_service=(
"$mock_path/event_service_mock.go EventsClient,Events_StreamEventsClient,Events_StreamEventsServer"
)
for ((i = 0; i < ${#proto_mocks_service[@]}; i++)); do
file=${proto_mocks_service[i]% *};
interfaces=${proto_mocks_service[i]#* };
echo "generating $file for interfaces: $interfaces";
echo
GO11MODULE=on mockgen -package=mock -destination="$file" github.com/prysmaticlabs/prysm/v3/proto/eth/service "$interfaces"
done
# github.com/prysmaticlabs/prysm/proto/v3/prysm/v1alpha1/validator-client
# -----------------------------------------------------------------------
proto_mocks_v1alpha1_validator_clients=(
"$mock_path/keymanager_mock.go RemoteSignerClient"
)
for ((i = 0; i < ${#proto_mocks_v1alpha1_validator_clients[@]}; i++)); do
file=${proto_mocks_v1alpha1_validator_clients[i]% *};
interfaces=${proto_mocks_v1alpha1_validator_clients[i]#* };
echo "generating $file for interfaces: $interfaces";
echo
GO11MODULE=on mockgen -package=mock -destination="$file" github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1/validator-client "$interfaces"
done
# github.com/prysmaticlabs/prysm/v3/validator/client/iface
# --------------------------------------------------------
iface_mocks=(
"$mock_path/validator_client_mock.go ValidatorClient"
)
for ((i = 0; i < ${#iface_mocks[@]}; i++)); do
file=${iface_mocks[i]% *};
interfaces=${iface_mocks[i]#* };
echo "generating $file for interfaces: $interfaces";
GO11MODULE=on mockgen -package=mock -destination="$file" github.com/prysmaticlabs/prysm/v3/validator/client/iface "$interfaces"
done
goimports -w "$mock_path/."
gofmt -s -w "$mock_path/."