The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/internal/configs/node/config_test.go

50 lines
951 B

package nodeconfig
import (
"testing"
)
func TestNodeConfigSingleton(t *testing.T) {
// init 3 configs
_ = GetShardConfig(2)
// get the singleton variable
c := GetShardConfig(Global)
c.SetBeaconGroupID(GroupIDBeacon)
d := GetShardConfig(Global)
g := d.GetBeaconGroupID()
if g != GroupIDBeacon {
t.Errorf("GetBeaconGroupID = %v, expected = %v", g, GroupIDBeacon)
}
}
func TestNodeConfigMultiple(t *testing.T) {
// init 3 configs
d := GetShardConfig(1)
e := GetShardConfig(0)
f := GetShardConfig(42)
if f != nil {
t.Errorf("expecting nil, got: %v", f)
}
d.SetShardGroupID("abcd")
if d.GetShardGroupID() != "abcd" {
t.Errorf("expecting abcd, got: %v", d.GetShardGroupID())
}
e.SetClientGroupID("client")
if e.GetClientGroupID() != "client" {
t.Errorf("expecting client, got: %v", d.GetClientGroupID())
}
e.SetIsClient(false)
if e.IsClient() != false {
t.Errorf("expecting false, got: %v", e.IsClient())
}
}