Skip to content

Commit

Permalink
remove unused method (#2337)
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvanloon authored Apr 22, 2019
1 parent d00350b commit 19c24ec
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
15 changes: 0 additions & 15 deletions shared/slotutil/slotticker.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,6 @@ func GetSlotTicker(genesisTime time.Time, secondsPerSlot uint64) *SlotTicker {
return ticker
}

// CurrentSlot accepts the genesis time and returns the current time's slot.
func CurrentSlot(
genesisTime time.Time,
secondsPerSlot uint64,
since func(time.Time) time.Duration) uint64 {

sinceGenesis := since(genesisTime)
if sinceGenesis < 0 {
return params.BeaconConfig().GenesisSlot
}

durationInSeconds := time.Duration(secondsPerSlot) * time.Second
return uint64(sinceGenesis/durationInSeconds) + params.BeaconConfig().GenesisSlot
}

func (s *SlotTicker) start(
genesisTime time.Time,
secondsPerSlot uint64,
Expand Down
17 changes: 0 additions & 17 deletions shared/slotutil/slotticker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,3 @@ func TestSlotTickerGenesis(t *testing.T) {
t.Fatalf("Expected %d, got %d", params.BeaconConfig().GenesisSlot+1, slot)
}
}

func TestCurrentSlot(t *testing.T) {
// Test genesis slot
genesisTime := time.Now()
secondsPerSlot := time.Second * time.Duration(params.BeaconConfig().SecondsPerSlot)
slot := CurrentSlot(genesisTime, params.BeaconConfig().SecondsPerSlot, time.Since)
if slot != params.BeaconConfig().GenesisSlot {
t.Errorf("Expected %d, got: %d", params.BeaconConfig().GenesisSlot, slot)
}

// Test slot 3 after genesis.
genesisTime = genesisTime.Add(secondsPerSlot * 3)
slot = CurrentSlot(genesisTime, params.BeaconConfig().SecondsPerSlot, time.Since)
if slot != 3*params.BeaconConfig().GenesisSlot {
t.Errorf("Expected %d, got: %d", params.BeaconConfig().GenesisSlot*3, slot)
}
}

0 comments on commit 19c24ec

Please sign in to comment.