github.com/xiaqingdoc/fabric@v2.1.1+incompatible/core/handlers/auth/filter/filter_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package filter
     8  
     9  import (
    10  	"context"
    11  	"testing"
    12  
    13  	"github.com/hyperledger/fabric-protos-go/peer"
    14  	"github.com/stretchr/testify/assert"
    15  )
    16  
    17  type mockEndorserServer struct {
    18  	invoked bool
    19  }
    20  
    21  func (es *mockEndorserServer) ProcessProposal(context.Context, *peer.SignedProposal) (*peer.ProposalResponse, error) {
    22  	es.invoked = true
    23  	return nil, nil
    24  }
    25  
    26  func TestFilter(t *testing.T) {
    27  	auth := NewFilter()
    28  	nextEndorser := &mockEndorserServer{}
    29  	auth.Init(nextEndorser)
    30  	auth.ProcessProposal(nil, nil)
    31  	assert.True(t, nextEndorser.invoked)
    32  }