Skip to content

Commit

Permalink
pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
noambergIL committed Apr 5, 2020
1 parent 7ec9070 commit eced6fd
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 15 deletions.
29 changes: 29 additions & 0 deletions services/blockheight/test/block_height_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
29 changes: 14 additions & 15 deletions services/quorum/test/quorum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
6 changes: 6 additions & 0 deletions spec/types/go/primitives/lean_helix_primitives.mb.go
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 6 additions & 0 deletions spec/types/go/protocol/lean_helix.mb.go
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit eced6fd

Please sign in to comment.