// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package handler

import (
	"testing"

	"github.com/stretchr/testify/require"

	"github.com/ava-labs/avalanchego/proto/pb/p2p"
)

func TestEngineManager_Get(t *testing.T) {
	type args struct {
		engineType p2p.EngineType
	}

	dag := &Engine{}
	chain := &Engine{}

	type expected struct {
		engine *Engine
	}

	tests := []struct {
		name     string
		args     args
		expected expected
	}{
		{
			name: "request unspecified engine",
			args: args{
				engineType: p2p.EngineType_ENGINE_TYPE_UNSPECIFIED,
			},
			expected: expected{
				engine: nil,
			},
		},
		{
			name: "request dag engine",
			args: args{
				engineType: p2p.EngineType_ENGINE_TYPE_DAG,
			},
			expected: expected{
				engine: dag,
			},
		},
		{
			name: "request chain engine",
			args: args{
				engineType: p2p.EngineType_ENGINE_TYPE_CHAIN,
			},
			expected: expected{
				engine: chain,
			},
		},
	}
	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			e := EngineManager{
				DAG:   dag,
				Chain: chain,
			}

			require.Equal(t, test.expected.engine, e.Get(test.args.engineType))
		})
	}
}
