github.com/braveheart12/insolar-09-08-19@v0.8.7/testutils/network/consensus_network_mock.go (about)

     1  package network
     2  
     3  /*
     4  DO NOT EDIT!
     5  This code was generated automatically using github.com/gojuno/minimock v1.9
     6  The original interface "ConsensusNetwork" can be found in github.com/insolar/insolar/network
     7  */
     8  import (
     9  	context "context"
    10  	"sync/atomic"
    11  	"time"
    12  
    13  	"github.com/gojuno/minimock"
    14  	packets "github.com/insolar/insolar/consensus/packets"
    15  	core "github.com/insolar/insolar/core"
    16  	network "github.com/insolar/insolar/network"
    17  
    18  	testify_assert "github.com/stretchr/testify/assert"
    19  )
    20  
    21  //ConsensusNetworkMock implements github.com/insolar/insolar/network.ConsensusNetwork
    22  type ConsensusNetworkMock struct {
    23  	t minimock.Tester
    24  
    25  	GetNodeIDFunc       func() (r core.RecordRef)
    26  	GetNodeIDCounter    uint64
    27  	GetNodeIDPreCounter uint64
    28  	GetNodeIDMock       mConsensusNetworkMockGetNodeID
    29  
    30  	PublicAddressFunc       func() (r string)
    31  	PublicAddressCounter    uint64
    32  	PublicAddressPreCounter uint64
    33  	PublicAddressMock       mConsensusNetworkMockPublicAddress
    34  
    35  	RegisterPacketHandlerFunc       func(p packets.PacketType, p1 network.ConsensusPacketHandler)
    36  	RegisterPacketHandlerCounter    uint64
    37  	RegisterPacketHandlerPreCounter uint64
    38  	RegisterPacketHandlerMock       mConsensusNetworkMockRegisterPacketHandler
    39  
    40  	SignAndSendPacketFunc       func(p packets.ConsensusPacket, p1 core.RecordRef, p2 core.CryptographyService) (r error)
    41  	SignAndSendPacketCounter    uint64
    42  	SignAndSendPacketPreCounter uint64
    43  	SignAndSendPacketMock       mConsensusNetworkMockSignAndSendPacket
    44  
    45  	StartFunc       func(p context.Context) (r error)
    46  	StartCounter    uint64
    47  	StartPreCounter uint64
    48  	StartMock       mConsensusNetworkMockStart
    49  
    50  	StopFunc       func(p context.Context) (r error)
    51  	StopCounter    uint64
    52  	StopPreCounter uint64
    53  	StopMock       mConsensusNetworkMockStop
    54  }
    55  
    56  //NewConsensusNetworkMock returns a mock for github.com/insolar/insolar/network.ConsensusNetwork
    57  func NewConsensusNetworkMock(t minimock.Tester) *ConsensusNetworkMock {
    58  	m := &ConsensusNetworkMock{t: t}
    59  
    60  	if controller, ok := t.(minimock.MockController); ok {
    61  		controller.RegisterMocker(m)
    62  	}
    63  
    64  	m.GetNodeIDMock = mConsensusNetworkMockGetNodeID{mock: m}
    65  	m.PublicAddressMock = mConsensusNetworkMockPublicAddress{mock: m}
    66  	m.RegisterPacketHandlerMock = mConsensusNetworkMockRegisterPacketHandler{mock: m}
    67  	m.SignAndSendPacketMock = mConsensusNetworkMockSignAndSendPacket{mock: m}
    68  	m.StartMock = mConsensusNetworkMockStart{mock: m}
    69  	m.StopMock = mConsensusNetworkMockStop{mock: m}
    70  
    71  	return m
    72  }
    73  
    74  type mConsensusNetworkMockGetNodeID struct {
    75  	mock              *ConsensusNetworkMock
    76  	mainExpectation   *ConsensusNetworkMockGetNodeIDExpectation
    77  	expectationSeries []*ConsensusNetworkMockGetNodeIDExpectation
    78  }
    79  
    80  type ConsensusNetworkMockGetNodeIDExpectation struct {
    81  	result *ConsensusNetworkMockGetNodeIDResult
    82  }
    83  
    84  type ConsensusNetworkMockGetNodeIDResult struct {
    85  	r core.RecordRef
    86  }
    87  
    88  //Expect specifies that invocation of ConsensusNetwork.GetNodeID is expected from 1 to Infinity times
    89  func (m *mConsensusNetworkMockGetNodeID) Expect() *mConsensusNetworkMockGetNodeID {
    90  	m.mock.GetNodeIDFunc = nil
    91  	m.expectationSeries = nil
    92  
    93  	if m.mainExpectation == nil {
    94  		m.mainExpectation = &ConsensusNetworkMockGetNodeIDExpectation{}
    95  	}
    96  
    97  	return m
    98  }
    99  
   100  //Return specifies results of invocation of ConsensusNetwork.GetNodeID
   101  func (m *mConsensusNetworkMockGetNodeID) Return(r core.RecordRef) *ConsensusNetworkMock {
   102  	m.mock.GetNodeIDFunc = nil
   103  	m.expectationSeries = nil
   104  
   105  	if m.mainExpectation == nil {
   106  		m.mainExpectation = &ConsensusNetworkMockGetNodeIDExpectation{}
   107  	}
   108  	m.mainExpectation.result = &ConsensusNetworkMockGetNodeIDResult{r}
   109  	return m.mock
   110  }
   111  
   112  //ExpectOnce specifies that invocation of ConsensusNetwork.GetNodeID is expected once
   113  func (m *mConsensusNetworkMockGetNodeID) ExpectOnce() *ConsensusNetworkMockGetNodeIDExpectation {
   114  	m.mock.GetNodeIDFunc = nil
   115  	m.mainExpectation = nil
   116  
   117  	expectation := &ConsensusNetworkMockGetNodeIDExpectation{}
   118  
   119  	m.expectationSeries = append(m.expectationSeries, expectation)
   120  	return expectation
   121  }
   122  
   123  func (e *ConsensusNetworkMockGetNodeIDExpectation) Return(r core.RecordRef) {
   124  	e.result = &ConsensusNetworkMockGetNodeIDResult{r}
   125  }
   126  
   127  //Set uses given function f as a mock of ConsensusNetwork.GetNodeID method
   128  func (m *mConsensusNetworkMockGetNodeID) Set(f func() (r core.RecordRef)) *ConsensusNetworkMock {
   129  	m.mainExpectation = nil
   130  	m.expectationSeries = nil
   131  
   132  	m.mock.GetNodeIDFunc = f
   133  	return m.mock
   134  }
   135  
   136  //GetNodeID implements github.com/insolar/insolar/network.ConsensusNetwork interface
   137  func (m *ConsensusNetworkMock) GetNodeID() (r core.RecordRef) {
   138  	counter := atomic.AddUint64(&m.GetNodeIDPreCounter, 1)
   139  	defer atomic.AddUint64(&m.GetNodeIDCounter, 1)
   140  
   141  	if len(m.GetNodeIDMock.expectationSeries) > 0 {
   142  		if counter > uint64(len(m.GetNodeIDMock.expectationSeries)) {
   143  			m.t.Fatalf("Unexpected call to ConsensusNetworkMock.GetNodeID.")
   144  			return
   145  		}
   146  
   147  		result := m.GetNodeIDMock.expectationSeries[counter-1].result
   148  		if result == nil {
   149  			m.t.Fatal("No results are set for the ConsensusNetworkMock.GetNodeID")
   150  			return
   151  		}
   152  
   153  		r = result.r
   154  
   155  		return
   156  	}
   157  
   158  	if m.GetNodeIDMock.mainExpectation != nil {
   159  
   160  		result := m.GetNodeIDMock.mainExpectation.result
   161  		if result == nil {
   162  			m.t.Fatal("No results are set for the ConsensusNetworkMock.GetNodeID")
   163  		}
   164  
   165  		r = result.r
   166  
   167  		return
   168  	}
   169  
   170  	if m.GetNodeIDFunc == nil {
   171  		m.t.Fatalf("Unexpected call to ConsensusNetworkMock.GetNodeID.")
   172  		return
   173  	}
   174  
   175  	return m.GetNodeIDFunc()
   176  }
   177  
   178  //GetNodeIDMinimockCounter returns a count of ConsensusNetworkMock.GetNodeIDFunc invocations
   179  func (m *ConsensusNetworkMock) GetNodeIDMinimockCounter() uint64 {
   180  	return atomic.LoadUint64(&m.GetNodeIDCounter)
   181  }
   182  
   183  //GetNodeIDMinimockPreCounter returns the value of ConsensusNetworkMock.GetNodeID invocations
   184  func (m *ConsensusNetworkMock) GetNodeIDMinimockPreCounter() uint64 {
   185  	return atomic.LoadUint64(&m.GetNodeIDPreCounter)
   186  }
   187  
   188  //GetNodeIDFinished returns true if mock invocations count is ok
   189  func (m *ConsensusNetworkMock) GetNodeIDFinished() bool {
   190  	// if expectation series were set then invocations count should be equal to expectations count
   191  	if len(m.GetNodeIDMock.expectationSeries) > 0 {
   192  		return atomic.LoadUint64(&m.GetNodeIDCounter) == uint64(len(m.GetNodeIDMock.expectationSeries))
   193  	}
   194  
   195  	// if main expectation was set then invocations count should be greater than zero
   196  	if m.GetNodeIDMock.mainExpectation != nil {
   197  		return atomic.LoadUint64(&m.GetNodeIDCounter) > 0
   198  	}
   199  
   200  	// if func was set then invocations count should be greater than zero
   201  	if m.GetNodeIDFunc != nil {
   202  		return atomic.LoadUint64(&m.GetNodeIDCounter) > 0
   203  	}
   204  
   205  	return true
   206  }
   207  
   208  type mConsensusNetworkMockPublicAddress struct {
   209  	mock              *ConsensusNetworkMock
   210  	mainExpectation   *ConsensusNetworkMockPublicAddressExpectation
   211  	expectationSeries []*ConsensusNetworkMockPublicAddressExpectation
   212  }
   213  
   214  type ConsensusNetworkMockPublicAddressExpectation struct {
   215  	result *ConsensusNetworkMockPublicAddressResult
   216  }
   217  
   218  type ConsensusNetworkMockPublicAddressResult struct {
   219  	r string
   220  }
   221  
   222  //Expect specifies that invocation of ConsensusNetwork.PublicAddress is expected from 1 to Infinity times
   223  func (m *mConsensusNetworkMockPublicAddress) Expect() *mConsensusNetworkMockPublicAddress {
   224  	m.mock.PublicAddressFunc = nil
   225  	m.expectationSeries = nil
   226  
   227  	if m.mainExpectation == nil {
   228  		m.mainExpectation = &ConsensusNetworkMockPublicAddressExpectation{}
   229  	}
   230  
   231  	return m
   232  }
   233  
   234  //Return specifies results of invocation of ConsensusNetwork.PublicAddress
   235  func (m *mConsensusNetworkMockPublicAddress) Return(r string) *ConsensusNetworkMock {
   236  	m.mock.PublicAddressFunc = nil
   237  	m.expectationSeries = nil
   238  
   239  	if m.mainExpectation == nil {
   240  		m.mainExpectation = &ConsensusNetworkMockPublicAddressExpectation{}
   241  	}
   242  	m.mainExpectation.result = &ConsensusNetworkMockPublicAddressResult{r}
   243  	return m.mock
   244  }
   245  
   246  //ExpectOnce specifies that invocation of ConsensusNetwork.PublicAddress is expected once
   247  func (m *mConsensusNetworkMockPublicAddress) ExpectOnce() *ConsensusNetworkMockPublicAddressExpectation {
   248  	m.mock.PublicAddressFunc = nil
   249  	m.mainExpectation = nil
   250  
   251  	expectation := &ConsensusNetworkMockPublicAddressExpectation{}
   252  
   253  	m.expectationSeries = append(m.expectationSeries, expectation)
   254  	return expectation
   255  }
   256  
   257  func (e *ConsensusNetworkMockPublicAddressExpectation) Return(r string) {
   258  	e.result = &ConsensusNetworkMockPublicAddressResult{r}
   259  }
   260  
   261  //Set uses given function f as a mock of ConsensusNetwork.PublicAddress method
   262  func (m *mConsensusNetworkMockPublicAddress) Set(f func() (r string)) *ConsensusNetworkMock {
   263  	m.mainExpectation = nil
   264  	m.expectationSeries = nil
   265  
   266  	m.mock.PublicAddressFunc = f
   267  	return m.mock
   268  }
   269  
   270  //PublicAddress implements github.com/insolar/insolar/network.ConsensusNetwork interface
   271  func (m *ConsensusNetworkMock) PublicAddress() (r string) {
   272  	counter := atomic.AddUint64(&m.PublicAddressPreCounter, 1)
   273  	defer atomic.AddUint64(&m.PublicAddressCounter, 1)
   274  
   275  	if len(m.PublicAddressMock.expectationSeries) > 0 {
   276  		if counter > uint64(len(m.PublicAddressMock.expectationSeries)) {
   277  			m.t.Fatalf("Unexpected call to ConsensusNetworkMock.PublicAddress.")
   278  			return
   279  		}
   280  
   281  		result := m.PublicAddressMock.expectationSeries[counter-1].result
   282  		if result == nil {
   283  			m.t.Fatal("No results are set for the ConsensusNetworkMock.PublicAddress")
   284  			return
   285  		}
   286  
   287  		r = result.r
   288  
   289  		return
   290  	}
   291  
   292  	if m.PublicAddressMock.mainExpectation != nil {
   293  
   294  		result := m.PublicAddressMock.mainExpectation.result
   295  		if result == nil {
   296  			m.t.Fatal("No results are set for the ConsensusNetworkMock.PublicAddress")
   297  		}
   298  
   299  		r = result.r
   300  
   301  		return
   302  	}
   303  
   304  	if m.PublicAddressFunc == nil {
   305  		m.t.Fatalf("Unexpected call to ConsensusNetworkMock.PublicAddress.")
   306  		return
   307  	}
   308  
   309  	return m.PublicAddressFunc()
   310  }
   311  
   312  //PublicAddressMinimockCounter returns a count of ConsensusNetworkMock.PublicAddressFunc invocations
   313  func (m *ConsensusNetworkMock) PublicAddressMinimockCounter() uint64 {
   314  	return atomic.LoadUint64(&m.PublicAddressCounter)
   315  }
   316  
   317  //PublicAddressMinimockPreCounter returns the value of ConsensusNetworkMock.PublicAddress invocations
   318  func (m *ConsensusNetworkMock) PublicAddressMinimockPreCounter() uint64 {
   319  	return atomic.LoadUint64(&m.PublicAddressPreCounter)
   320  }
   321  
   322  //PublicAddressFinished returns true if mock invocations count is ok
   323  func (m *ConsensusNetworkMock) PublicAddressFinished() bool {
   324  	// if expectation series were set then invocations count should be equal to expectations count
   325  	if len(m.PublicAddressMock.expectationSeries) > 0 {
   326  		return atomic.LoadUint64(&m.PublicAddressCounter) == uint64(len(m.PublicAddressMock.expectationSeries))
   327  	}
   328  
   329  	// if main expectation was set then invocations count should be greater than zero
   330  	if m.PublicAddressMock.mainExpectation != nil {
   331  		return atomic.LoadUint64(&m.PublicAddressCounter) > 0
   332  	}
   333  
   334  	// if func was set then invocations count should be greater than zero
   335  	if m.PublicAddressFunc != nil {
   336  		return atomic.LoadUint64(&m.PublicAddressCounter) > 0
   337  	}
   338  
   339  	return true
   340  }
   341  
   342  type mConsensusNetworkMockRegisterPacketHandler struct {
   343  	mock              *ConsensusNetworkMock
   344  	mainExpectation   *ConsensusNetworkMockRegisterPacketHandlerExpectation
   345  	expectationSeries []*ConsensusNetworkMockRegisterPacketHandlerExpectation
   346  }
   347  
   348  type ConsensusNetworkMockRegisterPacketHandlerExpectation struct {
   349  	input *ConsensusNetworkMockRegisterPacketHandlerInput
   350  }
   351  
   352  type ConsensusNetworkMockRegisterPacketHandlerInput struct {
   353  	p  packets.PacketType
   354  	p1 network.ConsensusPacketHandler
   355  }
   356  
   357  //Expect specifies that invocation of ConsensusNetwork.RegisterPacketHandler is expected from 1 to Infinity times
   358  func (m *mConsensusNetworkMockRegisterPacketHandler) Expect(p packets.PacketType, p1 network.ConsensusPacketHandler) *mConsensusNetworkMockRegisterPacketHandler {
   359  	m.mock.RegisterPacketHandlerFunc = nil
   360  	m.expectationSeries = nil
   361  
   362  	if m.mainExpectation == nil {
   363  		m.mainExpectation = &ConsensusNetworkMockRegisterPacketHandlerExpectation{}
   364  	}
   365  	m.mainExpectation.input = &ConsensusNetworkMockRegisterPacketHandlerInput{p, p1}
   366  	return m
   367  }
   368  
   369  //Return specifies results of invocation of ConsensusNetwork.RegisterPacketHandler
   370  func (m *mConsensusNetworkMockRegisterPacketHandler) Return() *ConsensusNetworkMock {
   371  	m.mock.RegisterPacketHandlerFunc = nil
   372  	m.expectationSeries = nil
   373  
   374  	if m.mainExpectation == nil {
   375  		m.mainExpectation = &ConsensusNetworkMockRegisterPacketHandlerExpectation{}
   376  	}
   377  
   378  	return m.mock
   379  }
   380  
   381  //ExpectOnce specifies that invocation of ConsensusNetwork.RegisterPacketHandler is expected once
   382  func (m *mConsensusNetworkMockRegisterPacketHandler) ExpectOnce(p packets.PacketType, p1 network.ConsensusPacketHandler) *ConsensusNetworkMockRegisterPacketHandlerExpectation {
   383  	m.mock.RegisterPacketHandlerFunc = nil
   384  	m.mainExpectation = nil
   385  
   386  	expectation := &ConsensusNetworkMockRegisterPacketHandlerExpectation{}
   387  	expectation.input = &ConsensusNetworkMockRegisterPacketHandlerInput{p, p1}
   388  	m.expectationSeries = append(m.expectationSeries, expectation)
   389  	return expectation
   390  }
   391  
   392  //Set uses given function f as a mock of ConsensusNetwork.RegisterPacketHandler method
   393  func (m *mConsensusNetworkMockRegisterPacketHandler) Set(f func(p packets.PacketType, p1 network.ConsensusPacketHandler)) *ConsensusNetworkMock {
   394  	m.mainExpectation = nil
   395  	m.expectationSeries = nil
   396  
   397  	m.mock.RegisterPacketHandlerFunc = f
   398  	return m.mock
   399  }
   400  
   401  //RegisterPacketHandler implements github.com/insolar/insolar/network.ConsensusNetwork interface
   402  func (m *ConsensusNetworkMock) RegisterPacketHandler(p packets.PacketType, p1 network.ConsensusPacketHandler) {
   403  	counter := atomic.AddUint64(&m.RegisterPacketHandlerPreCounter, 1)
   404  	defer atomic.AddUint64(&m.RegisterPacketHandlerCounter, 1)
   405  
   406  	if len(m.RegisterPacketHandlerMock.expectationSeries) > 0 {
   407  		if counter > uint64(len(m.RegisterPacketHandlerMock.expectationSeries)) {
   408  			m.t.Fatalf("Unexpected call to ConsensusNetworkMock.RegisterPacketHandler. %v %v", p, p1)
   409  			return
   410  		}
   411  
   412  		input := m.RegisterPacketHandlerMock.expectationSeries[counter-1].input
   413  		testify_assert.Equal(m.t, *input, ConsensusNetworkMockRegisterPacketHandlerInput{p, p1}, "ConsensusNetwork.RegisterPacketHandler got unexpected parameters")
   414  
   415  		return
   416  	}
   417  
   418  	if m.RegisterPacketHandlerMock.mainExpectation != nil {
   419  
   420  		input := m.RegisterPacketHandlerMock.mainExpectation.input
   421  		if input != nil {
   422  			testify_assert.Equal(m.t, *input, ConsensusNetworkMockRegisterPacketHandlerInput{p, p1}, "ConsensusNetwork.RegisterPacketHandler got unexpected parameters")
   423  		}
   424  
   425  		return
   426  	}
   427  
   428  	if m.RegisterPacketHandlerFunc == nil {
   429  		m.t.Fatalf("Unexpected call to ConsensusNetworkMock.RegisterPacketHandler. %v %v", p, p1)
   430  		return
   431  	}
   432  
   433  	m.RegisterPacketHandlerFunc(p, p1)
   434  }
   435  
   436  //RegisterPacketHandlerMinimockCounter returns a count of ConsensusNetworkMock.RegisterPacketHandlerFunc invocations
   437  func (m *ConsensusNetworkMock) RegisterPacketHandlerMinimockCounter() uint64 {
   438  	return atomic.LoadUint64(&m.RegisterPacketHandlerCounter)
   439  }
   440  
   441  //RegisterPacketHandlerMinimockPreCounter returns the value of ConsensusNetworkMock.RegisterPacketHandler invocations
   442  func (m *ConsensusNetworkMock) RegisterPacketHandlerMinimockPreCounter() uint64 {
   443  	return atomic.LoadUint64(&m.RegisterPacketHandlerPreCounter)
   444  }
   445  
   446  //RegisterPacketHandlerFinished returns true if mock invocations count is ok
   447  func (m *ConsensusNetworkMock) RegisterPacketHandlerFinished() bool {
   448  	// if expectation series were set then invocations count should be equal to expectations count
   449  	if len(m.RegisterPacketHandlerMock.expectationSeries) > 0 {
   450  		return atomic.LoadUint64(&m.RegisterPacketHandlerCounter) == uint64(len(m.RegisterPacketHandlerMock.expectationSeries))
   451  	}
   452  
   453  	// if main expectation was set then invocations count should be greater than zero
   454  	if m.RegisterPacketHandlerMock.mainExpectation != nil {
   455  		return atomic.LoadUint64(&m.RegisterPacketHandlerCounter) > 0
   456  	}
   457  
   458  	// if func was set then invocations count should be greater than zero
   459  	if m.RegisterPacketHandlerFunc != nil {
   460  		return atomic.LoadUint64(&m.RegisterPacketHandlerCounter) > 0
   461  	}
   462  
   463  	return true
   464  }
   465  
   466  type mConsensusNetworkMockSignAndSendPacket struct {
   467  	mock              *ConsensusNetworkMock
   468  	mainExpectation   *ConsensusNetworkMockSignAndSendPacketExpectation
   469  	expectationSeries []*ConsensusNetworkMockSignAndSendPacketExpectation
   470  }
   471  
   472  type ConsensusNetworkMockSignAndSendPacketExpectation struct {
   473  	input  *ConsensusNetworkMockSignAndSendPacketInput
   474  	result *ConsensusNetworkMockSignAndSendPacketResult
   475  }
   476  
   477  type ConsensusNetworkMockSignAndSendPacketInput struct {
   478  	p  packets.ConsensusPacket
   479  	p1 core.RecordRef
   480  	p2 core.CryptographyService
   481  }
   482  
   483  type ConsensusNetworkMockSignAndSendPacketResult struct {
   484  	r error
   485  }
   486  
   487  //Expect specifies that invocation of ConsensusNetwork.SignAndSendPacket is expected from 1 to Infinity times
   488  func (m *mConsensusNetworkMockSignAndSendPacket) Expect(p packets.ConsensusPacket, p1 core.RecordRef, p2 core.CryptographyService) *mConsensusNetworkMockSignAndSendPacket {
   489  	m.mock.SignAndSendPacketFunc = nil
   490  	m.expectationSeries = nil
   491  
   492  	if m.mainExpectation == nil {
   493  		m.mainExpectation = &ConsensusNetworkMockSignAndSendPacketExpectation{}
   494  	}
   495  	m.mainExpectation.input = &ConsensusNetworkMockSignAndSendPacketInput{p, p1, p2}
   496  	return m
   497  }
   498  
   499  //Return specifies results of invocation of ConsensusNetwork.SignAndSendPacket
   500  func (m *mConsensusNetworkMockSignAndSendPacket) Return(r error) *ConsensusNetworkMock {
   501  	m.mock.SignAndSendPacketFunc = nil
   502  	m.expectationSeries = nil
   503  
   504  	if m.mainExpectation == nil {
   505  		m.mainExpectation = &ConsensusNetworkMockSignAndSendPacketExpectation{}
   506  	}
   507  	m.mainExpectation.result = &ConsensusNetworkMockSignAndSendPacketResult{r}
   508  	return m.mock
   509  }
   510  
   511  //ExpectOnce specifies that invocation of ConsensusNetwork.SignAndSendPacket is expected once
   512  func (m *mConsensusNetworkMockSignAndSendPacket) ExpectOnce(p packets.ConsensusPacket, p1 core.RecordRef, p2 core.CryptographyService) *ConsensusNetworkMockSignAndSendPacketExpectation {
   513  	m.mock.SignAndSendPacketFunc = nil
   514  	m.mainExpectation = nil
   515  
   516  	expectation := &ConsensusNetworkMockSignAndSendPacketExpectation{}
   517  	expectation.input = &ConsensusNetworkMockSignAndSendPacketInput{p, p1, p2}
   518  	m.expectationSeries = append(m.expectationSeries, expectation)
   519  	return expectation
   520  }
   521  
   522  func (e *ConsensusNetworkMockSignAndSendPacketExpectation) Return(r error) {
   523  	e.result = &ConsensusNetworkMockSignAndSendPacketResult{r}
   524  }
   525  
   526  //Set uses given function f as a mock of ConsensusNetwork.SignAndSendPacket method
   527  func (m *mConsensusNetworkMockSignAndSendPacket) Set(f func(p packets.ConsensusPacket, p1 core.RecordRef, p2 core.CryptographyService) (r error)) *ConsensusNetworkMock {
   528  	m.mainExpectation = nil
   529  	m.expectationSeries = nil
   530  
   531  	m.mock.SignAndSendPacketFunc = f
   532  	return m.mock
   533  }
   534  
   535  //SignAndSendPacket implements github.com/insolar/insolar/network.ConsensusNetwork interface
   536  func (m *ConsensusNetworkMock) SignAndSendPacket(p packets.ConsensusPacket, p1 core.RecordRef, p2 core.CryptographyService) (r error) {
   537  	counter := atomic.AddUint64(&m.SignAndSendPacketPreCounter, 1)
   538  	defer atomic.AddUint64(&m.SignAndSendPacketCounter, 1)
   539  
   540  	if len(m.SignAndSendPacketMock.expectationSeries) > 0 {
   541  		if counter > uint64(len(m.SignAndSendPacketMock.expectationSeries)) {
   542  			m.t.Fatalf("Unexpected call to ConsensusNetworkMock.SignAndSendPacket. %v %v %v", p, p1, p2)
   543  			return
   544  		}
   545  
   546  		input := m.SignAndSendPacketMock.expectationSeries[counter-1].input
   547  		testify_assert.Equal(m.t, *input, ConsensusNetworkMockSignAndSendPacketInput{p, p1, p2}, "ConsensusNetwork.SignAndSendPacket got unexpected parameters")
   548  
   549  		result := m.SignAndSendPacketMock.expectationSeries[counter-1].result
   550  		if result == nil {
   551  			m.t.Fatal("No results are set for the ConsensusNetworkMock.SignAndSendPacket")
   552  			return
   553  		}
   554  
   555  		r = result.r
   556  
   557  		return
   558  	}
   559  
   560  	if m.SignAndSendPacketMock.mainExpectation != nil {
   561  
   562  		input := m.SignAndSendPacketMock.mainExpectation.input
   563  		if input != nil {
   564  			testify_assert.Equal(m.t, *input, ConsensusNetworkMockSignAndSendPacketInput{p, p1, p2}, "ConsensusNetwork.SignAndSendPacket got unexpected parameters")
   565  		}
   566  
   567  		result := m.SignAndSendPacketMock.mainExpectation.result
   568  		if result == nil {
   569  			m.t.Fatal("No results are set for the ConsensusNetworkMock.SignAndSendPacket")
   570  		}
   571  
   572  		r = result.r
   573  
   574  		return
   575  	}
   576  
   577  	if m.SignAndSendPacketFunc == nil {
   578  		m.t.Fatalf("Unexpected call to ConsensusNetworkMock.SignAndSendPacket. %v %v %v", p, p1, p2)
   579  		return
   580  	}
   581  
   582  	return m.SignAndSendPacketFunc(p, p1, p2)
   583  }
   584  
   585  //SignAndSendPacketMinimockCounter returns a count of ConsensusNetworkMock.SignAndSendPacketFunc invocations
   586  func (m *ConsensusNetworkMock) SignAndSendPacketMinimockCounter() uint64 {
   587  	return atomic.LoadUint64(&m.SignAndSendPacketCounter)
   588  }
   589  
   590  //SignAndSendPacketMinimockPreCounter returns the value of ConsensusNetworkMock.SignAndSendPacket invocations
   591  func (m *ConsensusNetworkMock) SignAndSendPacketMinimockPreCounter() uint64 {
   592  	return atomic.LoadUint64(&m.SignAndSendPacketPreCounter)
   593  }
   594  
   595  //SignAndSendPacketFinished returns true if mock invocations count is ok
   596  func (m *ConsensusNetworkMock) SignAndSendPacketFinished() bool {
   597  	// if expectation series were set then invocations count should be equal to expectations count
   598  	if len(m.SignAndSendPacketMock.expectationSeries) > 0 {
   599  		return atomic.LoadUint64(&m.SignAndSendPacketCounter) == uint64(len(m.SignAndSendPacketMock.expectationSeries))
   600  	}
   601  
   602  	// if main expectation was set then invocations count should be greater than zero
   603  	if m.SignAndSendPacketMock.mainExpectation != nil {
   604  		return atomic.LoadUint64(&m.SignAndSendPacketCounter) > 0
   605  	}
   606  
   607  	// if func was set then invocations count should be greater than zero
   608  	if m.SignAndSendPacketFunc != nil {
   609  		return atomic.LoadUint64(&m.SignAndSendPacketCounter) > 0
   610  	}
   611  
   612  	return true
   613  }
   614  
   615  type mConsensusNetworkMockStart struct {
   616  	mock              *ConsensusNetworkMock
   617  	mainExpectation   *ConsensusNetworkMockStartExpectation
   618  	expectationSeries []*ConsensusNetworkMockStartExpectation
   619  }
   620  
   621  type ConsensusNetworkMockStartExpectation struct {
   622  	input  *ConsensusNetworkMockStartInput
   623  	result *ConsensusNetworkMockStartResult
   624  }
   625  
   626  type ConsensusNetworkMockStartInput struct {
   627  	p context.Context
   628  }
   629  
   630  type ConsensusNetworkMockStartResult struct {
   631  	r error
   632  }
   633  
   634  //Expect specifies that invocation of ConsensusNetwork.Start is expected from 1 to Infinity times
   635  func (m *mConsensusNetworkMockStart) Expect(p context.Context) *mConsensusNetworkMockStart {
   636  	m.mock.StartFunc = nil
   637  	m.expectationSeries = nil
   638  
   639  	if m.mainExpectation == nil {
   640  		m.mainExpectation = &ConsensusNetworkMockStartExpectation{}
   641  	}
   642  	m.mainExpectation.input = &ConsensusNetworkMockStartInput{p}
   643  	return m
   644  }
   645  
   646  //Return specifies results of invocation of ConsensusNetwork.Start
   647  func (m *mConsensusNetworkMockStart) Return(r error) *ConsensusNetworkMock {
   648  	m.mock.StartFunc = nil
   649  	m.expectationSeries = nil
   650  
   651  	if m.mainExpectation == nil {
   652  		m.mainExpectation = &ConsensusNetworkMockStartExpectation{}
   653  	}
   654  	m.mainExpectation.result = &ConsensusNetworkMockStartResult{r}
   655  	return m.mock
   656  }
   657  
   658  //ExpectOnce specifies that invocation of ConsensusNetwork.Start is expected once
   659  func (m *mConsensusNetworkMockStart) ExpectOnce(p context.Context) *ConsensusNetworkMockStartExpectation {
   660  	m.mock.StartFunc = nil
   661  	m.mainExpectation = nil
   662  
   663  	expectation := &ConsensusNetworkMockStartExpectation{}
   664  	expectation.input = &ConsensusNetworkMockStartInput{p}
   665  	m.expectationSeries = append(m.expectationSeries, expectation)
   666  	return expectation
   667  }
   668  
   669  func (e *ConsensusNetworkMockStartExpectation) Return(r error) {
   670  	e.result = &ConsensusNetworkMockStartResult{r}
   671  }
   672  
   673  //Set uses given function f as a mock of ConsensusNetwork.Start method
   674  func (m *mConsensusNetworkMockStart) Set(f func(p context.Context) (r error)) *ConsensusNetworkMock {
   675  	m.mainExpectation = nil
   676  	m.expectationSeries = nil
   677  
   678  	m.mock.StartFunc = f
   679  	return m.mock
   680  }
   681  
   682  //Start implements github.com/insolar/insolar/network.ConsensusNetwork interface
   683  func (m *ConsensusNetworkMock) Start(p context.Context) (r error) {
   684  	counter := atomic.AddUint64(&m.StartPreCounter, 1)
   685  	defer atomic.AddUint64(&m.StartCounter, 1)
   686  
   687  	if len(m.StartMock.expectationSeries) > 0 {
   688  		if counter > uint64(len(m.StartMock.expectationSeries)) {
   689  			m.t.Fatalf("Unexpected call to ConsensusNetworkMock.Start. %v", p)
   690  			return
   691  		}
   692  
   693  		input := m.StartMock.expectationSeries[counter-1].input
   694  		testify_assert.Equal(m.t, *input, ConsensusNetworkMockStartInput{p}, "ConsensusNetwork.Start got unexpected parameters")
   695  
   696  		result := m.StartMock.expectationSeries[counter-1].result
   697  		if result == nil {
   698  			m.t.Fatal("No results are set for the ConsensusNetworkMock.Start")
   699  			return
   700  		}
   701  
   702  		r = result.r
   703  
   704  		return
   705  	}
   706  
   707  	if m.StartMock.mainExpectation != nil {
   708  
   709  		input := m.StartMock.mainExpectation.input
   710  		if input != nil {
   711  			testify_assert.Equal(m.t, *input, ConsensusNetworkMockStartInput{p}, "ConsensusNetwork.Start got unexpected parameters")
   712  		}
   713  
   714  		result := m.StartMock.mainExpectation.result
   715  		if result == nil {
   716  			m.t.Fatal("No results are set for the ConsensusNetworkMock.Start")
   717  		}
   718  
   719  		r = result.r
   720  
   721  		return
   722  	}
   723  
   724  	if m.StartFunc == nil {
   725  		m.t.Fatalf("Unexpected call to ConsensusNetworkMock.Start. %v", p)
   726  		return
   727  	}
   728  
   729  	return m.StartFunc(p)
   730  }
   731  
   732  //StartMinimockCounter returns a count of ConsensusNetworkMock.StartFunc invocations
   733  func (m *ConsensusNetworkMock) StartMinimockCounter() uint64 {
   734  	return atomic.LoadUint64(&m.StartCounter)
   735  }
   736  
   737  //StartMinimockPreCounter returns the value of ConsensusNetworkMock.Start invocations
   738  func (m *ConsensusNetworkMock) StartMinimockPreCounter() uint64 {
   739  	return atomic.LoadUint64(&m.StartPreCounter)
   740  }
   741  
   742  //StartFinished returns true if mock invocations count is ok
   743  func (m *ConsensusNetworkMock) StartFinished() bool {
   744  	// if expectation series were set then invocations count should be equal to expectations count
   745  	if len(m.StartMock.expectationSeries) > 0 {
   746  		return atomic.LoadUint64(&m.StartCounter) == uint64(len(m.StartMock.expectationSeries))
   747  	}
   748  
   749  	// if main expectation was set then invocations count should be greater than zero
   750  	if m.StartMock.mainExpectation != nil {
   751  		return atomic.LoadUint64(&m.StartCounter) > 0
   752  	}
   753  
   754  	// if func was set then invocations count should be greater than zero
   755  	if m.StartFunc != nil {
   756  		return atomic.LoadUint64(&m.StartCounter) > 0
   757  	}
   758  
   759  	return true
   760  }
   761  
   762  type mConsensusNetworkMockStop struct {
   763  	mock              *ConsensusNetworkMock
   764  	mainExpectation   *ConsensusNetworkMockStopExpectation
   765  	expectationSeries []*ConsensusNetworkMockStopExpectation
   766  }
   767  
   768  type ConsensusNetworkMockStopExpectation struct {
   769  	input  *ConsensusNetworkMockStopInput
   770  	result *ConsensusNetworkMockStopResult
   771  }
   772  
   773  type ConsensusNetworkMockStopInput struct {
   774  	p context.Context
   775  }
   776  
   777  type ConsensusNetworkMockStopResult struct {
   778  	r error
   779  }
   780  
   781  //Expect specifies that invocation of ConsensusNetwork.Stop is expected from 1 to Infinity times
   782  func (m *mConsensusNetworkMockStop) Expect(p context.Context) *mConsensusNetworkMockStop {
   783  	m.mock.StopFunc = nil
   784  	m.expectationSeries = nil
   785  
   786  	if m.mainExpectation == nil {
   787  		m.mainExpectation = &ConsensusNetworkMockStopExpectation{}
   788  	}
   789  	m.mainExpectation.input = &ConsensusNetworkMockStopInput{p}
   790  	return m
   791  }
   792  
   793  //Return specifies results of invocation of ConsensusNetwork.Stop
   794  func (m *mConsensusNetworkMockStop) Return(r error) *ConsensusNetworkMock {
   795  	m.mock.StopFunc = nil
   796  	m.expectationSeries = nil
   797  
   798  	if m.mainExpectation == nil {
   799  		m.mainExpectation = &ConsensusNetworkMockStopExpectation{}
   800  	}
   801  	m.mainExpectation.result = &ConsensusNetworkMockStopResult{r}
   802  	return m.mock
   803  }
   804  
   805  //ExpectOnce specifies that invocation of ConsensusNetwork.Stop is expected once
   806  func (m *mConsensusNetworkMockStop) ExpectOnce(p context.Context) *ConsensusNetworkMockStopExpectation {
   807  	m.mock.StopFunc = nil
   808  	m.mainExpectation = nil
   809  
   810  	expectation := &ConsensusNetworkMockStopExpectation{}
   811  	expectation.input = &ConsensusNetworkMockStopInput{p}
   812  	m.expectationSeries = append(m.expectationSeries, expectation)
   813  	return expectation
   814  }
   815  
   816  func (e *ConsensusNetworkMockStopExpectation) Return(r error) {
   817  	e.result = &ConsensusNetworkMockStopResult{r}
   818  }
   819  
   820  //Set uses given function f as a mock of ConsensusNetwork.Stop method
   821  func (m *mConsensusNetworkMockStop) Set(f func(p context.Context) (r error)) *ConsensusNetworkMock {
   822  	m.mainExpectation = nil
   823  	m.expectationSeries = nil
   824  
   825  	m.mock.StopFunc = f
   826  	return m.mock
   827  }
   828  
   829  //Stop implements github.com/insolar/insolar/network.ConsensusNetwork interface
   830  func (m *ConsensusNetworkMock) Stop(p context.Context) (r error) {
   831  	counter := atomic.AddUint64(&m.StopPreCounter, 1)
   832  	defer atomic.AddUint64(&m.StopCounter, 1)
   833  
   834  	if len(m.StopMock.expectationSeries) > 0 {
   835  		if counter > uint64(len(m.StopMock.expectationSeries)) {
   836  			m.t.Fatalf("Unexpected call to ConsensusNetworkMock.Stop. %v", p)
   837  			return
   838  		}
   839  
   840  		input := m.StopMock.expectationSeries[counter-1].input
   841  		testify_assert.Equal(m.t, *input, ConsensusNetworkMockStopInput{p}, "ConsensusNetwork.Stop got unexpected parameters")
   842  
   843  		result := m.StopMock.expectationSeries[counter-1].result
   844  		if result == nil {
   845  			m.t.Fatal("No results are set for the ConsensusNetworkMock.Stop")
   846  			return
   847  		}
   848  
   849  		r = result.r
   850  
   851  		return
   852  	}
   853  
   854  	if m.StopMock.mainExpectation != nil {
   855  
   856  		input := m.StopMock.mainExpectation.input
   857  		if input != nil {
   858  			testify_assert.Equal(m.t, *input, ConsensusNetworkMockStopInput{p}, "ConsensusNetwork.Stop got unexpected parameters")
   859  		}
   860  
   861  		result := m.StopMock.mainExpectation.result
   862  		if result == nil {
   863  			m.t.Fatal("No results are set for the ConsensusNetworkMock.Stop")
   864  		}
   865  
   866  		r = result.r
   867  
   868  		return
   869  	}
   870  
   871  	if m.StopFunc == nil {
   872  		m.t.Fatalf("Unexpected call to ConsensusNetworkMock.Stop. %v", p)
   873  		return
   874  	}
   875  
   876  	return m.StopFunc(p)
   877  }
   878  
   879  //StopMinimockCounter returns a count of ConsensusNetworkMock.StopFunc invocations
   880  func (m *ConsensusNetworkMock) StopMinimockCounter() uint64 {
   881  	return atomic.LoadUint64(&m.StopCounter)
   882  }
   883  
   884  //StopMinimockPreCounter returns the value of ConsensusNetworkMock.Stop invocations
   885  func (m *ConsensusNetworkMock) StopMinimockPreCounter() uint64 {
   886  	return atomic.LoadUint64(&m.StopPreCounter)
   887  }
   888  
   889  //StopFinished returns true if mock invocations count is ok
   890  func (m *ConsensusNetworkMock) StopFinished() bool {
   891  	// if expectation series were set then invocations count should be equal to expectations count
   892  	if len(m.StopMock.expectationSeries) > 0 {
   893  		return atomic.LoadUint64(&m.StopCounter) == uint64(len(m.StopMock.expectationSeries))
   894  	}
   895  
   896  	// if main expectation was set then invocations count should be greater than zero
   897  	if m.StopMock.mainExpectation != nil {
   898  		return atomic.LoadUint64(&m.StopCounter) > 0
   899  	}
   900  
   901  	// if func was set then invocations count should be greater than zero
   902  	if m.StopFunc != nil {
   903  		return atomic.LoadUint64(&m.StopCounter) > 0
   904  	}
   905  
   906  	return true
   907  }
   908  
   909  //ValidateCallCounters checks that all mocked methods of the interface have been called at least once
   910  //Deprecated: please use MinimockFinish method or use Finish method of minimock.Controller
   911  func (m *ConsensusNetworkMock) ValidateCallCounters() {
   912  
   913  	if !m.GetNodeIDFinished() {
   914  		m.t.Fatal("Expected call to ConsensusNetworkMock.GetNodeID")
   915  	}
   916  
   917  	if !m.PublicAddressFinished() {
   918  		m.t.Fatal("Expected call to ConsensusNetworkMock.PublicAddress")
   919  	}
   920  
   921  	if !m.RegisterPacketHandlerFinished() {
   922  		m.t.Fatal("Expected call to ConsensusNetworkMock.RegisterPacketHandler")
   923  	}
   924  
   925  	if !m.SignAndSendPacketFinished() {
   926  		m.t.Fatal("Expected call to ConsensusNetworkMock.SignAndSendPacket")
   927  	}
   928  
   929  	if !m.StartFinished() {
   930  		m.t.Fatal("Expected call to ConsensusNetworkMock.Start")
   931  	}
   932  
   933  	if !m.StopFinished() {
   934  		m.t.Fatal("Expected call to ConsensusNetworkMock.Stop")
   935  	}
   936  
   937  }
   938  
   939  //CheckMocksCalled checks that all mocked methods of the interface have been called at least once
   940  //Deprecated: please use MinimockFinish method or use Finish method of minimock.Controller
   941  func (m *ConsensusNetworkMock) CheckMocksCalled() {
   942  	m.Finish()
   943  }
   944  
   945  //Finish checks that all mocked methods of the interface have been called at least once
   946  //Deprecated: please use MinimockFinish or use Finish method of minimock.Controller
   947  func (m *ConsensusNetworkMock) Finish() {
   948  	m.MinimockFinish()
   949  }
   950  
   951  //MinimockFinish checks that all mocked methods of the interface have been called at least once
   952  func (m *ConsensusNetworkMock) MinimockFinish() {
   953  
   954  	if !m.GetNodeIDFinished() {
   955  		m.t.Fatal("Expected call to ConsensusNetworkMock.GetNodeID")
   956  	}
   957  
   958  	if !m.PublicAddressFinished() {
   959  		m.t.Fatal("Expected call to ConsensusNetworkMock.PublicAddress")
   960  	}
   961  
   962  	if !m.RegisterPacketHandlerFinished() {
   963  		m.t.Fatal("Expected call to ConsensusNetworkMock.RegisterPacketHandler")
   964  	}
   965  
   966  	if !m.SignAndSendPacketFinished() {
   967  		m.t.Fatal("Expected call to ConsensusNetworkMock.SignAndSendPacket")
   968  	}
   969  
   970  	if !m.StartFinished() {
   971  		m.t.Fatal("Expected call to ConsensusNetworkMock.Start")
   972  	}
   973  
   974  	if !m.StopFinished() {
   975  		m.t.Fatal("Expected call to ConsensusNetworkMock.Stop")
   976  	}
   977  
   978  }
   979  
   980  //Wait waits for all mocked methods to be called at least once
   981  //Deprecated: please use MinimockWait or use Wait method of minimock.Controller
   982  func (m *ConsensusNetworkMock) Wait(timeout time.Duration) {
   983  	m.MinimockWait(timeout)
   984  }
   985  
   986  //MinimockWait waits for all mocked methods to be called at least once
   987  //this method is called by minimock.Controller
   988  func (m *ConsensusNetworkMock) MinimockWait(timeout time.Duration) {
   989  	timeoutCh := time.After(timeout)
   990  	for {
   991  		ok := true
   992  		ok = ok && m.GetNodeIDFinished()
   993  		ok = ok && m.PublicAddressFinished()
   994  		ok = ok && m.RegisterPacketHandlerFinished()
   995  		ok = ok && m.SignAndSendPacketFinished()
   996  		ok = ok && m.StartFinished()
   997  		ok = ok && m.StopFinished()
   998  
   999  		if ok {
  1000  			return
  1001  		}
  1002  
  1003  		select {
  1004  		case <-timeoutCh:
  1005  
  1006  			if !m.GetNodeIDFinished() {
  1007  				m.t.Error("Expected call to ConsensusNetworkMock.GetNodeID")
  1008  			}
  1009  
  1010  			if !m.PublicAddressFinished() {
  1011  				m.t.Error("Expected call to ConsensusNetworkMock.PublicAddress")
  1012  			}
  1013  
  1014  			if !m.RegisterPacketHandlerFinished() {
  1015  				m.t.Error("Expected call to ConsensusNetworkMock.RegisterPacketHandler")
  1016  			}
  1017  
  1018  			if !m.SignAndSendPacketFinished() {
  1019  				m.t.Error("Expected call to ConsensusNetworkMock.SignAndSendPacket")
  1020  			}
  1021  
  1022  			if !m.StartFinished() {
  1023  				m.t.Error("Expected call to ConsensusNetworkMock.Start")
  1024  			}
  1025  
  1026  			if !m.StopFinished() {
  1027  				m.t.Error("Expected call to ConsensusNetworkMock.Stop")
  1028  			}
  1029  
  1030  			m.t.Fatalf("Some mocks were not called on time: %s", timeout)
  1031  			return
  1032  		default:
  1033  			time.Sleep(time.Millisecond)
  1034  		}
  1035  	}
  1036  }
  1037  
  1038  //AllMocksCalled returns true if all mocked methods were called before the execution of AllMocksCalled,
  1039  //it can be used with assert/require, i.e. assert.True(mock.AllMocksCalled())
  1040  func (m *ConsensusNetworkMock) AllMocksCalled() bool {
  1041  
  1042  	if !m.GetNodeIDFinished() {
  1043  		return false
  1044  	}
  1045  
  1046  	if !m.PublicAddressFinished() {
  1047  		return false
  1048  	}
  1049  
  1050  	if !m.RegisterPacketHandlerFinished() {
  1051  		return false
  1052  	}
  1053  
  1054  	if !m.SignAndSendPacketFinished() {
  1055  		return false
  1056  	}
  1057  
  1058  	if !m.StartFinished() {
  1059  		return false
  1060  	}
  1061  
  1062  	if !m.StopFinished() {
  1063  		return false
  1064  	}
  1065  
  1066  	return true
  1067  }