diff --git a/services/blockheight/test/block_height_test.go b/services/blockheight/test/block_height_test.go new file mode 100644 index 0000000..9bfb7cb --- /dev/null +++ b/services/blockheight/test/block_height_test.go @@ -0,0 +1,29 @@ +// Copyright 2019 the lean-helix-go authors +// This file is part of the lean-helix-go library in the Orbs project. +// +// This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. +// The above notice should be included in all copies or substantial portions of the software. + +package test + +import ( + "github.com/orbs-network/lean-helix-go/services/blockheight" + "github.com/orbs-network/lean-helix-go/services/interfaces" + "github.com/orbs-network/lean-helix-go/spec/types/go/primitives" + "github.com/orbs-network/lean-helix-go/test/mocks" + "github.com/stretchr/testify/require" + "testing" +) + +func TestGenesisBlockHeight(t *testing.T) { + actual := blockheight.GetBlockHeight(interfaces.GenesisBlock) + require.Equal(t, primitives.BlockHeight(0), actual) +} + +func TestBasicBlockHeight(t *testing.T) { + block1 := mocks.ABlock(interfaces.GenesisBlock) + block2 := mocks.ABlock(block1) + block3 := mocks.ABlock(block2) + actual := blockheight.GetBlockHeight(block3) + require.Equal(t, primitives.BlockHeight(3), actual) +} diff --git a/services/quorum/test/quorum_test.go b/services/quorum/test/quorum_test.go index 9bfb7cb..ff94f2a 100644 --- a/services/quorum/test/quorum_test.go +++ b/services/quorum/test/quorum_test.go @@ -7,23 +7,22 @@ package test import ( - "github.com/orbs-network/lean-helix-go/services/blockheight" - "github.com/orbs-network/lean-helix-go/services/interfaces" - "github.com/orbs-network/lean-helix-go/spec/types/go/primitives" - "github.com/orbs-network/lean-helix-go/test/mocks" + "github.com/orbs-network/lean-helix-go/services/quorum" "github.com/stretchr/testify/require" "testing" ) -func TestGenesisBlockHeight(t *testing.T) { - actual := blockheight.GetBlockHeight(interfaces.GenesisBlock) - require.Equal(t, primitives.BlockHeight(0), actual) -} - -func TestBasicBlockHeight(t *testing.T) { - block1 := mocks.ABlock(interfaces.GenesisBlock) - block2 := mocks.ABlock(block1) - block3 := mocks.ABlock(block2) - actual := blockheight.GetBlockHeight(block3) - require.Equal(t, primitives.BlockHeight(3), actual) +func TestCommitteeQuorum(t *testing.T) { + require.Equal(t, 3, quorum.CalcQuorumSize(4)) + require.Equal(t, 4, quorum.CalcQuorumSize(5)) + require.Equal(t, 5, quorum.CalcQuorumSize(6)) + require.Equal(t, 5, quorum.CalcQuorumSize(7)) + require.Equal(t, 6, quorum.CalcQuorumSize(8)) + require.Equal(t, 7, quorum.CalcQuorumSize(9)) + require.Equal(t, 7, quorum.CalcQuorumSize(10)) + require.Equal(t, 8, quorum.CalcQuorumSize(11)) + require.Equal(t, 9, quorum.CalcQuorumSize(12)) + require.Equal(t, 15, quorum.CalcQuorumSize(21)) + require.Equal(t, 15, quorum.CalcQuorumSize(22)) + require.Equal(t, 67, quorum.CalcQuorumSize(100)) } diff --git a/spec/types/go/primitives/lean_helix_primitives.mb.go b/spec/types/go/primitives/lean_helix_primitives.mb.go index 04bd3dd..98909fa 100644 --- a/spec/types/go/primitives/lean_helix_primitives.mb.go +++ b/spec/types/go/primitives/lean_helix_primitives.mb.go @@ -1,3 +1,9 @@ +// Copyright 2019 the lean-helix-go authors +// This file is part of the lean-helix-go library in the Orbs project. +// +// This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. +// The above notice should be included in all copies or substantial portions of the software. + // AUTO GENERATED FILE (by membufc proto compiler v0.0.32) package primitives diff --git a/spec/types/go/protocol/lean_helix.mb.go b/spec/types/go/protocol/lean_helix.mb.go index 5f61033..5612f80 100644 --- a/spec/types/go/protocol/lean_helix.mb.go +++ b/spec/types/go/protocol/lean_helix.mb.go @@ -1,3 +1,9 @@ +// Copyright 2019 the lean-helix-go authors +// This file is part of the lean-helix-go library in the Orbs project. +// +// This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. +// The above notice should be included in all copies or substantial portions of the software. + // AUTO GENERATED FILE (by membufc proto compiler v0.0.32) package protocol