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.
|
2024-02-21 18:37:17 +00:00
|
|
|
# Be sure to install mockgen before use: https://github.com/uber-go/mock
|
2019-02-03 05:13:16 +00:00
|
|
|
|
2021-09-29 21:25:45 +00:00
|
|
|
mock_path="testing/mock"
|
2023-03-20 16:32:32 +00:00
|
|
|
iface_mock_path="testing/validator-mock"
|
2022-11-21 16:26:27 +00:00
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
# github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1
|
2022-11-21 16:26:27 +00:00
|
|
|
# ------------------------------------------------------
|
|
|
|
proto_mocks_v1alpha1=(
|
2024-02-15 15:23:31 +00:00
|
|
|
"$mock_path/beacon_service_mock.go BeaconChainClient"
|
|
|
|
"$mock_path/beacon_validator_server_mock.go BeaconNodeValidatorServer,BeaconNodeValidator_WaitForActivationServer,BeaconNodeValidator_WaitForChainStartServer,BeaconNodeValidator_StreamSlotsServer"
|
|
|
|
"$mock_path/beacon_validator_client_mock.go BeaconNodeValidatorClient,BeaconNodeValidator_WaitForChainStartClient,BeaconNodeValidator_WaitForActivationClient,BeaconNodeValidator_StreamSlotsClient"
|
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
|
2024-02-15 05:46:47 +00:00
|
|
|
GO11MODULE=on mockgen -package=mock -destination="$file" github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1 "$interfaces"
|
2022-11-21 16:26:27 +00:00
|
|
|
done
|
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
# github.com/prysmaticlabs/prysm/v5/validator/client/iface
|
2022-11-21 16:26:27 +00:00
|
|
|
# --------------------------------------------------------
|
|
|
|
iface_mocks=(
|
2023-03-20 16:32:32 +00:00
|
|
|
"$iface_mock_path/beacon_chain_client_mock.go BeaconChainClient"
|
2023-10-11 13:23:02 +00:00
|
|
|
"$iface_mock_path/prysm_beacon_chain_client_mock.go PrysmBeaconChainClient"
|
2023-03-20 16:32:32 +00:00
|
|
|
"$iface_mock_path/node_client_mock.go NodeClient"
|
|
|
|
"$iface_mock_path/validator_client_mock.go ValidatorClient"
|
2022-11-21 16:26:27 +00:00
|
|
|
)
|
|
|
|
|
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";
|
2024-02-15 05:46:47 +00:00
|
|
|
GO11MODULE=on mockgen -package=validator_mock -destination="$file" github.com/prysmaticlabs/prysm/v5/validator/client/iface "$interfaces"
|
2022-11-07 10:29:27 +00:00
|
|
|
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
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
# github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api
|
2023-01-04 23:15:23 +00:00
|
|
|
# -------------------------------------------------------------
|
2022-12-05 10:27:41 +00:00
|
|
|
beacon_api_mock_path="validator/client/beacon-api/mock"
|
|
|
|
beacon_api_mocks=(
|
|
|
|
"$beacon_api_mock_path/genesis_mock.go genesis.go"
|
2023-01-18 21:21:07 +00:00
|
|
|
"$beacon_api_mock_path/duties_mock.go duties.go"
|
2022-12-06 12:27:26 +00:00
|
|
|
"$beacon_api_mock_path/json_rest_handler_mock.go json_rest_handler.go"
|
2023-01-04 23:15:23 +00:00
|
|
|
"$beacon_api_mock_path/state_validators_mock.go state_validators.go"
|
2023-02-13 13:22:11 +00:00
|
|
|
"$beacon_api_mock_path/beacon_block_converter_mock.go beacon_block_converter.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/."
|
2023-02-14 04:53:54 +00:00
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
# github.com/prysmaticlabs/prysm/v5/crypto/bls
|
2023-02-14 04:53:54 +00:00
|
|
|
# --------------------------------------------
|
|
|
|
crypto_bls_common_mock_path="crypto/bls/common/mock"
|
|
|
|
crypto_bls_common_mocks=(
|
|
|
|
"$crypto_bls_common_mock_path/interface_mock.go interface.go"
|
|
|
|
)
|
|
|
|
|
|
|
|
for ((i = 0; i < ${#crypto_bls_common_mocks[@]}; i++)); do
|
|
|
|
file=${crypto_bls_common_mocks[i]% *};
|
|
|
|
source=${crypto_bls_common_mocks[i]#* };
|
|
|
|
echo "generating $file for file: $source";
|
|
|
|
GO11MODULE=on mockgen -package=mock -source="crypto/bls/common/$source" -destination="$file"
|
|
|
|
done
|
|
|
|
|
|
|
|
goimports -w "$crypto_bls_common_mock_path/."
|
|
|
|
gofmt -s -w "$crypto_bls_common_mock_path/."
|