github.com/Consensys/quorum@v21.1.0+incompatible/plugin/account/internal/testutils/matchers.go (about)

     1  package testutils
     2  
     3  import (
     4  	"fmt"
     5  
     6  	protobuf "github.com/golang/protobuf/proto"
     7  	"github.com/jpmorganchase/quorum-account-plugin-sdk-go/proto"
     8  )
     9  
    10  type StatusRequestMatcher struct {
    11  	R *proto.StatusRequest
    12  }
    13  
    14  func (m StatusRequestMatcher) Matches(x interface{}) bool {
    15  	r, ok := x.(*proto.StatusRequest)
    16  	if !ok {
    17  		return false
    18  	}
    19  	return protobuf.Equal(m.R, r)
    20  }
    21  
    22  func (m StatusRequestMatcher) String() string {
    23  	return fmt.Sprintf("is %v", m.R)
    24  }
    25  
    26  type OpenRequestMatcher struct {
    27  	R *proto.OpenRequest
    28  }
    29  
    30  func (m OpenRequestMatcher) Matches(x interface{}) bool {
    31  	r, ok := x.(*proto.OpenRequest)
    32  	if !ok {
    33  		return false
    34  	}
    35  	return protobuf.Equal(m.R, r)
    36  }
    37  
    38  func (m OpenRequestMatcher) String() string {
    39  	return fmt.Sprintf("is %v", m.R)
    40  }
    41  
    42  type CloseRequestMatcher struct {
    43  	R *proto.CloseRequest
    44  }
    45  
    46  func (m CloseRequestMatcher) Matches(x interface{}) bool {
    47  	r, ok := x.(*proto.CloseRequest)
    48  	if !ok {
    49  		return false
    50  	}
    51  	return protobuf.Equal(m.R, r)
    52  }
    53  
    54  func (m CloseRequestMatcher) String() string {
    55  	return fmt.Sprintf("is %v", m.R)
    56  }
    57  
    58  type AccountsRequestMatcher struct {
    59  	R *proto.AccountsRequest
    60  }
    61  
    62  func (m AccountsRequestMatcher) Matches(x interface{}) bool {
    63  	r, ok := x.(*proto.AccountsRequest)
    64  	if !ok {
    65  		return false
    66  	}
    67  	return protobuf.Equal(m.R, r)
    68  }
    69  
    70  func (m AccountsRequestMatcher) String() string {
    71  	return fmt.Sprintf("is %v", m.R)
    72  }
    73  
    74  type ContainsRequestMatcher struct {
    75  	R *proto.ContainsRequest
    76  }
    77  
    78  func (m ContainsRequestMatcher) Matches(x interface{}) bool {
    79  	r, ok := x.(*proto.ContainsRequest)
    80  	if !ok {
    81  		return false
    82  	}
    83  	return protobuf.Equal(m.R, r)
    84  }
    85  
    86  func (m ContainsRequestMatcher) String() string {
    87  	return fmt.Sprintf("is %v", m.R)
    88  }
    89  
    90  type SignRequestMatcher struct {
    91  	R *proto.SignRequest
    92  }
    93  
    94  func (m SignRequestMatcher) Matches(x interface{}) bool {
    95  	r, ok := x.(*proto.SignRequest)
    96  	if !ok {
    97  		return false
    98  	}
    99  	return protobuf.Equal(m.R, r)
   100  }
   101  
   102  func (m SignRequestMatcher) String() string {
   103  	return fmt.Sprintf("is %v", m.R)
   104  }
   105  
   106  type UnlockAndSignRequestMatcher struct {
   107  	R *proto.UnlockAndSignRequest
   108  }
   109  
   110  func (m UnlockAndSignRequestMatcher) Matches(x interface{}) bool {
   111  	r, ok := x.(*proto.UnlockAndSignRequest)
   112  	if !ok {
   113  		return false
   114  	}
   115  	return protobuf.Equal(m.R, r)
   116  }
   117  
   118  func (m UnlockAndSignRequestMatcher) String() string {
   119  	return fmt.Sprintf("is %v", m.R)
   120  }
   121  
   122  type TimedUnlockRequestMatcher struct {
   123  	R *proto.TimedUnlockRequest
   124  }
   125  
   126  func (m TimedUnlockRequestMatcher) Matches(x interface{}) bool {
   127  	r, ok := x.(*proto.TimedUnlockRequest)
   128  	if !ok {
   129  		return false
   130  	}
   131  	return protobuf.Equal(m.R, r)
   132  }
   133  
   134  func (m TimedUnlockRequestMatcher) String() string {
   135  	return fmt.Sprintf("is %v", m.R)
   136  }
   137  
   138  type LockRequestMatcher struct {
   139  	R *proto.LockRequest
   140  }
   141  
   142  func (m LockRequestMatcher) Matches(x interface{}) bool {
   143  	r, ok := x.(*proto.LockRequest)
   144  	if !ok {
   145  		return false
   146  	}
   147  	return protobuf.Equal(m.R, r)
   148  }
   149  
   150  func (m LockRequestMatcher) String() string {
   151  	return fmt.Sprintf("is %v", m.R)
   152  }
   153  
   154  type NewAccountRequestMatcher struct {
   155  	R *proto.NewAccountRequest
   156  }
   157  
   158  func (m NewAccountRequestMatcher) Matches(x interface{}) bool {
   159  	r, ok := x.(*proto.NewAccountRequest)
   160  	if !ok {
   161  		return false
   162  	}
   163  	return protobuf.Equal(m.R, r)
   164  }
   165  
   166  func (m NewAccountRequestMatcher) String() string {
   167  	return fmt.Sprintf("is %v", m.R)
   168  }
   169  
   170  type ImportRawKeyRequestMatcher struct {
   171  	R *proto.ImportRawKeyRequest
   172  }
   173  
   174  func (m ImportRawKeyRequestMatcher) Matches(x interface{}) bool {
   175  	r, ok := x.(*proto.ImportRawKeyRequest)
   176  	if !ok {
   177  		return false
   178  	}
   179  	return protobuf.Equal(m.R, r)
   180  }
   181  
   182  func (m ImportRawKeyRequestMatcher) String() string {
   183  	return fmt.Sprintf("is %v", m.R)
   184  }