func (s *Session) CheckRequestContext(ctx *kvrpcpb.Context) *errorpb.Error {
	ctxPeer := ctx.GetPeer()
	if ctxPeer != nil && ctxPeer.GetStoreId() != s.storeID {
		return &errorpb.Error{
			Message:       *proto.String("store not match"),
			StoreNotMatch: &errorpb.StoreNotMatch{},
		}
	}
	region, leaderID := s.cluster.GetRegion(ctx.GetRegionId())
	if region == nil {
		return &errorpb.Error{
			Message: *proto.String("region not found"),
			RegionNotFound: &errorpb.RegionNotFound{
				RegionId: *proto.Uint64(ctx.GetRegionId()),
			},
		}
	}
	var storePeer, leaderPeer *metapb.Peer
	for _, p := range region.Peers {
		if p.GetStoreId() == s.storeID {
			storePeer = p
		}
		if p.GetId() == leaderID {
			leaderPeer = p
		}
	}
	if storePeer == nil {
		return &errorpb.Error{
			Message: *proto.String("region not found"),
			RegionNotFound: &errorpb.RegionNotFound{
				RegionId: *proto.Uint64(ctx.GetRegionId()),
			},
		}
	}
	if leaderPeer == nil {
		return &errorpb.Error{
			Message: *proto.String("no leader"),
			NotLeader: &errorpb.NotLeader{
				RegionId: *proto.Uint64(ctx.GetRegionId()),
			},
		}
	}
	if storePeer.GetId() != leaderPeer.GetId() && !isTiFlashStore(s.cluster.GetStore(storePeer.GetStoreId())) {
		return &errorpb.Error{
			Message: *proto.String("not leader"),
			NotLeader: &errorpb.NotLeader{
				RegionId: *proto.Uint64(ctx.GetRegionId()),
				Leader:   leaderPeer,
			},
		}
	}
	if !proto.Equal(region.GetRegionEpoch(), ctx.GetRegionEpoch()) {
		nextRegion, _ := s.cluster.GetRegionByKey(region.GetEndKey())
		currentRegions := []*metapb.Region{region}
		if nextRegion != nil {
			currentRegions = append(currentRegions, nextRegion)
		}
		return &errorpb.Error{
			Message: *proto.String("epoch not match"),
			EpochNotMatch: &errorpb.EpochNotMatch{
				CurrentRegions: currentRegions,
			},
		}
	}
	s.startKey, s.endKey = region.StartKey, region.EndKey
	s.isolationLevel = ctx.IsolationLevel
	s.resolvedLocks = ctx.ResolvedLocks
	return nil
}
CheckRequestContext checks if the context matches the request status.
package mocktikv
import (
	"github.com/gogo/protobuf/proto"
	"github.com/pingcap/kvproto/pkg/errorpb"
	"github.com/pingcap/kvproto/pkg/kvrpcpb"
	"github.com/pingcap/kvproto/pkg/metapb"
)
type Session struct {
	cluster   *Cluster
	mvccStore MVCCStore
	storeID uint64
	startKey []byte
	endKey   []byte
	rawStartKey []byte
	rawEndKey   []byte
	isolationLevel kvrpcpb.IsolationLevel
	resolvedLocks  []uint64
}
func (s *Session) GetIsolationLevel() kvrpcpb.IsolationLevel {
	return s.isolationLevel
}
func (s *Session) GetMVCCStore() MVCCStore {
	return s.mvccStore
}
func (s *Session) GetRawStartKey() []byte {
	return s.rawStartKey
}
func (s *Session) GetRawEndKey() []byte {
	return s.rawEndKey
}
func (s *Session) GetResolvedLocks() []uint64 {
	return s.resolvedLocks
}