mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-03 18:42:14 +00:00
* Rebased and git-squashed the commits in PR #6546 migrate abci to finalizeBlock work on abci, proxy and mempool abciresponse, blok events, indexer, some tests fix some tests fix errors fix errors in abci fix tests amd errors * Fixes after rebasing PR#6546 * Restored height to RequestFinalizeBlock & other * Fixed more UTs * Fixed kvstore * More UT fixes * last TC fixed * make format * Update internal/consensus/mempool_test.go Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com> * Addressed @williambanfield's comments * Fixed UTs * Addressed last comments from @williambanfield * make format Co-authored-by: marbar3778 <marbar3778@yahoo.com> Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
61 lines
1.8 KiB
Go
61 lines
1.8 KiB
Go
package p2p
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
"github.com/tendermint/tendermint/types"
|
|
)
|
|
|
|
func TestRouter_ConstructQueueFactory(t *testing.T) {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
t.Run("ValidateOptionsPopulatesDefaultQueue", func(t *testing.T) {
|
|
opts := RouterOptions{}
|
|
require.NoError(t, opts.Validate())
|
|
require.Equal(t, "fifo", opts.QueueType)
|
|
})
|
|
t.Run("Default", func(t *testing.T) {
|
|
require.Zero(t, os.Getenv("TM_P2P_QUEUE"))
|
|
opts := RouterOptions{}
|
|
r, err := NewRouter(ctx, log.NewNopLogger(), nil, types.NodeInfo{}, nil, nil, nil, nil, opts)
|
|
require.NoError(t, err)
|
|
_, ok := r.queueFactory(1).(*fifoQueue)
|
|
require.True(t, ok)
|
|
})
|
|
t.Run("Fifo", func(t *testing.T) {
|
|
opts := RouterOptions{QueueType: queueTypeFifo}
|
|
r, err := NewRouter(ctx, log.NewNopLogger(), nil, types.NodeInfo{}, nil, nil, nil, nil, opts)
|
|
require.NoError(t, err)
|
|
_, ok := r.queueFactory(1).(*fifoQueue)
|
|
require.True(t, ok)
|
|
})
|
|
t.Run("Priority", func(t *testing.T) {
|
|
opts := RouterOptions{QueueType: queueTypePriority}
|
|
r, err := NewRouter(ctx, log.NewNopLogger(), nil, types.NodeInfo{}, nil, nil, nil, nil, opts)
|
|
require.NoError(t, err)
|
|
q, ok := r.queueFactory(1).(*pqScheduler)
|
|
require.True(t, ok)
|
|
defer q.close()
|
|
})
|
|
t.Run("NonExistant", func(t *testing.T) {
|
|
opts := RouterOptions{QueueType: "fast"}
|
|
_, err := NewRouter(ctx, log.NewNopLogger(), nil, types.NodeInfo{}, nil, nil, nil, nil, opts)
|
|
require.Error(t, err)
|
|
require.Contains(t, err.Error(), "fast")
|
|
})
|
|
t.Run("InternalsSafeWhenUnspecified", func(t *testing.T) {
|
|
r := &Router{}
|
|
require.Zero(t, r.options.QueueType)
|
|
|
|
fn, err := r.createQueueFactory(ctx)
|
|
require.Error(t, err)
|
|
require.Nil(t, fn)
|
|
})
|
|
}
|