Skip to content

Commit

Permalink
Merge branch 'master' into uptime-interfaces-pkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyonur committed Nov 5, 2024
2 parents ad44a00 + 8a6df9e commit e987b9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions plugin/evm/uptime/pausable_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (p *pausableManager) StartTracking(nodeIDs []ids.NodeID) error {

// OnValidatorAdded is called when a validator is added.
// If the node is inactive, it will be paused.
func (p *pausableManager) OnValidatorAdded(vID ids.ID, nodeID ids.NodeID, startTime uint64, isActive bool) {
func (p *pausableManager) OnValidatorAdded(_ ids.ID, nodeID ids.NodeID, _ uint64, isActive bool) {
if !isActive {
err := p.pause(nodeID)
if err != nil {
Expand All @@ -83,7 +83,7 @@ func (p *pausableManager) OnValidatorAdded(vID ids.ID, nodeID ids.NodeID, startT

// OnValidatorRemoved is called when a validator is removed.
// If the node is already paused, it will be resumed.
func (p *pausableManager) OnValidatorRemoved(vID ids.ID, nodeID ids.NodeID) {
func (p *pausableManager) OnValidatorRemoved(_ ids.ID, nodeID ids.NodeID) {
if p.IsPaused(nodeID) {
err := p.resume(nodeID)
if err != nil {
Expand All @@ -94,7 +94,7 @@ func (p *pausableManager) OnValidatorRemoved(vID ids.ID, nodeID ids.NodeID) {

// OnValidatorStatusUpdated is called when the status of a validator is updated.
// If the node is active, it will be resumed. If the node is inactive, it will be paused.
func (p *pausableManager) OnValidatorStatusUpdated(vID ids.ID, nodeID ids.NodeID, isActive bool) {
func (p *pausableManager) OnValidatorStatusUpdated(_ ids.ID, nodeID ids.NodeID, isActive bool) {
var err error
if isActive {
err = p.resume(nodeID)
Expand Down
9 changes: 8 additions & 1 deletion plugin/evm/uptime/pausable_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func TestPausableManager(t *testing.T) {
vID := ids.GenerateTestID()
nodeID0 := ids.GenerateTestNodeID()
startTime := time.Now()
require := require.New(t)

tests := []struct {
name string
Expand All @@ -27,6 +26,8 @@ func TestPausableManager(t *testing.T) {
{
name: "Case 1: Connect, pause, start tracking",
testFunc: func(t *testing.T, up interfaces.PausableManager, clk *mockable.Clock, s uptime.State) {
require := require.New(t)

// Connect before tracking
require.NoError(up.Connect(nodeID0))
addTime(clk, time.Second)
Expand Down Expand Up @@ -54,6 +55,8 @@ func TestPausableManager(t *testing.T) {
{
name: "Case 2: Start tracking, connect, pause, re-connect, resume",
testFunc: func(t *testing.T, up interfaces.PausableManager, clk *mockable.Clock, s uptime.State) {
require := require.New(t)

// Start tracking
require.NoError(up.StartTracking([]ids.NodeID{nodeID0}))

Expand Down Expand Up @@ -103,6 +106,8 @@ func TestPausableManager(t *testing.T) {
{
name: "Case 3: Pause, start tracking, connect, re-connect, resume",
testFunc: func(t *testing.T, up interfaces.PausableManager, clk *mockable.Clock, s uptime.State) {
require := require.New(t)

// Pause before tracking
up.OnValidatorStatusUpdated(vID, nodeID0, false)
require.True(up.IsPaused(nodeID0))
Expand Down Expand Up @@ -143,6 +148,8 @@ func TestPausableManager(t *testing.T) {
{
name: "Case 4: Start tracking, connect, pause, stop tracking, resume tracking",
testFunc: func(t *testing.T, up interfaces.PausableManager, clk *mockable.Clock, s uptime.State) {
require := require.New(t)

// Start tracking and connect
require.NoError(up.StartTracking([]ids.NodeID{nodeID0}))
addTime(clk, time.Second)
Expand Down

0 comments on commit e987b9b

Please sign in to comment.