github.com/turingchain2020/turingchain@v1.1.21/util/calccommit_test.go (about) 1 // Copyright Turing Corp. 2018 All Rights Reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package util 6 7 import ( 8 "testing" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestGetMostCommit(t *testing.T) { 14 commits := [][]byte{[]byte("aa"), []byte("bb"), []byte("aa"), []byte("aa")} 15 16 most, key := GetMostCommit(commits) 17 18 assert.Equal(t, 3, most) 19 assert.Equal(t, "aa", key) 20 } 21 22 func TestIsCommitDone(t *testing.T) { 23 done := IsCommitDone(4, 2) 24 assert.Equal(t, false, done) 25 26 done = IsCommitDone(4, 3) 27 assert.Equal(t, true, done) 28 29 }