Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
18aaddy committed Nov 4, 2024
1 parent 3f50496 commit 3a98e39
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
45 changes: 45 additions & 0 deletions consensus/main/consensus_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"testing"
"fmt"
"github.com/BlocSoc-iitr/selene/config"
"github.com/BlocSoc-iitr/selene/consensus"
Common "github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
)

func CreateNewConsensus() consensus.ConsensusClient {
var n config.Network
baseConfig, err := n.BaseConfig("MAINNET")
if err != nil {
fmt.Printf("Error in base config creation: %v", err)
}

checkpoint := "b21924031f38635d45297d68e7b7a408d40b194d435b25eeccad41c522841bd5"
consensusRpcUrl := "http://testing.mainnet.beacon-api.nimbus.team"
executionRpcUrl := "https://eth-mainnet.g.alchemy.com/v2/j28GcevSYukh-GvSeBOYcwHOfIggF1Gt"

config := &config.Config{
ConsensusRpc: consensusRpcUrl,
ExecutionRpc: executionRpcUrl,
RpcBindIp: &baseConfig.RpcBindIp,
RpcPort: &baseConfig.RpcPort,
DefaultCheckpoint: baseConfig.DefaultCheckpoint,
Checkpoint: (*[32]byte)(Common.Hex2Bytes(checkpoint)),
Chain: baseConfig.Chain,
Forks: baseConfig.Forks,
StrictCheckpointAge: false,
DataDir: baseConfig.DataDir,
DatabaseType: nil,
MaxCheckpointAge: baseConfig.MaxCheckpointAge,
LoadExternalFallback: false,
}
return consensus.ConsensusClient{}.New(&consensusRpcUrl, *config)
}

func TestShutdown(t *testing.T) {
consensusClient := CreateNewConsensus()
err := consensusClient.Shutdown()
assert.NoError(t, err, "Found Error")
}
42 changes: 42 additions & 0 deletions consensus/main/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"fmt"
"github.com/BlocSoc-iitr/selene/config"
"github.com/BlocSoc-iitr/selene/consensus"
Common "github.com/ethereum/go-ethereum/common"
)

func main() {
var n config.Network
baseConfig, err := n.BaseConfig("MAINNET")
if err != nil {
fmt.Printf("Error in base config creation: %v", err)
}

checkpoint := "b21924031f38635d45297d68e7b7a408d40b194d435b25eeccad41c522841bd5"
consensusRpcUrl := "http://testing.mainnet.beacon-api.nimbus.team"
executionRpcUrl := "https://eth-mainnet.g.alchemy.com/v2/j28GcevSYukh-GvSeBOYcwHOfIggF1Gt"

config := &config.Config{
ConsensusRpc: consensusRpcUrl,
ExecutionRpc: executionRpcUrl,
RpcBindIp: &baseConfig.RpcBindIp,
RpcPort: &baseConfig.RpcPort,
DefaultCheckpoint: baseConfig.DefaultCheckpoint,
Checkpoint: (*[32]byte)(Common.Hex2Bytes(checkpoint)),
Chain: baseConfig.Chain,
Forks: baseConfig.Forks,
StrictCheckpointAge: false,
DataDir: baseConfig.DataDir,
DatabaseType: nil,
MaxCheckpointAge: baseConfig.MaxCheckpointAge,
LoadExternalFallback: false,
}
consensusClient := consensus.ConsensusClient{}.New(&consensusRpcUrl, *config)

err = consensusClient.Shutdown()
if err != nil {
fmt.Println("Found error in shutting down: ", err)
}
}

0 comments on commit 3a98e39

Please sign in to comment.