github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/internal/pkg/gateway/peeradapter_test.go (about)

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package gateway
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/hechain20/hechain/core/peer"
    13  	"github.com/stretchr/testify/require"
    14  )
    15  
    16  func TestPeerAdapter(t *testing.T) {
    17  	t.Run("CommitNotifications", func(t *testing.T) {
    18  		t.Run("returns error when channel does not exist", func(t *testing.T) {
    19  			adapter := &peerAdapter{
    20  				Peer: &peer.Peer{},
    21  			}
    22  
    23  			_, err := adapter.CommitNotifications(nil, "CHANNEL")
    24  
    25  			require.ErrorContains(t, err, "CHANNEL")
    26  		})
    27  	})
    28  
    29  	t.Run("TransactionStatus", func(t *testing.T) {
    30  		t.Run("returns error when channel does not exist", func(t *testing.T) {
    31  			adapter := &peerAdapter{
    32  				Peer: &peer.Peer{},
    33  			}
    34  
    35  			_, _, err := adapter.TransactionStatus("CHANNEL", "TX_ID")
    36  
    37  			require.ErrorContains(t, err, "CHANNEL")
    38  		})
    39  	})
    40  
    41  	t.Run("Ledger", func(t *testing.T) {
    42  		t.Run("returns error when channel does not exist", func(t *testing.T) {
    43  			adapter := &peerAdapter{
    44  				Peer: &peer.Peer{},
    45  			}
    46  
    47  			_, err := adapter.Ledger("CHANNEL")
    48  
    49  			require.ErrorContains(t, err, "CHANNEL")
    50  		})
    51  	})
    52  }