Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomi-3-0 committed Dec 7, 2023
1 parent 0a9878e commit bdfc4d0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 120 deletions.
7 changes: 1 addition & 6 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ func setupStarknetNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions,
inputCustomChainSpec,
inputCustomGenesis,
inputCustomDeployBlock,
inputExecutionBootNodes,
inputConsensusBootNodes,

); err != nil {
return err
}
Expand Down Expand Up @@ -1111,10 +1110,6 @@ func inputEthNode(p ui.Prompter, o *CliCmdOptions) (err error) {
return
}

// func inputDbPath(p ui.Prompter, o *CliCmdOptions) (err error) {
// o.genData.DbPath, err = p.InputFilePath("Custom path to database", "", true, ".yml", ".yaml", ".txt", ".json")
// return
// }

func absPathInPlace(path *string) error {
absPath, err := filepath.Abs(*path)
Expand Down
98 changes: 19 additions & 79 deletions cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,16 @@ func TestCli(t *testing.T) {
ETHClients["execution"] = append(ETHClients["execution"], "randomize")
ETHClients["consensus"] = append(ETHClients["consensus"], "randomize")
ETHClients["validator"] = append(ETHClients["validator"], "randomize")
ETHClients["starknet"] = append(ETHClients["starknet"], "randomize")
ETHClients["starknet"] = append(ETHClients["starknet"], "randomize")

GnosisClients := map[string][]string{
"execution": {"nethermind"},
"consensus": utils.Filter(clients.AllClients["consensus"], func(c string) bool { return c != "prysm" }),
"validator": utils.Filter(clients.AllClients["validator"], func(c string) bool { return c != "prysm" }),
"starknet": {"juno"},
}
GnosisClients["execution"] = append(GnosisClients["execution"], "randomize")
GnosisClients["consensus"] = append(GnosisClients["consensus"], "randomize")
GnosisClients["validator"] = append(GnosisClients["validator"], "randomize")
GnosisClients["starknet"] = append(GnosisClients["starknet"], "randomize")

HoleskyClients := map[string][]string{
"execution": clients.AllClients["execution"],
Expand Down Expand Up @@ -108,7 +106,7 @@ func TestCli(t *testing.T) {
sedgeActions.EXPECT().GetCommandRunner().Return(&test.SimpleCMDRunner{})
gomock.InOrder(
prompter.EXPECT().Select("Select network", "", []string{NetworkMainnet, NetworkGoerli, NetworkSepolia, NetworkGnosis, NetworkChiado, NetworkHolesky}).Return(0, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator}).Return(0, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator, NodeTypeStarknet}).Return(0, nil),
prompter.EXPECT().Input("Generation path", configs.DefaultAbsSedgeDataPath, false, nil).Return(generationPath, nil),
prompter.EXPECT().Input("Container tag, sedge will add to each container and the network, a suffix with the tag", "", false, nil).Return("tag", nil),
prompter.EXPECT().Confirm("Do you want to set up a validator?", true).Return(true, nil),
Expand Down Expand Up @@ -178,7 +176,7 @@ func TestCli(t *testing.T) {
}
gomock.InOrder(
prompter.EXPECT().Select("Select network", "", []string{NetworkMainnet, NetworkGoerli, NetworkSepolia, NetworkGnosis, NetworkChiado, NetworkHolesky}).Return(0, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator}).Return(0, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator, NodeTypeStarknet}).Return(0, nil),
prompter.EXPECT().Input("Generation path", configs.DefaultAbsSedgeDataPath, false, nil).Return(generationPath, nil),
prompter.EXPECT().Input("Container tag, sedge will add to each container and the network, a suffix with the tag", "", false, nil).Return("tag", nil),
prompter.EXPECT().Confirm("Do you want to set up a validator?", true).Return(false, nil),
Expand Down Expand Up @@ -257,7 +255,7 @@ func TestCli(t *testing.T) {

gomock.InOrder(
prompter.EXPECT().Select("Select network", "", []string{NetworkMainnet, NetworkGoerli, NetworkSepolia, NetworkGnosis, NetworkChiado, NetworkHolesky}).Return(0, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator}).Return(1, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator, NodeTypeStarknet}).Return(1, nil),
prompter.EXPECT().Input("Generation path", configs.DefaultAbsSedgeDataPath, false, nil).Return(generationPath, nil),
prompter.EXPECT().Input("Container tag, sedge will add to each container and the network, a suffix with the tag", "", false, nil).Return("tag", nil),
prompter.EXPECT().Select("Select execution client", "", ETHClients["execution"]).Return(0, nil),
Expand Down Expand Up @@ -349,7 +347,7 @@ func TestCli(t *testing.T) {

gomock.InOrder(
prompter.EXPECT().Select("Select network", "", []string{NetworkMainnet, NetworkGoerli, NetworkSepolia, NetworkGnosis, NetworkChiado, NetworkHolesky}).Return(1, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator}).Return(2, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator, NodeTypeStarknet}).Return(2, nil),
prompter.EXPECT().Input("Generation path", configs.DefaultAbsSedgeDataPath, false, nil).Return(generationPath, nil),
prompter.EXPECT().Input("Container tag, sedge will add to each container and the network, a suffix with the tag", "", false, nil).Return("tag", nil),
prompter.EXPECT().Select("Select consensus client", "", ETHClients["consensus"]).Return(3, nil),
Expand Down Expand Up @@ -433,7 +431,7 @@ func TestCli(t *testing.T) {

gomock.InOrder(
prompter.EXPECT().Select("Select network", "", []string{NetworkMainnet, NetworkGoerli, NetworkSepolia, NetworkGnosis, NetworkChiado, NetworkHolesky}).Return(0, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator}).Return(3, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator, NodeTypeStarknet}).Return(3, nil),
prompter.EXPECT().Input("Generation path", configs.DefaultAbsSedgeDataPath, false, nil).Return(generationPath, nil),
prompter.EXPECT().Input("Container tag, sedge will add to each container and the network, a suffix with the tag", "", false, nil).Return("tag", nil),
prompter.EXPECT().Select("Select validator client", "", ETHClients["validator"]).Return(1, nil),
Expand Down Expand Up @@ -472,93 +470,34 @@ func TestCli(t *testing.T) {
},
},
{
name: "starknet node",
name: "starknet node mainnet",
setup: func(t *testing.T, sedgeActions *sedge_mocks.MockSedgeActions, prompter *sedge_mocks.MockPrompter, depsMgr *sedge_mocks.MockDependenciesManager) {
generationPath := t.TempDir()
genData := generate.GenData{
Services: []string{"starknet"},
StarknetClient: &clients.Client{
Name: "juno",
Type: "starknet",
Image: configs.ClientImages.Execution.Nethermind.String(),
Image: configs.ClientImages.Starknet.Juno.String(),

},
Network: "mainnet",
MapAllPorts: true,
ContainerTag: "tag",
ExecutionApiUrl: "ws://execution:8545",
Network: "mainnet",
MapAllPorts: true,
ContainerTag: "tag",
Full: false,
JWTSecretPath: filepath.Join(generationPath, "jwtsecret"),
}

gomock.InOrder(
prompter.EXPECT().Select("Select network", "", []string{NetworkMainnet, NetworkGoerli}).Return(0, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator, NodeTypeStarknet}).Return(1, nil),
prompter.EXPECT().Select("Select network", "", []string{NetworkMainnet, NetworkGoerli, NetworkSepolia, NetworkGnosis, NetworkChiado, NetworkHolesky}).Return(0, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator, NodeTypeStarknet}).Return(4, nil),
prompter.EXPECT().Input("Generation path", configs.DefaultAbsSedgeDataPath, false, nil).Return(generationPath, nil),
prompter.EXPECT().Input("Container tag, sedge will add to each container and the network, a suffix with the tag", "", false, nil).Return("tag", nil),
prompter.EXPECT().Select("Select starknet client", "", ETHClients["starknet"]).Return(0, nil),
prompter.EXPECT().Confirm("Do you want to set up a full starknet node (with execution and consensus)?", true).Return(false, nil),
prompter.EXPECT().InputURL("Eth 1 Endpoint", "", true).Return("ws://execution:8545", nil),
prompter.EXPECT().Confirm("Do you want to expose all ports?", false).Return(true, nil),
prompter.EXPECT().Select("Select JWT source", "", []string{SourceTypeCreate, SourceTypeExisting, SourceTypeSkip}).Return(2, nil),
sedgeActions.EXPECT().Generate(gomock.Eq(actions.GenerateOptions{
GenerationPath: generationPath,
GenerationData: genData,
})).Return(genData, nil),
prompter.EXPECT().Confirm("Run services now?", false).Return(true, nil),
depsMgr.EXPECT().Check([]string{dependencies.Docker}).Return([]string{dependencies.Docker}, nil),
depsMgr.EXPECT().DockerEngineIsOn().Return(nil),
depsMgr.EXPECT().DockerComposeIsInstalled().Return(nil),
sedgeActions.EXPECT().SetupContainers(actions.SetupContainersOptions{
GenerationPath: generationPath,
Services: []string{"starknet"},
}),
sedgeActions.EXPECT().RunContainers(actions.RunContainersOptions{
GenerationPath: generationPath,
Services: []string{"starknet"},
}),
)
},
},
{
name: "starknet node with execution and consensus",
setup: func(t *testing.T, sedgeActions *sedge_mocks.MockSedgeActions, prompter *sedge_mocks.MockPrompter, depsMgr *sedge_mocks.MockDependenciesManager) {
generationPath := t.TempDir()
genData := generate.GenData{
Services: []string{"starknet", "execution", "consensus"},
StarknetClient: &clients.Client{
Name: "juno",
Type: "starknet",
Image: configs.ClientImages.Starknet.Juno.String(),
},
ExecutionClient: &clients.Client{
Name: "nethermind",
Type: "execution",
Image: configs.ClientImages.Execution.Nethermind.String(),
},
ConsensusClient: &clients.Client{
Name: "prysm",
Type: "consensus",
Image: configs.ClientImages.Consensus.Prysm.String(),
},
Network: "mainnet",
CheckpointSyncUrl: "http://checkpoint.sync",
FeeRecipient: "0x2d07a21ebadde0c13e6b91022a7e5722eb6bf5d5",
MapAllPorts: true,
SLStartGracePeriod: 840,
ContainerTag: "tag",
JWTSecretPath: filepath.Join(generationPath, "jwtsecret"),
}
sedgeActions.EXPECT().GetCommandRunner().Return(&test.SimpleCMDRunner{})
gomock.InOrder(
prompter.EXPECT().Select("Select network", "", []string{NetworkMainnet, NetworkGoerli, NetworkSepolia, NetworkGnosis, NetworkChiado}).Return(0, nil),
prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator, NodeTypeStarknet}).Return(0, nil),
prompter.EXPECT().Input("Generation path", configs.DefaultAbsSedgeDataPath, false, nil).Return(generationPath, nil),
prompter.EXPECT().Input("Container tag, sedge will add to each container and the network, a suffix with the tag", "", false, nil).Return("tag", nil),
prompter.EXPECT().Select("Select starknet client", "", ETHClients["starknet"]).Return(0, nil),
prompter.EXPECT().Confirm("Do you want to set up a full starknet node (with execution and consensus)?", true).Return(true, nil),
prompter.EXPECT().Select("Select execution client", "", ETHClients["execution"]).Return(0, nil),
prompter.EXPECT().Select("Select consensus client", "", ETHClients["consensus"]).Return(1, nil),
prompter.EXPECT().InputInt64("Starknet grace period. This is the number of epochs the starknet client will wait before starting", int64(1)).Return(int64(2), nil),
prompter.EXPECT().InputURL("Checkpoint sync URL", configs.NetworksConfigs()[genData.Network].CheckpointSyncURL, false).Return("http://checkpoint.sync", nil),
prompter.EXPECT().EthAddress("Please enter the Fee Recipient address (press enter to skip it)", "", false).Return("0x2d07a21ebadde0c13e6b91022a7e5722eb6bf5d5", nil),
prompter.EXPECT().Confirm("Do you want to expose all ports?", false).Return(true, nil),
prompter.EXPECT().Select("Select JWT source", "", []string{SourceTypeCreate, SourceTypeExisting}).Return(0, nil),
sedgeActions.EXPECT().Generate(gomock.Eq(actions.GenerateOptions{
GenerationPath: generationPath,
Expand All @@ -568,6 +507,7 @@ func TestCli(t *testing.T) {
)
},
},

}

for _, tt := range tests {
Expand All @@ -584,4 +524,4 @@ func TestCli(t *testing.T) {
c.Execute()
})
}
}
}
51 changes: 16 additions & 35 deletions cli/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1380,64 +1380,45 @@ func TestGenerateCmd(t *testing.T) {
consensusName: "teku",
},
globalFlags{
install: false,
generationPath: "",
network: "",
logging: "",
network: "mainnet",
},
nil,
},
{
"Starknet, missing execution api url",
"starknet with full flag and Fixed clients",
subCmd{
name: "starknet",
args: []string{"juno"},
},
GenCmdFlags{},
globalFlags{
install: false,
generationPath: "",
network: "",
logging: "",
},
errors.New("required flag(s) \"execution-api-url\" not set"),
},
{
"Starknet, correct number of arguments with client name",
subCmd{
name: "starknet",
args: []string{"juno"},
args: []string{},
},
GenCmdFlags{
executionApiUrl: "ws://localhost:8545",
pendingPollInterval: "5s",
executionName: "nethermind",
consensusName: "lighthouse",
full: true,
feeRecipient: "0x0000000000000000000000000000000000000000",
},
globalFlags{
install: false,
generationPath: "",
network: "",
logging: "",
install: false,
logging: "",
},
nil,
},
{
"Starknet, with full flag",
"full-node Random clients, no feeRecipient",
subCmd{
name: "starknet",
args: []string{" "},
args: []string{},
},
GenCmdFlags{
full: true,
},
globalFlags{
install: false,
generationPath: "",
network: "",
logging: "",
install: false,
logging: "",
},
errors.New("requires one argument"),
nil,
},
}
}

// TODO: Add test cases for Execution fallback urls
// TODO: Add test cases for EL and CL bootnodes in full-node

Expand Down

0 comments on commit bdfc4d0

Please sign in to comment.