github.com/braveheart12/just@v0.8.7/testutils/merkle/calculator_mock.go (about)

     1  package merkle
     2  
     3  /*
     4  DO NOT EDIT!
     5  This code was generated automatically using github.com/gojuno/minimock v1.9
     6  The original interface "Calculator" can be found in github.com/insolar/insolar/network/merkle
     7  */
     8  import (
     9  	crypto "crypto"
    10  	"sync/atomic"
    11  	"time"
    12  
    13  	"github.com/gojuno/minimock"
    14  	merkle "github.com/insolar/insolar/network/merkle"
    15  
    16  	testify_assert "github.com/stretchr/testify/assert"
    17  )
    18  
    19  //CalculatorMock implements github.com/insolar/insolar/network/merkle.Calculator
    20  type CalculatorMock struct {
    21  	t minimock.Tester
    22  
    23  	GetCloudProofFunc       func(p *merkle.CloudEntry) (r merkle.OriginHash, r1 *merkle.CloudProof, r2 error)
    24  	GetCloudProofCounter    uint64
    25  	GetCloudProofPreCounter uint64
    26  	GetCloudProofMock       mCalculatorMockGetCloudProof
    27  
    28  	GetGlobuleProofFunc       func(p *merkle.GlobuleEntry) (r merkle.OriginHash, r1 *merkle.GlobuleProof, r2 error)
    29  	GetGlobuleProofCounter    uint64
    30  	GetGlobuleProofPreCounter uint64
    31  	GetGlobuleProofMock       mCalculatorMockGetGlobuleProof
    32  
    33  	GetPulseProofFunc       func(p *merkle.PulseEntry) (r merkle.OriginHash, r1 *merkle.PulseProof, r2 error)
    34  	GetPulseProofCounter    uint64
    35  	GetPulseProofPreCounter uint64
    36  	GetPulseProofMock       mCalculatorMockGetPulseProof
    37  
    38  	IsValidFunc       func(p merkle.Proof, p1 merkle.OriginHash, p2 crypto.PublicKey) (r bool)
    39  	IsValidCounter    uint64
    40  	IsValidPreCounter uint64
    41  	IsValidMock       mCalculatorMockIsValid
    42  }
    43  
    44  //NewCalculatorMock returns a mock for github.com/insolar/insolar/network/merkle.Calculator
    45  func NewCalculatorMock(t minimock.Tester) *CalculatorMock {
    46  	m := &CalculatorMock{t: t}
    47  
    48  	if controller, ok := t.(minimock.MockController); ok {
    49  		controller.RegisterMocker(m)
    50  	}
    51  
    52  	m.GetCloudProofMock = mCalculatorMockGetCloudProof{mock: m}
    53  	m.GetGlobuleProofMock = mCalculatorMockGetGlobuleProof{mock: m}
    54  	m.GetPulseProofMock = mCalculatorMockGetPulseProof{mock: m}
    55  	m.IsValidMock = mCalculatorMockIsValid{mock: m}
    56  
    57  	return m
    58  }
    59  
    60  type mCalculatorMockGetCloudProof struct {
    61  	mock              *CalculatorMock
    62  	mainExpectation   *CalculatorMockGetCloudProofExpectation
    63  	expectationSeries []*CalculatorMockGetCloudProofExpectation
    64  }
    65  
    66  type CalculatorMockGetCloudProofExpectation struct {
    67  	input  *CalculatorMockGetCloudProofInput
    68  	result *CalculatorMockGetCloudProofResult
    69  }
    70  
    71  type CalculatorMockGetCloudProofInput struct {
    72  	p *merkle.CloudEntry
    73  }
    74  
    75  type CalculatorMockGetCloudProofResult struct {
    76  	r  merkle.OriginHash
    77  	r1 *merkle.CloudProof
    78  	r2 error
    79  }
    80  
    81  //Expect specifies that invocation of Calculator.GetCloudProof is expected from 1 to Infinity times
    82  func (m *mCalculatorMockGetCloudProof) Expect(p *merkle.CloudEntry) *mCalculatorMockGetCloudProof {
    83  	m.mock.GetCloudProofFunc = nil
    84  	m.expectationSeries = nil
    85  
    86  	if m.mainExpectation == nil {
    87  		m.mainExpectation = &CalculatorMockGetCloudProofExpectation{}
    88  	}
    89  	m.mainExpectation.input = &CalculatorMockGetCloudProofInput{p}
    90  	return m
    91  }
    92  
    93  //Return specifies results of invocation of Calculator.GetCloudProof
    94  func (m *mCalculatorMockGetCloudProof) Return(r merkle.OriginHash, r1 *merkle.CloudProof, r2 error) *CalculatorMock {
    95  	m.mock.GetCloudProofFunc = nil
    96  	m.expectationSeries = nil
    97  
    98  	if m.mainExpectation == nil {
    99  		m.mainExpectation = &CalculatorMockGetCloudProofExpectation{}
   100  	}
   101  	m.mainExpectation.result = &CalculatorMockGetCloudProofResult{r, r1, r2}
   102  	return m.mock
   103  }
   104  
   105  //ExpectOnce specifies that invocation of Calculator.GetCloudProof is expected once
   106  func (m *mCalculatorMockGetCloudProof) ExpectOnce(p *merkle.CloudEntry) *CalculatorMockGetCloudProofExpectation {
   107  	m.mock.GetCloudProofFunc = nil
   108  	m.mainExpectation = nil
   109  
   110  	expectation := &CalculatorMockGetCloudProofExpectation{}
   111  	expectation.input = &CalculatorMockGetCloudProofInput{p}
   112  	m.expectationSeries = append(m.expectationSeries, expectation)
   113  	return expectation
   114  }
   115  
   116  func (e *CalculatorMockGetCloudProofExpectation) Return(r merkle.OriginHash, r1 *merkle.CloudProof, r2 error) {
   117  	e.result = &CalculatorMockGetCloudProofResult{r, r1, r2}
   118  }
   119  
   120  //Set uses given function f as a mock of Calculator.GetCloudProof method
   121  func (m *mCalculatorMockGetCloudProof) Set(f func(p *merkle.CloudEntry) (r merkle.OriginHash, r1 *merkle.CloudProof, r2 error)) *CalculatorMock {
   122  	m.mainExpectation = nil
   123  	m.expectationSeries = nil
   124  
   125  	m.mock.GetCloudProofFunc = f
   126  	return m.mock
   127  }
   128  
   129  //GetCloudProof implements github.com/insolar/insolar/network/merkle.Calculator interface
   130  func (m *CalculatorMock) GetCloudProof(p *merkle.CloudEntry) (r merkle.OriginHash, r1 *merkle.CloudProof, r2 error) {
   131  	counter := atomic.AddUint64(&m.GetCloudProofPreCounter, 1)
   132  	defer atomic.AddUint64(&m.GetCloudProofCounter, 1)
   133  
   134  	if len(m.GetCloudProofMock.expectationSeries) > 0 {
   135  		if counter > uint64(len(m.GetCloudProofMock.expectationSeries)) {
   136  			m.t.Fatalf("Unexpected call to CalculatorMock.GetCloudProof. %v", p)
   137  			return
   138  		}
   139  
   140  		input := m.GetCloudProofMock.expectationSeries[counter-1].input
   141  		testify_assert.Equal(m.t, *input, CalculatorMockGetCloudProofInput{p}, "Calculator.GetCloudProof got unexpected parameters")
   142  
   143  		result := m.GetCloudProofMock.expectationSeries[counter-1].result
   144  		if result == nil {
   145  			m.t.Fatal("No results are set for the CalculatorMock.GetCloudProof")
   146  			return
   147  		}
   148  
   149  		r = result.r
   150  		r1 = result.r1
   151  		r2 = result.r2
   152  
   153  		return
   154  	}
   155  
   156  	if m.GetCloudProofMock.mainExpectation != nil {
   157  
   158  		input := m.GetCloudProofMock.mainExpectation.input
   159  		if input != nil {
   160  			testify_assert.Equal(m.t, *input, CalculatorMockGetCloudProofInput{p}, "Calculator.GetCloudProof got unexpected parameters")
   161  		}
   162  
   163  		result := m.GetCloudProofMock.mainExpectation.result
   164  		if result == nil {
   165  			m.t.Fatal("No results are set for the CalculatorMock.GetCloudProof")
   166  		}
   167  
   168  		r = result.r
   169  		r1 = result.r1
   170  		r2 = result.r2
   171  
   172  		return
   173  	}
   174  
   175  	if m.GetCloudProofFunc == nil {
   176  		m.t.Fatalf("Unexpected call to CalculatorMock.GetCloudProof. %v", p)
   177  		return
   178  	}
   179  
   180  	return m.GetCloudProofFunc(p)
   181  }
   182  
   183  //GetCloudProofMinimockCounter returns a count of CalculatorMock.GetCloudProofFunc invocations
   184  func (m *CalculatorMock) GetCloudProofMinimockCounter() uint64 {
   185  	return atomic.LoadUint64(&m.GetCloudProofCounter)
   186  }
   187  
   188  //GetCloudProofMinimockPreCounter returns the value of CalculatorMock.GetCloudProof invocations
   189  func (m *CalculatorMock) GetCloudProofMinimockPreCounter() uint64 {
   190  	return atomic.LoadUint64(&m.GetCloudProofPreCounter)
   191  }
   192  
   193  //GetCloudProofFinished returns true if mock invocations count is ok
   194  func (m *CalculatorMock) GetCloudProofFinished() bool {
   195  	// if expectation series were set then invocations count should be equal to expectations count
   196  	if len(m.GetCloudProofMock.expectationSeries) > 0 {
   197  		return atomic.LoadUint64(&m.GetCloudProofCounter) == uint64(len(m.GetCloudProofMock.expectationSeries))
   198  	}
   199  
   200  	// if main expectation was set then invocations count should be greater than zero
   201  	if m.GetCloudProofMock.mainExpectation != nil {
   202  		return atomic.LoadUint64(&m.GetCloudProofCounter) > 0
   203  	}
   204  
   205  	// if func was set then invocations count should be greater than zero
   206  	if m.GetCloudProofFunc != nil {
   207  		return atomic.LoadUint64(&m.GetCloudProofCounter) > 0
   208  	}
   209  
   210  	return true
   211  }
   212  
   213  type mCalculatorMockGetGlobuleProof struct {
   214  	mock              *CalculatorMock
   215  	mainExpectation   *CalculatorMockGetGlobuleProofExpectation
   216  	expectationSeries []*CalculatorMockGetGlobuleProofExpectation
   217  }
   218  
   219  type CalculatorMockGetGlobuleProofExpectation struct {
   220  	input  *CalculatorMockGetGlobuleProofInput
   221  	result *CalculatorMockGetGlobuleProofResult
   222  }
   223  
   224  type CalculatorMockGetGlobuleProofInput struct {
   225  	p *merkle.GlobuleEntry
   226  }
   227  
   228  type CalculatorMockGetGlobuleProofResult struct {
   229  	r  merkle.OriginHash
   230  	r1 *merkle.GlobuleProof
   231  	r2 error
   232  }
   233  
   234  //Expect specifies that invocation of Calculator.GetGlobuleProof is expected from 1 to Infinity times
   235  func (m *mCalculatorMockGetGlobuleProof) Expect(p *merkle.GlobuleEntry) *mCalculatorMockGetGlobuleProof {
   236  	m.mock.GetGlobuleProofFunc = nil
   237  	m.expectationSeries = nil
   238  
   239  	if m.mainExpectation == nil {
   240  		m.mainExpectation = &CalculatorMockGetGlobuleProofExpectation{}
   241  	}
   242  	m.mainExpectation.input = &CalculatorMockGetGlobuleProofInput{p}
   243  	return m
   244  }
   245  
   246  //Return specifies results of invocation of Calculator.GetGlobuleProof
   247  func (m *mCalculatorMockGetGlobuleProof) Return(r merkle.OriginHash, r1 *merkle.GlobuleProof, r2 error) *CalculatorMock {
   248  	m.mock.GetGlobuleProofFunc = nil
   249  	m.expectationSeries = nil
   250  
   251  	if m.mainExpectation == nil {
   252  		m.mainExpectation = &CalculatorMockGetGlobuleProofExpectation{}
   253  	}
   254  	m.mainExpectation.result = &CalculatorMockGetGlobuleProofResult{r, r1, r2}
   255  	return m.mock
   256  }
   257  
   258  //ExpectOnce specifies that invocation of Calculator.GetGlobuleProof is expected once
   259  func (m *mCalculatorMockGetGlobuleProof) ExpectOnce(p *merkle.GlobuleEntry) *CalculatorMockGetGlobuleProofExpectation {
   260  	m.mock.GetGlobuleProofFunc = nil
   261  	m.mainExpectation = nil
   262  
   263  	expectation := &CalculatorMockGetGlobuleProofExpectation{}
   264  	expectation.input = &CalculatorMockGetGlobuleProofInput{p}
   265  	m.expectationSeries = append(m.expectationSeries, expectation)
   266  	return expectation
   267  }
   268  
   269  func (e *CalculatorMockGetGlobuleProofExpectation) Return(r merkle.OriginHash, r1 *merkle.GlobuleProof, r2 error) {
   270  	e.result = &CalculatorMockGetGlobuleProofResult{r, r1, r2}
   271  }
   272  
   273  //Set uses given function f as a mock of Calculator.GetGlobuleProof method
   274  func (m *mCalculatorMockGetGlobuleProof) Set(f func(p *merkle.GlobuleEntry) (r merkle.OriginHash, r1 *merkle.GlobuleProof, r2 error)) *CalculatorMock {
   275  	m.mainExpectation = nil
   276  	m.expectationSeries = nil
   277  
   278  	m.mock.GetGlobuleProofFunc = f
   279  	return m.mock
   280  }
   281  
   282  //GetGlobuleProof implements github.com/insolar/insolar/network/merkle.Calculator interface
   283  func (m *CalculatorMock) GetGlobuleProof(p *merkle.GlobuleEntry) (r merkle.OriginHash, r1 *merkle.GlobuleProof, r2 error) {
   284  	counter := atomic.AddUint64(&m.GetGlobuleProofPreCounter, 1)
   285  	defer atomic.AddUint64(&m.GetGlobuleProofCounter, 1)
   286  
   287  	if len(m.GetGlobuleProofMock.expectationSeries) > 0 {
   288  		if counter > uint64(len(m.GetGlobuleProofMock.expectationSeries)) {
   289  			m.t.Fatalf("Unexpected call to CalculatorMock.GetGlobuleProof. %v", p)
   290  			return
   291  		}
   292  
   293  		input := m.GetGlobuleProofMock.expectationSeries[counter-1].input
   294  		testify_assert.Equal(m.t, *input, CalculatorMockGetGlobuleProofInput{p}, "Calculator.GetGlobuleProof got unexpected parameters")
   295  
   296  		result := m.GetGlobuleProofMock.expectationSeries[counter-1].result
   297  		if result == nil {
   298  			m.t.Fatal("No results are set for the CalculatorMock.GetGlobuleProof")
   299  			return
   300  		}
   301  
   302  		r = result.r
   303  		r1 = result.r1
   304  		r2 = result.r2
   305  
   306  		return
   307  	}
   308  
   309  	if m.GetGlobuleProofMock.mainExpectation != nil {
   310  
   311  		input := m.GetGlobuleProofMock.mainExpectation.input
   312  		if input != nil {
   313  			testify_assert.Equal(m.t, *input, CalculatorMockGetGlobuleProofInput{p}, "Calculator.GetGlobuleProof got unexpected parameters")
   314  		}
   315  
   316  		result := m.GetGlobuleProofMock.mainExpectation.result
   317  		if result == nil {
   318  			m.t.Fatal("No results are set for the CalculatorMock.GetGlobuleProof")
   319  		}
   320  
   321  		r = result.r
   322  		r1 = result.r1
   323  		r2 = result.r2
   324  
   325  		return
   326  	}
   327  
   328  	if m.GetGlobuleProofFunc == nil {
   329  		m.t.Fatalf("Unexpected call to CalculatorMock.GetGlobuleProof. %v", p)
   330  		return
   331  	}
   332  
   333  	return m.GetGlobuleProofFunc(p)
   334  }
   335  
   336  //GetGlobuleProofMinimockCounter returns a count of CalculatorMock.GetGlobuleProofFunc invocations
   337  func (m *CalculatorMock) GetGlobuleProofMinimockCounter() uint64 {
   338  	return atomic.LoadUint64(&m.GetGlobuleProofCounter)
   339  }
   340  
   341  //GetGlobuleProofMinimockPreCounter returns the value of CalculatorMock.GetGlobuleProof invocations
   342  func (m *CalculatorMock) GetGlobuleProofMinimockPreCounter() uint64 {
   343  	return atomic.LoadUint64(&m.GetGlobuleProofPreCounter)
   344  }
   345  
   346  //GetGlobuleProofFinished returns true if mock invocations count is ok
   347  func (m *CalculatorMock) GetGlobuleProofFinished() bool {
   348  	// if expectation series were set then invocations count should be equal to expectations count
   349  	if len(m.GetGlobuleProofMock.expectationSeries) > 0 {
   350  		return atomic.LoadUint64(&m.GetGlobuleProofCounter) == uint64(len(m.GetGlobuleProofMock.expectationSeries))
   351  	}
   352  
   353  	// if main expectation was set then invocations count should be greater than zero
   354  	if m.GetGlobuleProofMock.mainExpectation != nil {
   355  		return atomic.LoadUint64(&m.GetGlobuleProofCounter) > 0
   356  	}
   357  
   358  	// if func was set then invocations count should be greater than zero
   359  	if m.GetGlobuleProofFunc != nil {
   360  		return atomic.LoadUint64(&m.GetGlobuleProofCounter) > 0
   361  	}
   362  
   363  	return true
   364  }
   365  
   366  type mCalculatorMockGetPulseProof struct {
   367  	mock              *CalculatorMock
   368  	mainExpectation   *CalculatorMockGetPulseProofExpectation
   369  	expectationSeries []*CalculatorMockGetPulseProofExpectation
   370  }
   371  
   372  type CalculatorMockGetPulseProofExpectation struct {
   373  	input  *CalculatorMockGetPulseProofInput
   374  	result *CalculatorMockGetPulseProofResult
   375  }
   376  
   377  type CalculatorMockGetPulseProofInput struct {
   378  	p *merkle.PulseEntry
   379  }
   380  
   381  type CalculatorMockGetPulseProofResult struct {
   382  	r  merkle.OriginHash
   383  	r1 *merkle.PulseProof
   384  	r2 error
   385  }
   386  
   387  //Expect specifies that invocation of Calculator.GetPulseProof is expected from 1 to Infinity times
   388  func (m *mCalculatorMockGetPulseProof) Expect(p *merkle.PulseEntry) *mCalculatorMockGetPulseProof {
   389  	m.mock.GetPulseProofFunc = nil
   390  	m.expectationSeries = nil
   391  
   392  	if m.mainExpectation == nil {
   393  		m.mainExpectation = &CalculatorMockGetPulseProofExpectation{}
   394  	}
   395  	m.mainExpectation.input = &CalculatorMockGetPulseProofInput{p}
   396  	return m
   397  }
   398  
   399  //Return specifies results of invocation of Calculator.GetPulseProof
   400  func (m *mCalculatorMockGetPulseProof) Return(r merkle.OriginHash, r1 *merkle.PulseProof, r2 error) *CalculatorMock {
   401  	m.mock.GetPulseProofFunc = nil
   402  	m.expectationSeries = nil
   403  
   404  	if m.mainExpectation == nil {
   405  		m.mainExpectation = &CalculatorMockGetPulseProofExpectation{}
   406  	}
   407  	m.mainExpectation.result = &CalculatorMockGetPulseProofResult{r, r1, r2}
   408  	return m.mock
   409  }
   410  
   411  //ExpectOnce specifies that invocation of Calculator.GetPulseProof is expected once
   412  func (m *mCalculatorMockGetPulseProof) ExpectOnce(p *merkle.PulseEntry) *CalculatorMockGetPulseProofExpectation {
   413  	m.mock.GetPulseProofFunc = nil
   414  	m.mainExpectation = nil
   415  
   416  	expectation := &CalculatorMockGetPulseProofExpectation{}
   417  	expectation.input = &CalculatorMockGetPulseProofInput{p}
   418  	m.expectationSeries = append(m.expectationSeries, expectation)
   419  	return expectation
   420  }
   421  
   422  func (e *CalculatorMockGetPulseProofExpectation) Return(r merkle.OriginHash, r1 *merkle.PulseProof, r2 error) {
   423  	e.result = &CalculatorMockGetPulseProofResult{r, r1, r2}
   424  }
   425  
   426  //Set uses given function f as a mock of Calculator.GetPulseProof method
   427  func (m *mCalculatorMockGetPulseProof) Set(f func(p *merkle.PulseEntry) (r merkle.OriginHash, r1 *merkle.PulseProof, r2 error)) *CalculatorMock {
   428  	m.mainExpectation = nil
   429  	m.expectationSeries = nil
   430  
   431  	m.mock.GetPulseProofFunc = f
   432  	return m.mock
   433  }
   434  
   435  //GetPulseProof implements github.com/insolar/insolar/network/merkle.Calculator interface
   436  func (m *CalculatorMock) GetPulseProof(p *merkle.PulseEntry) (r merkle.OriginHash, r1 *merkle.PulseProof, r2 error) {
   437  	counter := atomic.AddUint64(&m.GetPulseProofPreCounter, 1)
   438  	defer atomic.AddUint64(&m.GetPulseProofCounter, 1)
   439  
   440  	if len(m.GetPulseProofMock.expectationSeries) > 0 {
   441  		if counter > uint64(len(m.GetPulseProofMock.expectationSeries)) {
   442  			m.t.Fatalf("Unexpected call to CalculatorMock.GetPulseProof. %v", p)
   443  			return
   444  		}
   445  
   446  		input := m.GetPulseProofMock.expectationSeries[counter-1].input
   447  		testify_assert.Equal(m.t, *input, CalculatorMockGetPulseProofInput{p}, "Calculator.GetPulseProof got unexpected parameters")
   448  
   449  		result := m.GetPulseProofMock.expectationSeries[counter-1].result
   450  		if result == nil {
   451  			m.t.Fatal("No results are set for the CalculatorMock.GetPulseProof")
   452  			return
   453  		}
   454  
   455  		r = result.r
   456  		r1 = result.r1
   457  		r2 = result.r2
   458  
   459  		return
   460  	}
   461  
   462  	if m.GetPulseProofMock.mainExpectation != nil {
   463  
   464  		input := m.GetPulseProofMock.mainExpectation.input
   465  		if input != nil {
   466  			testify_assert.Equal(m.t, *input, CalculatorMockGetPulseProofInput{p}, "Calculator.GetPulseProof got unexpected parameters")
   467  		}
   468  
   469  		result := m.GetPulseProofMock.mainExpectation.result
   470  		if result == nil {
   471  			m.t.Fatal("No results are set for the CalculatorMock.GetPulseProof")
   472  		}
   473  
   474  		r = result.r
   475  		r1 = result.r1
   476  		r2 = result.r2
   477  
   478  		return
   479  	}
   480  
   481  	if m.GetPulseProofFunc == nil {
   482  		m.t.Fatalf("Unexpected call to CalculatorMock.GetPulseProof. %v", p)
   483  		return
   484  	}
   485  
   486  	return m.GetPulseProofFunc(p)
   487  }
   488  
   489  //GetPulseProofMinimockCounter returns a count of CalculatorMock.GetPulseProofFunc invocations
   490  func (m *CalculatorMock) GetPulseProofMinimockCounter() uint64 {
   491  	return atomic.LoadUint64(&m.GetPulseProofCounter)
   492  }
   493  
   494  //GetPulseProofMinimockPreCounter returns the value of CalculatorMock.GetPulseProof invocations
   495  func (m *CalculatorMock) GetPulseProofMinimockPreCounter() uint64 {
   496  	return atomic.LoadUint64(&m.GetPulseProofPreCounter)
   497  }
   498  
   499  //GetPulseProofFinished returns true if mock invocations count is ok
   500  func (m *CalculatorMock) GetPulseProofFinished() bool {
   501  	// if expectation series were set then invocations count should be equal to expectations count
   502  	if len(m.GetPulseProofMock.expectationSeries) > 0 {
   503  		return atomic.LoadUint64(&m.GetPulseProofCounter) == uint64(len(m.GetPulseProofMock.expectationSeries))
   504  	}
   505  
   506  	// if main expectation was set then invocations count should be greater than zero
   507  	if m.GetPulseProofMock.mainExpectation != nil {
   508  		return atomic.LoadUint64(&m.GetPulseProofCounter) > 0
   509  	}
   510  
   511  	// if func was set then invocations count should be greater than zero
   512  	if m.GetPulseProofFunc != nil {
   513  		return atomic.LoadUint64(&m.GetPulseProofCounter) > 0
   514  	}
   515  
   516  	return true
   517  }
   518  
   519  type mCalculatorMockIsValid struct {
   520  	mock              *CalculatorMock
   521  	mainExpectation   *CalculatorMockIsValidExpectation
   522  	expectationSeries []*CalculatorMockIsValidExpectation
   523  }
   524  
   525  type CalculatorMockIsValidExpectation struct {
   526  	input  *CalculatorMockIsValidInput
   527  	result *CalculatorMockIsValidResult
   528  }
   529  
   530  type CalculatorMockIsValidInput struct {
   531  	p  merkle.Proof
   532  	p1 merkle.OriginHash
   533  	p2 crypto.PublicKey
   534  }
   535  
   536  type CalculatorMockIsValidResult struct {
   537  	r bool
   538  }
   539  
   540  //Expect specifies that invocation of Calculator.IsValid is expected from 1 to Infinity times
   541  func (m *mCalculatorMockIsValid) Expect(p merkle.Proof, p1 merkle.OriginHash, p2 crypto.PublicKey) *mCalculatorMockIsValid {
   542  	m.mock.IsValidFunc = nil
   543  	m.expectationSeries = nil
   544  
   545  	if m.mainExpectation == nil {
   546  		m.mainExpectation = &CalculatorMockIsValidExpectation{}
   547  	}
   548  	m.mainExpectation.input = &CalculatorMockIsValidInput{p, p1, p2}
   549  	return m
   550  }
   551  
   552  //Return specifies results of invocation of Calculator.IsValid
   553  func (m *mCalculatorMockIsValid) Return(r bool) *CalculatorMock {
   554  	m.mock.IsValidFunc = nil
   555  	m.expectationSeries = nil
   556  
   557  	if m.mainExpectation == nil {
   558  		m.mainExpectation = &CalculatorMockIsValidExpectation{}
   559  	}
   560  	m.mainExpectation.result = &CalculatorMockIsValidResult{r}
   561  	return m.mock
   562  }
   563  
   564  //ExpectOnce specifies that invocation of Calculator.IsValid is expected once
   565  func (m *mCalculatorMockIsValid) ExpectOnce(p merkle.Proof, p1 merkle.OriginHash, p2 crypto.PublicKey) *CalculatorMockIsValidExpectation {
   566  	m.mock.IsValidFunc = nil
   567  	m.mainExpectation = nil
   568  
   569  	expectation := &CalculatorMockIsValidExpectation{}
   570  	expectation.input = &CalculatorMockIsValidInput{p, p1, p2}
   571  	m.expectationSeries = append(m.expectationSeries, expectation)
   572  	return expectation
   573  }
   574  
   575  func (e *CalculatorMockIsValidExpectation) Return(r bool) {
   576  	e.result = &CalculatorMockIsValidResult{r}
   577  }
   578  
   579  //Set uses given function f as a mock of Calculator.IsValid method
   580  func (m *mCalculatorMockIsValid) Set(f func(p merkle.Proof, p1 merkle.OriginHash, p2 crypto.PublicKey) (r bool)) *CalculatorMock {
   581  	m.mainExpectation = nil
   582  	m.expectationSeries = nil
   583  
   584  	m.mock.IsValidFunc = f
   585  	return m.mock
   586  }
   587  
   588  //IsValid implements github.com/insolar/insolar/network/merkle.Calculator interface
   589  func (m *CalculatorMock) IsValid(p merkle.Proof, p1 merkle.OriginHash, p2 crypto.PublicKey) (r bool) {
   590  	counter := atomic.AddUint64(&m.IsValidPreCounter, 1)
   591  	defer atomic.AddUint64(&m.IsValidCounter, 1)
   592  
   593  	if len(m.IsValidMock.expectationSeries) > 0 {
   594  		if counter > uint64(len(m.IsValidMock.expectationSeries)) {
   595  			m.t.Fatalf("Unexpected call to CalculatorMock.IsValid. %v %v %v", p, p1, p2)
   596  			return
   597  		}
   598  
   599  		input := m.IsValidMock.expectationSeries[counter-1].input
   600  		testify_assert.Equal(m.t, *input, CalculatorMockIsValidInput{p, p1, p2}, "Calculator.IsValid got unexpected parameters")
   601  
   602  		result := m.IsValidMock.expectationSeries[counter-1].result
   603  		if result == nil {
   604  			m.t.Fatal("No results are set for the CalculatorMock.IsValid")
   605  			return
   606  		}
   607  
   608  		r = result.r
   609  
   610  		return
   611  	}
   612  
   613  	if m.IsValidMock.mainExpectation != nil {
   614  
   615  		input := m.IsValidMock.mainExpectation.input
   616  		if input != nil {
   617  			testify_assert.Equal(m.t, *input, CalculatorMockIsValidInput{p, p1, p2}, "Calculator.IsValid got unexpected parameters")
   618  		}
   619  
   620  		result := m.IsValidMock.mainExpectation.result
   621  		if result == nil {
   622  			m.t.Fatal("No results are set for the CalculatorMock.IsValid")
   623  		}
   624  
   625  		r = result.r
   626  
   627  		return
   628  	}
   629  
   630  	if m.IsValidFunc == nil {
   631  		m.t.Fatalf("Unexpected call to CalculatorMock.IsValid. %v %v %v", p, p1, p2)
   632  		return
   633  	}
   634  
   635  	return m.IsValidFunc(p, p1, p2)
   636  }
   637  
   638  //IsValidMinimockCounter returns a count of CalculatorMock.IsValidFunc invocations
   639  func (m *CalculatorMock) IsValidMinimockCounter() uint64 {
   640  	return atomic.LoadUint64(&m.IsValidCounter)
   641  }
   642  
   643  //IsValidMinimockPreCounter returns the value of CalculatorMock.IsValid invocations
   644  func (m *CalculatorMock) IsValidMinimockPreCounter() uint64 {
   645  	return atomic.LoadUint64(&m.IsValidPreCounter)
   646  }
   647  
   648  //IsValidFinished returns true if mock invocations count is ok
   649  func (m *CalculatorMock) IsValidFinished() bool {
   650  	// if expectation series were set then invocations count should be equal to expectations count
   651  	if len(m.IsValidMock.expectationSeries) > 0 {
   652  		return atomic.LoadUint64(&m.IsValidCounter) == uint64(len(m.IsValidMock.expectationSeries))
   653  	}
   654  
   655  	// if main expectation was set then invocations count should be greater than zero
   656  	if m.IsValidMock.mainExpectation != nil {
   657  		return atomic.LoadUint64(&m.IsValidCounter) > 0
   658  	}
   659  
   660  	// if func was set then invocations count should be greater than zero
   661  	if m.IsValidFunc != nil {
   662  		return atomic.LoadUint64(&m.IsValidCounter) > 0
   663  	}
   664  
   665  	return true
   666  }
   667  
   668  //ValidateCallCounters checks that all mocked methods of the interface have been called at least once
   669  //Deprecated: please use MinimockFinish method or use Finish method of minimock.Controller
   670  func (m *CalculatorMock) ValidateCallCounters() {
   671  
   672  	if !m.GetCloudProofFinished() {
   673  		m.t.Fatal("Expected call to CalculatorMock.GetCloudProof")
   674  	}
   675  
   676  	if !m.GetGlobuleProofFinished() {
   677  		m.t.Fatal("Expected call to CalculatorMock.GetGlobuleProof")
   678  	}
   679  
   680  	if !m.GetPulseProofFinished() {
   681  		m.t.Fatal("Expected call to CalculatorMock.GetPulseProof")
   682  	}
   683  
   684  	if !m.IsValidFinished() {
   685  		m.t.Fatal("Expected call to CalculatorMock.IsValid")
   686  	}
   687  
   688  }
   689  
   690  //CheckMocksCalled checks that all mocked methods of the interface have been called at least once
   691  //Deprecated: please use MinimockFinish method or use Finish method of minimock.Controller
   692  func (m *CalculatorMock) CheckMocksCalled() {
   693  	m.Finish()
   694  }
   695  
   696  //Finish checks that all mocked methods of the interface have been called at least once
   697  //Deprecated: please use MinimockFinish or use Finish method of minimock.Controller
   698  func (m *CalculatorMock) Finish() {
   699  	m.MinimockFinish()
   700  }
   701  
   702  //MinimockFinish checks that all mocked methods of the interface have been called at least once
   703  func (m *CalculatorMock) MinimockFinish() {
   704  
   705  	if !m.GetCloudProofFinished() {
   706  		m.t.Fatal("Expected call to CalculatorMock.GetCloudProof")
   707  	}
   708  
   709  	if !m.GetGlobuleProofFinished() {
   710  		m.t.Fatal("Expected call to CalculatorMock.GetGlobuleProof")
   711  	}
   712  
   713  	if !m.GetPulseProofFinished() {
   714  		m.t.Fatal("Expected call to CalculatorMock.GetPulseProof")
   715  	}
   716  
   717  	if !m.IsValidFinished() {
   718  		m.t.Fatal("Expected call to CalculatorMock.IsValid")
   719  	}
   720  
   721  }
   722  
   723  //Wait waits for all mocked methods to be called at least once
   724  //Deprecated: please use MinimockWait or use Wait method of minimock.Controller
   725  func (m *CalculatorMock) Wait(timeout time.Duration) {
   726  	m.MinimockWait(timeout)
   727  }
   728  
   729  //MinimockWait waits for all mocked methods to be called at least once
   730  //this method is called by minimock.Controller
   731  func (m *CalculatorMock) MinimockWait(timeout time.Duration) {
   732  	timeoutCh := time.After(timeout)
   733  	for {
   734  		ok := true
   735  		ok = ok && m.GetCloudProofFinished()
   736  		ok = ok && m.GetGlobuleProofFinished()
   737  		ok = ok && m.GetPulseProofFinished()
   738  		ok = ok && m.IsValidFinished()
   739  
   740  		if ok {
   741  			return
   742  		}
   743  
   744  		select {
   745  		case <-timeoutCh:
   746  
   747  			if !m.GetCloudProofFinished() {
   748  				m.t.Error("Expected call to CalculatorMock.GetCloudProof")
   749  			}
   750  
   751  			if !m.GetGlobuleProofFinished() {
   752  				m.t.Error("Expected call to CalculatorMock.GetGlobuleProof")
   753  			}
   754  
   755  			if !m.GetPulseProofFinished() {
   756  				m.t.Error("Expected call to CalculatorMock.GetPulseProof")
   757  			}
   758  
   759  			if !m.IsValidFinished() {
   760  				m.t.Error("Expected call to CalculatorMock.IsValid")
   761  			}
   762  
   763  			m.t.Fatalf("Some mocks were not called on time: %s", timeout)
   764  			return
   765  		default:
   766  			time.Sleep(time.Millisecond)
   767  		}
   768  	}
   769  }
   770  
   771  //AllMocksCalled returns true if all mocked methods were called before the execution of AllMocksCalled,
   772  //it can be used with assert/require, i.e. assert.True(mock.AllMocksCalled())
   773  func (m *CalculatorMock) AllMocksCalled() bool {
   774  
   775  	if !m.GetCloudProofFinished() {
   776  		return false
   777  	}
   778  
   779  	if !m.GetGlobuleProofFinished() {
   780  		return false
   781  	}
   782  
   783  	if !m.GetPulseProofFinished() {
   784  		return false
   785  	}
   786  
   787  	if !m.IsValidFinished() {
   788  		return false
   789  	}
   790  
   791  	return true
   792  }