Some checks are pending
docker-build-cometbft / vars (push) Waiting to run
docker-build-cometbft / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-cometbft / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-cometbft / merge-images (push) Blocked by required conditions
docker-build-e2e-node / vars (push) Waiting to run
docker-build-e2e-node / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-e2e-node / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-e2e-node / merge-images (push) Blocked by required conditions
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package store
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"git.cw.tr/mukan-network/mukan-consensus/internal/test"
|
|
"git.cw.tr/mukan-network/mukan-consensus/types"
|
|
cmttime "git.cw.tr/mukan-network/mukan-consensus/types/time"
|
|
)
|
|
|
|
// TestLoadBlockExtendedCommit tests loading the extended commit for a previously
|
|
// saved block. The load method should return nil when only a commit was saved and
|
|
// return the extended commit otherwise.
|
|
func BenchmarkRepeatedLoadSeenCommitSameBlock(b *testing.B) {
|
|
state, bs, cleanup := makeStateAndBlockStore()
|
|
defer cleanup()
|
|
h := bs.Height() + 1
|
|
block, err := state.MakeBlock(h, test.MakeNTxs(h, 10), new(types.Commit), nil, state.Validators.GetProposer().Address)
|
|
require.NoError(b, err)
|
|
seenCommit := makeTestExtCommitWithNumSigs(block.Header.Height, cmttime.Now(), 100).ToCommit()
|
|
ps, err := block.MakePartSet(types.BlockPartSizeBytes)
|
|
require.NoError(b, err)
|
|
bs.SaveBlock(block, ps, seenCommit)
|
|
|
|
// sanity check
|
|
res := bs.LoadSeenCommit(block.Height)
|
|
require.Equal(b, seenCommit, res)
|
|
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
res := bs.LoadSeenCommit(block.Height)
|
|
require.NotNil(b, res)
|
|
}
|
|
}
|