diff --git a/cmd/exit_broadcast_internal_test.go b/cmd/exit_broadcast_internal_test.go index 87abbb732..83990d5d2 100644 --- a/cmd/exit_broadcast_internal_test.go +++ b/cmd/exit_broadcast_internal_test.go @@ -337,3 +337,92 @@ func Test_runBcastFullExitCmd_Config(t *testing.T) { }) } } + +func TestExitBroadcastCLI(t *testing.T) { + tests := []struct { + name string + expectedErr string + + flags []string + }{ + { + name: "check flags", + expectedErr: "load identity key: read private key from disk: open test: no such file or directory", + flags: []string{ + "--publish-address=test", + "--private-key-file=test", + "--lock-file=test", + "--validator-keys-dir=test", + "--exit-epoch=1", + "--validator-public-key=test", // single exit + "--beacon-node-endpoints=test1,test2", + "--exit-from-file=test", // single exit + "--beacon-node-timeout=1ms", + "--publish-timeout=1ms", + "--all=false", // single exit + "--testnet-name=test", + "--testnet-fork-version=test", + "--testnet-chain-id=1", + "--testnet-genesis-timestamp=1", + "--testnet-capella-hard-fork=test", + }, + }, + { + name: "check flags all", + expectedErr: "load identity key: read private key from disk: open test: no such file or directory", + flags: []string{ + "--publish-address=test", + "--private-key-file=test", + "--lock-file=test", + "--validator-keys-dir=test", // exit all + "--exit-epoch=1", + "--beacon-node-endpoints=test1,test2", + "--exit-from-dir=test", + "--beacon-node-timeout=1ms", + "--publish-timeout=1ms", + "--all", // exit all + "--testnet-name=test", + "--testnet-fork-version=test", + "--testnet-chain-id=1", + "--testnet-genesis-timestamp=1", + "--testnet-capella-hard-fork=test", + }, + }, + { + name: "check flags all", + expectedErr: "load identity key: read private key from disk: open test: no such file or directory", + flags: []string{ + "--publish-address=test", + "--private-key-file=test", + "--lock-file=test", + "--validator-keys-dir=test", // exit all + "--exit-epoch=1", + "--beacon-node-endpoints=test1,test2", + "--exit-from-dir=test", + "--beacon-node-timeout=1ms", + "--publish-timeout=1ms", + "--all", // exit all + "--testnet-name=test", + "--testnet-fork-version=test", + "--testnet-chain-id=1", + "--testnet-genesis-timestamp=1", + "--testnet-capella-hard-fork=test", + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + cmd := newExitCmd(newBcastFullExitCmd(runBcastFullExit)) + cmd.SetArgs(append([]string{"broadcast"}, test.flags...)) + + err := cmd.Execute() + if test.expectedErr != "" { + require.Error(t, err) + require.ErrorContains(t, err, test.expectedErr) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/cmd/exit_fetch_internal_test.go b/cmd/exit_fetch_internal_test.go index 8c690adea..d43992980 100644 --- a/cmd/exit_fetch_internal_test.go +++ b/cmd/exit_fetch_internal_test.go @@ -169,3 +169,70 @@ func Test_runFetchExitBadOutDir(t *testing.T) { require.ErrorContains(t, runFetchExit(context.Background(), config), "permission denied") } + +func TestExitFetchCLI(t *testing.T) { + tests := []struct { + name string + expectedErr string + + publishAddress string + privateKeyPath string + lockFilePath string + validatorPubkey string + all string + fetchedExitPath string + publishTimeout string + testnetName string + testnetForkVersion string + testnetChainID string + testnetGenesisTimestamp string + testnetCapellaHardFork string + }{ + { + name: "check flags", + expectedErr: "store exit path: stat 1: no such file or directory", + + publishAddress: "--publish-address=test", + privateKeyPath: "--private-key-file=test", + lockFilePath: "--lock-file=test", + validatorPubkey: "--validator-public-key=test", + fetchedExitPath: "--fetched-exit-path=1", + publishTimeout: "--publish-timeout=1ms", + all: "--all=false", + testnetName: "--testnet-name=test", + testnetForkVersion: "--testnet-fork-version=test", + testnetChainID: "--testnet-chain-id=1", + testnetGenesisTimestamp: "--testnet-genesis-timestamp=1", + testnetCapellaHardFork: "--testnet-capella-hard-fork=test", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + cmd := newExitCmd(newFetchExitCmd(runFetchExit)) + cmd.SetArgs([]string{ + "fetch", + test.publishAddress, + test.privateKeyPath, + test.lockFilePath, + test.validatorPubkey, + test.fetchedExitPath, + test.publishTimeout, + test.all, + test.testnetName, + test.testnetForkVersion, + test.testnetChainID, + test.testnetGenesisTimestamp, + test.testnetCapellaHardFork, + }) + + err := cmd.Execute() + if test.expectedErr != "" { + require.Error(t, err) + require.ErrorContains(t, err, test.expectedErr) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/cmd/exit_list_internal_test.go b/cmd/exit_list_internal_test.go index 05450b9b6..0ddc48b41 100644 --- a/cmd/exit_list_internal_test.go +++ b/cmd/exit_list_internal_test.go @@ -197,3 +197,58 @@ func Test_listActiveVals(t *testing.T) { require.Len(t, vals, len(lock.Validators)/2) }) } + +func TestExitListCLI(t *testing.T) { + tests := []struct { + name string + expectedErr string + + lockFilePath string + beaconNodeEndpoints string + beaconNodeTimeout string + testnetName string + testnetForkVersion string + testnetChainID string + testnetGenesisTimestamp string + testnetCapellaHardFork string + }{ + { + name: "check flags", + expectedErr: "load cluster lock: load cluster manifest from disk: load dag from disk: no file found", + + lockFilePath: "--lock-file=test", + beaconNodeEndpoints: "--beacon-node-endpoints=test1,test2", + beaconNodeTimeout: "--beacon-node-timeout=1ms", + testnetName: "--testnet-name=test", + testnetForkVersion: "--testnet-fork-version=test", + testnetChainID: "--testnet-chain-id=1", + testnetGenesisTimestamp: "--testnet-genesis-timestamp=1", + testnetCapellaHardFork: "--testnet-capella-hard-fork=test", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + cmd := newExitCmd(newListActiveValidatorsCmd(runListActiveValidatorsCmd)) + cmd.SetArgs([]string{ + "active-validator-list", + test.lockFilePath, + test.beaconNodeEndpoints, + test.beaconNodeTimeout, + test.testnetName, + test.testnetForkVersion, + test.testnetChainID, + test.testnetGenesisTimestamp, + test.testnetCapellaHardFork, + }) + + err := cmd.Execute() + if test.expectedErr != "" { + require.Error(t, err) + require.ErrorContains(t, err, test.expectedErr) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/cmd/exit_sign_internal_test.go b/cmd/exit_sign_internal_test.go index 82da33995..324bdd75f 100644 --- a/cmd/exit_sign_internal_test.go +++ b/cmd/exit_sign_internal_test.go @@ -386,3 +386,82 @@ func Test_runSubmitPartialExit_Config(t *testing.T) { }) } } + +func TestExitSignCLI(t *testing.T) { + tests := []struct { + name string + expectedErr string + + publishAddress string + privateKeyPath string + lockFilePath string + validatorKeysDir string + exitEpoch string + validatorPubkey string + validatorIndex string + beaconNodeEndpoints string + beaconNodeTimeout string + publishTimeout string + all string + testnetName string + testnetForkVersion string + testnetChainID string + testnetGenesisTimestamp string + testnetCapellaHardFork string + }{ + { + name: "check flags", + expectedErr: "load identity key: read private key from disk: open test: no such file or directory", + + publishAddress: "--publish-address=test", + privateKeyPath: "--private-key-file=test", + lockFilePath: "--lock-file=test", + validatorKeysDir: "--validator-keys-dir=test", + exitEpoch: "--exit-epoch=1", + validatorPubkey: "--validator-public-key=test", + validatorIndex: "--validator-index=1", + beaconNodeEndpoints: "--beacon-node-endpoints=test1,test2", + beaconNodeTimeout: "--beacon-node-timeout=1ms", + publishTimeout: "--publish-timeout=1ms", + all: "--all=false", + testnetName: "--testnet-name=test", + testnetForkVersion: "--testnet-fork-version=test", + testnetChainID: "--testnet-chain-id=1", + testnetGenesisTimestamp: "--testnet-genesis-timestamp=1", + testnetCapellaHardFork: "--testnet-capella-hard-fork=test", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + cmd := newExitCmd(newSignPartialExitCmd(runSignPartialExit)) + cmd.SetArgs([]string{ + "sign", + test.publishAddress, + test.privateKeyPath, + test.lockFilePath, + test.validatorKeysDir, + test.exitEpoch, + test.validatorPubkey, + test.validatorIndex, + test.beaconNodeEndpoints, + test.beaconNodeTimeout, + test.publishTimeout, + test.all, + test.testnetName, + test.testnetForkVersion, + test.testnetChainID, + test.testnetGenesisTimestamp, + test.testnetCapellaHardFork, + }) + + err := cmd.Execute() + if test.expectedErr != "" { + require.Error(t, err) + require.ErrorContains(t, err, test.expectedErr) + } else { + require.NoError(t, err) + } + }) + } +}