2019-02-03 05:13:16 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-07-28 21:23:44 +00:00
|
|
|
# Script to update mock files after proto/prysm/v1alpha1/services.proto changes.
|
2019-02-03 05:13:16 +00:00
|
|
|
# Use a space to separate mock destination from its interfaces.
|
|
|
|
|
2021-09-29 21:25:45 +00:00
|
|
|
mock_path="testing/mock"
|
2022-11-21 16:26:27 +00:00
|
|
|
|
|
|
|
# github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1
|
|
|
|
# ------------------------------------------------------
|
|
|
|
proto_mocks_v1alpha1=(
|
2020-05-15 17:27:46 +00:00
|
|
|
"$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"
|
2020-11-17 02:48:16 +00:00
|
|
|
"$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"
|
2021-09-29 21:25:45 +00:00
|
|
|
"$mock_path/slasher_client_mock.go SlasherClient"
|
2020-05-14 22:11:52 +00:00
|
|
|
"$mock_path/node_service_mock.go NodeClient"
|
|
|
|
)
|
2019-02-03 05:13:16 +00:00
|
|
|
|
2022-11-21 16:26:27 +00:00
|
|
|
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"
|
2022-11-07 10:29:27 +00:00
|
|
|
)
|
|
|
|
|
2022-11-21 16:26:27 +00:00
|
|
|
for ((i = 0; i < ${#proto_mocks_service[@]}; i++)); do
|
|
|
|
file=${proto_mocks_service[i]% *};
|
|
|
|
interfaces=${proto_mocks_service[i]#* };
|
2019-02-03 05:13:16 +00:00
|
|
|
echo "generating $file for interfaces: $interfaces";
|
2022-11-21 16:26:27 +00:00
|
|
|
echo
|
|
|
|
GO11MODULE=on mockgen -package=mock -destination="$file" github.com/prysmaticlabs/prysm/v3/proto/eth/service "$interfaces"
|
2019-03-24 00:46:25 +00:00
|
|
|
done
|
2020-05-15 17:27:46 +00:00
|
|
|
|
2022-11-21 16:26:27 +00:00
|
|
|
# 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"
|
|
|
|
)
|
|
|
|
|
2022-11-07 10:29:27 +00:00
|
|
|
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
|
|
|
|
|
2020-05-15 17:27:46 +00:00
|
|
|
goimports -w "$mock_path/."
|
|
|
|
gofmt -s -w "$mock_path/."
|
2021-09-29 21:25:45 +00:00
|
|
|
|
2022-12-05 10:27:41 +00:00
|
|
|
# github.com/prysmaticlabs/prysm/v3/validator/client/beacon-api
|
|
|
|
# --------------------------------------------------------
|
|
|
|
beacon_api_mock_path="validator/client/beacon-api/mock"
|
|
|
|
beacon_api_mocks=(
|
|
|
|
"$beacon_api_mock_path/genesis_mock.go genesis.go"
|
2022-12-06 12:27:26 +00:00
|
|
|
"$beacon_api_mock_path/json_rest_handler_mock.go json_rest_handler.go"
|
2022-12-05 10:27:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
for ((i = 0; i < ${#beacon_api_mocks[@]}; i++)); do
|
|
|
|
file=${beacon_api_mocks[i]% *};
|
|
|
|
source=${beacon_api_mocks[i]#* };
|
|
|
|
echo "generating $file for file: $source";
|
2022-12-08 14:38:56 +00:00
|
|
|
GO11MODULE=on mockgen -package=mock -source="validator/client/beacon-api/$source" -destination="$file"
|
2022-12-05 10:27:41 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
goimports -w "$beacon_api_mock_path/."
|
|
|
|
gofmt -s -w "$beacon_api_mock_path/."
|