prysm-pulse/shared/slotutil/slottime_test.go
Victor Farazdagi b577869ed6
Fixes import aliases (#8497)
* Fixes import aliases

* another fix

* reset gw files

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2021-02-22 23:20:57 +00:00

44 lines
875 B
Go

package slotutil
import (
"testing"
"time"
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/timeutils"
)
func TestSlotsSinceGenesis(t *testing.T) {
type args struct {
genesis time.Time
}
tests := []struct {
name string
args args
want types.Slot
}{
{
name: "pre-genesis",
args: args{
genesis: timeutils.Now().Add(1 * time.Hour), // 1 hour in the future
},
want: 0,
},
{
name: "post-genesis",
args: args{
genesis: timeutils.Now().Add(-5 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second),
},
want: 5,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := SlotsSinceGenesis(tt.args.genesis); got != tt.want {
t.Errorf("SlotsSinceGenesis() = %v, want %v", got, tt.want)
}
})
}
}