2019-03-12 23:39:13 +00:00
|
|
|
package forkutil
|
2019-02-06 05:34:22 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
|
|
)
|
|
|
|
|
2019-02-22 15:11:26 +00:00
|
|
|
func TestForkVersion_OK(t *testing.T) {
|
2019-02-06 05:34:22 +00:00
|
|
|
fork := &pb.Fork{
|
|
|
|
Epoch: 10,
|
|
|
|
PreviousVersion: 2,
|
|
|
|
CurrentVersion: 3,
|
|
|
|
}
|
|
|
|
|
|
|
|
if ForkVersion(fork, 9) != 2 {
|
|
|
|
t.Errorf("fork Version not equal to 2 %d", ForkVersion(fork, 9))
|
|
|
|
}
|
|
|
|
|
|
|
|
if ForkVersion(fork, 11) != 3 {
|
|
|
|
t.Errorf("fork Version not equal to 3 %d", ForkVersion(fork, 11))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-22 15:11:26 +00:00
|
|
|
func TestDomainVersion_OK(t *testing.T) {
|
2019-02-06 05:34:22 +00:00
|
|
|
fork := &pb.Fork{
|
|
|
|
Epoch: 10,
|
|
|
|
PreviousVersion: 2,
|
|
|
|
CurrentVersion: 3,
|
|
|
|
}
|
|
|
|
|
|
|
|
constant := uint64(math.Pow(2, 32))
|
|
|
|
|
|
|
|
if DomainVersion(fork, 9, 2) != 2*constant+2 {
|
|
|
|
t.Errorf("incorrect domain version %d", DomainVersion(fork, 9, 2))
|
|
|
|
}
|
|
|
|
|
|
|
|
if DomainVersion(fork, 11, 3) != 3*constant+3 {
|
|
|
|
t.Errorf("incorrect domain version %d", DomainVersion(fork, 11, 3))
|
|
|
|
}
|
|
|
|
}
|