How to use serialize method of main Package

Best K6 code snippet using main.serialize

certificate_mock.go

Source:certificate_mock.go Github

copy

Full Screen

1package testutils2/*3DO NOT EDIT!4This code was generated automatically using github.com/gojuno/minimock v1.95The original interface "Certificate" can be found in github.com/insolar/insolar/insolar6*/7import (8 crypto "crypto"9 "sync/atomic"10 "time"11 "github.com/gojuno/minimock"12 insolar "github.com/insolar/insolar/insolar"13)14//CertificateMock implements github.com/insolar/insolar/insolar.Certificate15type CertificateMock struct {16 t minimock.Tester17 GetDiscoveryNodesFunc func() (r []insolar.DiscoveryNode)18 GetDiscoveryNodesCounter uint6419 GetDiscoveryNodesPreCounter uint6420 GetDiscoveryNodesMock mCertificateMockGetDiscoveryNodes21 GetDiscoverySignsFunc func() (r map[insolar.Reference][]byte)22 GetDiscoverySignsCounter uint6423 GetDiscoverySignsPreCounter uint6424 GetDiscoverySignsMock mCertificateMockGetDiscoverySigns25 GetMajorityRuleFunc func() (r int)26 GetMajorityRuleCounter uint6427 GetMajorityRulePreCounter uint6428 GetMajorityRuleMock mCertificateMockGetMajorityRule29 GetMinRolesFunc func() (r uint, r1 uint, r2 uint)30 GetMinRolesCounter uint6431 GetMinRolesPreCounter uint6432 GetMinRolesMock mCertificateMockGetMinRoles33 GetNodeRefFunc func() (r *insolar.Reference)34 GetNodeRefCounter uint6435 GetNodeRefPreCounter uint6436 GetNodeRefMock mCertificateMockGetNodeRef37 GetPublicKeyFunc func() (r crypto.PublicKey)38 GetPublicKeyCounter uint6439 GetPublicKeyPreCounter uint6440 GetPublicKeyMock mCertificateMockGetPublicKey41 GetRoleFunc func() (r insolar.StaticRole)42 GetRoleCounter uint6443 GetRolePreCounter uint6444 GetRoleMock mCertificateMockGetRole45 GetRootDomainReferenceFunc func() (r *insolar.Reference)46 GetRootDomainReferenceCounter uint6447 GetRootDomainReferencePreCounter uint6448 GetRootDomainReferenceMock mCertificateMockGetRootDomainReference49 SerializeNodePartFunc func() (r []byte)50 SerializeNodePartCounter uint6451 SerializeNodePartPreCounter uint6452 SerializeNodePartMock mCertificateMockSerializeNodePart53}54//NewCertificateMock returns a mock for github.com/insolar/insolar/insolar.Certificate55func NewCertificateMock(t minimock.Tester) *CertificateMock {56 m := &CertificateMock{t: t}57 if controller, ok := t.(minimock.MockController); ok {58 controller.RegisterMocker(m)59 }60 m.GetDiscoveryNodesMock = mCertificateMockGetDiscoveryNodes{mock: m}61 m.GetDiscoverySignsMock = mCertificateMockGetDiscoverySigns{mock: m}62 m.GetMajorityRuleMock = mCertificateMockGetMajorityRule{mock: m}63 m.GetMinRolesMock = mCertificateMockGetMinRoles{mock: m}64 m.GetNodeRefMock = mCertificateMockGetNodeRef{mock: m}65 m.GetPublicKeyMock = mCertificateMockGetPublicKey{mock: m}66 m.GetRoleMock = mCertificateMockGetRole{mock: m}67 m.GetRootDomainReferenceMock = mCertificateMockGetRootDomainReference{mock: m}68 m.SerializeNodePartMock = mCertificateMockSerializeNodePart{mock: m}69 return m70}71type mCertificateMockGetDiscoveryNodes struct {72 mock *CertificateMock73 mainExpectation *CertificateMockGetDiscoveryNodesExpectation74 expectationSeries []*CertificateMockGetDiscoveryNodesExpectation75}76type CertificateMockGetDiscoveryNodesExpectation struct {77 result *CertificateMockGetDiscoveryNodesResult78}79type CertificateMockGetDiscoveryNodesResult struct {80 r []insolar.DiscoveryNode81}82//Expect specifies that invocation of Certificate.GetDiscoveryNodes is expected from 1 to Infinity times83func (m *mCertificateMockGetDiscoveryNodes) Expect() *mCertificateMockGetDiscoveryNodes {84 m.mock.GetDiscoveryNodesFunc = nil85 m.expectationSeries = nil86 if m.mainExpectation == nil {87 m.mainExpectation = &CertificateMockGetDiscoveryNodesExpectation{}88 }89 return m90}91//Return specifies results of invocation of Certificate.GetDiscoveryNodes92func (m *mCertificateMockGetDiscoveryNodes) Return(r []insolar.DiscoveryNode) *CertificateMock {93 m.mock.GetDiscoveryNodesFunc = nil94 m.expectationSeries = nil95 if m.mainExpectation == nil {96 m.mainExpectation = &CertificateMockGetDiscoveryNodesExpectation{}97 }98 m.mainExpectation.result = &CertificateMockGetDiscoveryNodesResult{r}99 return m.mock100}101//ExpectOnce specifies that invocation of Certificate.GetDiscoveryNodes is expected once102func (m *mCertificateMockGetDiscoveryNodes) ExpectOnce() *CertificateMockGetDiscoveryNodesExpectation {103 m.mock.GetDiscoveryNodesFunc = nil104 m.mainExpectation = nil105 expectation := &CertificateMockGetDiscoveryNodesExpectation{}106 m.expectationSeries = append(m.expectationSeries, expectation)107 return expectation108}109func (e *CertificateMockGetDiscoveryNodesExpectation) Return(r []insolar.DiscoveryNode) {110 e.result = &CertificateMockGetDiscoveryNodesResult{r}111}112//Set uses given function f as a mock of Certificate.GetDiscoveryNodes method113func (m *mCertificateMockGetDiscoveryNodes) Set(f func() (r []insolar.DiscoveryNode)) *CertificateMock {114 m.mainExpectation = nil115 m.expectationSeries = nil116 m.mock.GetDiscoveryNodesFunc = f117 return m.mock118}119//GetDiscoveryNodes implements github.com/insolar/insolar/insolar.Certificate interface120func (m *CertificateMock) GetDiscoveryNodes() (r []insolar.DiscoveryNode) {121 counter := atomic.AddUint64(&m.GetDiscoveryNodesPreCounter, 1)122 defer atomic.AddUint64(&m.GetDiscoveryNodesCounter, 1)123 if len(m.GetDiscoveryNodesMock.expectationSeries) > 0 {124 if counter > uint64(len(m.GetDiscoveryNodesMock.expectationSeries)) {125 m.t.Fatalf("Unexpected call to CertificateMock.GetDiscoveryNodes.")126 return127 }128 result := m.GetDiscoveryNodesMock.expectationSeries[counter-1].result129 if result == nil {130 m.t.Fatal("No results are set for the CertificateMock.GetDiscoveryNodes")131 return132 }133 r = result.r134 return135 }136 if m.GetDiscoveryNodesMock.mainExpectation != nil {137 result := m.GetDiscoveryNodesMock.mainExpectation.result138 if result == nil {139 m.t.Fatal("No results are set for the CertificateMock.GetDiscoveryNodes")140 }141 r = result.r142 return143 }144 if m.GetDiscoveryNodesFunc == nil {145 m.t.Fatalf("Unexpected call to CertificateMock.GetDiscoveryNodes.")146 return147 }148 return m.GetDiscoveryNodesFunc()149}150//GetDiscoveryNodesMinimockCounter returns a count of CertificateMock.GetDiscoveryNodesFunc invocations151func (m *CertificateMock) GetDiscoveryNodesMinimockCounter() uint64 {152 return atomic.LoadUint64(&m.GetDiscoveryNodesCounter)153}154//GetDiscoveryNodesMinimockPreCounter returns the value of CertificateMock.GetDiscoveryNodes invocations155func (m *CertificateMock) GetDiscoveryNodesMinimockPreCounter() uint64 {156 return atomic.LoadUint64(&m.GetDiscoveryNodesPreCounter)157}158//GetDiscoveryNodesFinished returns true if mock invocations count is ok159func (m *CertificateMock) GetDiscoveryNodesFinished() bool {160 // if expectation series were set then invocations count should be equal to expectations count161 if len(m.GetDiscoveryNodesMock.expectationSeries) > 0 {162 return atomic.LoadUint64(&m.GetDiscoveryNodesCounter) == uint64(len(m.GetDiscoveryNodesMock.expectationSeries))163 }164 // if main expectation was set then invocations count should be greater than zero165 if m.GetDiscoveryNodesMock.mainExpectation != nil {166 return atomic.LoadUint64(&m.GetDiscoveryNodesCounter) > 0167 }168 // if func was set then invocations count should be greater than zero169 if m.GetDiscoveryNodesFunc != nil {170 return atomic.LoadUint64(&m.GetDiscoveryNodesCounter) > 0171 }172 return true173}174type mCertificateMockGetDiscoverySigns struct {175 mock *CertificateMock176 mainExpectation *CertificateMockGetDiscoverySignsExpectation177 expectationSeries []*CertificateMockGetDiscoverySignsExpectation178}179type CertificateMockGetDiscoverySignsExpectation struct {180 result *CertificateMockGetDiscoverySignsResult181}182type CertificateMockGetDiscoverySignsResult struct {183 r map[insolar.Reference][]byte184}185//Expect specifies that invocation of Certificate.GetDiscoverySigns is expected from 1 to Infinity times186func (m *mCertificateMockGetDiscoverySigns) Expect() *mCertificateMockGetDiscoverySigns {187 m.mock.GetDiscoverySignsFunc = nil188 m.expectationSeries = nil189 if m.mainExpectation == nil {190 m.mainExpectation = &CertificateMockGetDiscoverySignsExpectation{}191 }192 return m193}194//Return specifies results of invocation of Certificate.GetDiscoverySigns195func (m *mCertificateMockGetDiscoverySigns) Return(r map[insolar.Reference][]byte) *CertificateMock {196 m.mock.GetDiscoverySignsFunc = nil197 m.expectationSeries = nil198 if m.mainExpectation == nil {199 m.mainExpectation = &CertificateMockGetDiscoverySignsExpectation{}200 }201 m.mainExpectation.result = &CertificateMockGetDiscoverySignsResult{r}202 return m.mock203}204//ExpectOnce specifies that invocation of Certificate.GetDiscoverySigns is expected once205func (m *mCertificateMockGetDiscoverySigns) ExpectOnce() *CertificateMockGetDiscoverySignsExpectation {206 m.mock.GetDiscoverySignsFunc = nil207 m.mainExpectation = nil208 expectation := &CertificateMockGetDiscoverySignsExpectation{}209 m.expectationSeries = append(m.expectationSeries, expectation)210 return expectation211}212func (e *CertificateMockGetDiscoverySignsExpectation) Return(r map[insolar.Reference][]byte) {213 e.result = &CertificateMockGetDiscoverySignsResult{r}214}215//Set uses given function f as a mock of Certificate.GetDiscoverySigns method216func (m *mCertificateMockGetDiscoverySigns) Set(f func() (r map[insolar.Reference][]byte)) *CertificateMock {217 m.mainExpectation = nil218 m.expectationSeries = nil219 m.mock.GetDiscoverySignsFunc = f220 return m.mock221}222//GetDiscoverySigns implements github.com/insolar/insolar/insolar.Certificate interface223func (m *CertificateMock) GetDiscoverySigns() (r map[insolar.Reference][]byte) {224 counter := atomic.AddUint64(&m.GetDiscoverySignsPreCounter, 1)225 defer atomic.AddUint64(&m.GetDiscoverySignsCounter, 1)226 if len(m.GetDiscoverySignsMock.expectationSeries) > 0 {227 if counter > uint64(len(m.GetDiscoverySignsMock.expectationSeries)) {228 m.t.Fatalf("Unexpected call to CertificateMock.GetDiscoverySigns.")229 return230 }231 result := m.GetDiscoverySignsMock.expectationSeries[counter-1].result232 if result == nil {233 m.t.Fatal("No results are set for the CertificateMock.GetDiscoverySigns")234 return235 }236 r = result.r237 return238 }239 if m.GetDiscoverySignsMock.mainExpectation != nil {240 result := m.GetDiscoverySignsMock.mainExpectation.result241 if result == nil {242 m.t.Fatal("No results are set for the CertificateMock.GetDiscoverySigns")243 }244 r = result.r245 return246 }247 if m.GetDiscoverySignsFunc == nil {248 m.t.Fatalf("Unexpected call to CertificateMock.GetDiscoverySigns.")249 return250 }251 return m.GetDiscoverySignsFunc()252}253//GetDiscoverySignsMinimockCounter returns a count of CertificateMock.GetDiscoverySignsFunc invocations254func (m *CertificateMock) GetDiscoverySignsMinimockCounter() uint64 {255 return atomic.LoadUint64(&m.GetDiscoverySignsCounter)256}257//GetDiscoverySignsMinimockPreCounter returns the value of CertificateMock.GetDiscoverySigns invocations258func (m *CertificateMock) GetDiscoverySignsMinimockPreCounter() uint64 {259 return atomic.LoadUint64(&m.GetDiscoverySignsPreCounter)260}261//GetDiscoverySignsFinished returns true if mock invocations count is ok262func (m *CertificateMock) GetDiscoverySignsFinished() bool {263 // if expectation series were set then invocations count should be equal to expectations count264 if len(m.GetDiscoverySignsMock.expectationSeries) > 0 {265 return atomic.LoadUint64(&m.GetDiscoverySignsCounter) == uint64(len(m.GetDiscoverySignsMock.expectationSeries))266 }267 // if main expectation was set then invocations count should be greater than zero268 if m.GetDiscoverySignsMock.mainExpectation != nil {269 return atomic.LoadUint64(&m.GetDiscoverySignsCounter) > 0270 }271 // if func was set then invocations count should be greater than zero272 if m.GetDiscoverySignsFunc != nil {273 return atomic.LoadUint64(&m.GetDiscoverySignsCounter) > 0274 }275 return true276}277type mCertificateMockGetMajorityRule struct {278 mock *CertificateMock279 mainExpectation *CertificateMockGetMajorityRuleExpectation280 expectationSeries []*CertificateMockGetMajorityRuleExpectation281}282type CertificateMockGetMajorityRuleExpectation struct {283 result *CertificateMockGetMajorityRuleResult284}285type CertificateMockGetMajorityRuleResult struct {286 r int287}288//Expect specifies that invocation of Certificate.GetMajorityRule is expected from 1 to Infinity times289func (m *mCertificateMockGetMajorityRule) Expect() *mCertificateMockGetMajorityRule {290 m.mock.GetMajorityRuleFunc = nil291 m.expectationSeries = nil292 if m.mainExpectation == nil {293 m.mainExpectation = &CertificateMockGetMajorityRuleExpectation{}294 }295 return m296}297//Return specifies results of invocation of Certificate.GetMajorityRule298func (m *mCertificateMockGetMajorityRule) Return(r int) *CertificateMock {299 m.mock.GetMajorityRuleFunc = nil300 m.expectationSeries = nil301 if m.mainExpectation == nil {302 m.mainExpectation = &CertificateMockGetMajorityRuleExpectation{}303 }304 m.mainExpectation.result = &CertificateMockGetMajorityRuleResult{r}305 return m.mock306}307//ExpectOnce specifies that invocation of Certificate.GetMajorityRule is expected once308func (m *mCertificateMockGetMajorityRule) ExpectOnce() *CertificateMockGetMajorityRuleExpectation {309 m.mock.GetMajorityRuleFunc = nil310 m.mainExpectation = nil311 expectation := &CertificateMockGetMajorityRuleExpectation{}312 m.expectationSeries = append(m.expectationSeries, expectation)313 return expectation314}315func (e *CertificateMockGetMajorityRuleExpectation) Return(r int) {316 e.result = &CertificateMockGetMajorityRuleResult{r}317}318//Set uses given function f as a mock of Certificate.GetMajorityRule method319func (m *mCertificateMockGetMajorityRule) Set(f func() (r int)) *CertificateMock {320 m.mainExpectation = nil321 m.expectationSeries = nil322 m.mock.GetMajorityRuleFunc = f323 return m.mock324}325//GetMajorityRule implements github.com/insolar/insolar/insolar.Certificate interface326func (m *CertificateMock) GetMajorityRule() (r int) {327 counter := atomic.AddUint64(&m.GetMajorityRulePreCounter, 1)328 defer atomic.AddUint64(&m.GetMajorityRuleCounter, 1)329 if len(m.GetMajorityRuleMock.expectationSeries) > 0 {330 if counter > uint64(len(m.GetMajorityRuleMock.expectationSeries)) {331 m.t.Fatalf("Unexpected call to CertificateMock.GetMajorityRule.")332 return333 }334 result := m.GetMajorityRuleMock.expectationSeries[counter-1].result335 if result == nil {336 m.t.Fatal("No results are set for the CertificateMock.GetMajorityRule")337 return338 }339 r = result.r340 return341 }342 if m.GetMajorityRuleMock.mainExpectation != nil {343 result := m.GetMajorityRuleMock.mainExpectation.result344 if result == nil {345 m.t.Fatal("No results are set for the CertificateMock.GetMajorityRule")346 }347 r = result.r348 return349 }350 if m.GetMajorityRuleFunc == nil {351 m.t.Fatalf("Unexpected call to CertificateMock.GetMajorityRule.")352 return353 }354 return m.GetMajorityRuleFunc()355}356//GetMajorityRuleMinimockCounter returns a count of CertificateMock.GetMajorityRuleFunc invocations357func (m *CertificateMock) GetMajorityRuleMinimockCounter() uint64 {358 return atomic.LoadUint64(&m.GetMajorityRuleCounter)359}360//GetMajorityRuleMinimockPreCounter returns the value of CertificateMock.GetMajorityRule invocations361func (m *CertificateMock) GetMajorityRuleMinimockPreCounter() uint64 {362 return atomic.LoadUint64(&m.GetMajorityRulePreCounter)363}364//GetMajorityRuleFinished returns true if mock invocations count is ok365func (m *CertificateMock) GetMajorityRuleFinished() bool {366 // if expectation series were set then invocations count should be equal to expectations count367 if len(m.GetMajorityRuleMock.expectationSeries) > 0 {368 return atomic.LoadUint64(&m.GetMajorityRuleCounter) == uint64(len(m.GetMajorityRuleMock.expectationSeries))369 }370 // if main expectation was set then invocations count should be greater than zero371 if m.GetMajorityRuleMock.mainExpectation != nil {372 return atomic.LoadUint64(&m.GetMajorityRuleCounter) > 0373 }374 // if func was set then invocations count should be greater than zero375 if m.GetMajorityRuleFunc != nil {376 return atomic.LoadUint64(&m.GetMajorityRuleCounter) > 0377 }378 return true379}380type mCertificateMockGetMinRoles struct {381 mock *CertificateMock382 mainExpectation *CertificateMockGetMinRolesExpectation383 expectationSeries []*CertificateMockGetMinRolesExpectation384}385type CertificateMockGetMinRolesExpectation struct {386 result *CertificateMockGetMinRolesResult387}388type CertificateMockGetMinRolesResult struct {389 r uint390 r1 uint391 r2 uint392}393//Expect specifies that invocation of Certificate.GetMinRoles is expected from 1 to Infinity times394func (m *mCertificateMockGetMinRoles) Expect() *mCertificateMockGetMinRoles {395 m.mock.GetMinRolesFunc = nil396 m.expectationSeries = nil397 if m.mainExpectation == nil {398 m.mainExpectation = &CertificateMockGetMinRolesExpectation{}399 }400 return m401}402//Return specifies results of invocation of Certificate.GetMinRoles403func (m *mCertificateMockGetMinRoles) Return(r uint, r1 uint, r2 uint) *CertificateMock {404 m.mock.GetMinRolesFunc = nil405 m.expectationSeries = nil406 if m.mainExpectation == nil {407 m.mainExpectation = &CertificateMockGetMinRolesExpectation{}408 }409 m.mainExpectation.result = &CertificateMockGetMinRolesResult{r, r1, r2}410 return m.mock411}412//ExpectOnce specifies that invocation of Certificate.GetMinRoles is expected once413func (m *mCertificateMockGetMinRoles) ExpectOnce() *CertificateMockGetMinRolesExpectation {414 m.mock.GetMinRolesFunc = nil415 m.mainExpectation = nil416 expectation := &CertificateMockGetMinRolesExpectation{}417 m.expectationSeries = append(m.expectationSeries, expectation)418 return expectation419}420func (e *CertificateMockGetMinRolesExpectation) Return(r uint, r1 uint, r2 uint) {421 e.result = &CertificateMockGetMinRolesResult{r, r1, r2}422}423//Set uses given function f as a mock of Certificate.GetMinRoles method424func (m *mCertificateMockGetMinRoles) Set(f func() (r uint, r1 uint, r2 uint)) *CertificateMock {425 m.mainExpectation = nil426 m.expectationSeries = nil427 m.mock.GetMinRolesFunc = f428 return m.mock429}430//GetMinRoles implements github.com/insolar/insolar/insolar.Certificate interface431func (m *CertificateMock) GetMinRoles() (r uint, r1 uint, r2 uint) {432 counter := atomic.AddUint64(&m.GetMinRolesPreCounter, 1)433 defer atomic.AddUint64(&m.GetMinRolesCounter, 1)434 if len(m.GetMinRolesMock.expectationSeries) > 0 {435 if counter > uint64(len(m.GetMinRolesMock.expectationSeries)) {436 m.t.Fatalf("Unexpected call to CertificateMock.GetMinRoles.")437 return438 }439 result := m.GetMinRolesMock.expectationSeries[counter-1].result440 if result == nil {441 m.t.Fatal("No results are set for the CertificateMock.GetMinRoles")442 return443 }444 r = result.r445 r1 = result.r1446 r2 = result.r2447 return448 }449 if m.GetMinRolesMock.mainExpectation != nil {450 result := m.GetMinRolesMock.mainExpectation.result451 if result == nil {452 m.t.Fatal("No results are set for the CertificateMock.GetMinRoles")453 }454 r = result.r455 r1 = result.r1456 r2 = result.r2457 return458 }459 if m.GetMinRolesFunc == nil {460 m.t.Fatalf("Unexpected call to CertificateMock.GetMinRoles.")461 return462 }463 return m.GetMinRolesFunc()464}465//GetMinRolesMinimockCounter returns a count of CertificateMock.GetMinRolesFunc invocations466func (m *CertificateMock) GetMinRolesMinimockCounter() uint64 {467 return atomic.LoadUint64(&m.GetMinRolesCounter)468}469//GetMinRolesMinimockPreCounter returns the value of CertificateMock.GetMinRoles invocations470func (m *CertificateMock) GetMinRolesMinimockPreCounter() uint64 {471 return atomic.LoadUint64(&m.GetMinRolesPreCounter)472}473//GetMinRolesFinished returns true if mock invocations count is ok474func (m *CertificateMock) GetMinRolesFinished() bool {475 // if expectation series were set then invocations count should be equal to expectations count476 if len(m.GetMinRolesMock.expectationSeries) > 0 {477 return atomic.LoadUint64(&m.GetMinRolesCounter) == uint64(len(m.GetMinRolesMock.expectationSeries))478 }479 // if main expectation was set then invocations count should be greater than zero480 if m.GetMinRolesMock.mainExpectation != nil {481 return atomic.LoadUint64(&m.GetMinRolesCounter) > 0482 }483 // if func was set then invocations count should be greater than zero484 if m.GetMinRolesFunc != nil {485 return atomic.LoadUint64(&m.GetMinRolesCounter) > 0486 }487 return true488}489type mCertificateMockGetNodeRef struct {490 mock *CertificateMock491 mainExpectation *CertificateMockGetNodeRefExpectation492 expectationSeries []*CertificateMockGetNodeRefExpectation493}494type CertificateMockGetNodeRefExpectation struct {495 result *CertificateMockGetNodeRefResult496}497type CertificateMockGetNodeRefResult struct {498 r *insolar.Reference499}500//Expect specifies that invocation of Certificate.GetNodeRef is expected from 1 to Infinity times501func (m *mCertificateMockGetNodeRef) Expect() *mCertificateMockGetNodeRef {502 m.mock.GetNodeRefFunc = nil503 m.expectationSeries = nil504 if m.mainExpectation == nil {505 m.mainExpectation = &CertificateMockGetNodeRefExpectation{}506 }507 return m508}509//Return specifies results of invocation of Certificate.GetNodeRef510func (m *mCertificateMockGetNodeRef) Return(r *insolar.Reference) *CertificateMock {511 m.mock.GetNodeRefFunc = nil512 m.expectationSeries = nil513 if m.mainExpectation == nil {514 m.mainExpectation = &CertificateMockGetNodeRefExpectation{}515 }516 m.mainExpectation.result = &CertificateMockGetNodeRefResult{r}517 return m.mock518}519//ExpectOnce specifies that invocation of Certificate.GetNodeRef is expected once520func (m *mCertificateMockGetNodeRef) ExpectOnce() *CertificateMockGetNodeRefExpectation {521 m.mock.GetNodeRefFunc = nil522 m.mainExpectation = nil523 expectation := &CertificateMockGetNodeRefExpectation{}524 m.expectationSeries = append(m.expectationSeries, expectation)525 return expectation526}527func (e *CertificateMockGetNodeRefExpectation) Return(r *insolar.Reference) {528 e.result = &CertificateMockGetNodeRefResult{r}529}530//Set uses given function f as a mock of Certificate.GetNodeRef method531func (m *mCertificateMockGetNodeRef) Set(f func() (r *insolar.Reference)) *CertificateMock {532 m.mainExpectation = nil533 m.expectationSeries = nil534 m.mock.GetNodeRefFunc = f535 return m.mock536}537//GetNodeRef implements github.com/insolar/insolar/insolar.Certificate interface538func (m *CertificateMock) GetNodeRef() (r *insolar.Reference) {539 counter := atomic.AddUint64(&m.GetNodeRefPreCounter, 1)540 defer atomic.AddUint64(&m.GetNodeRefCounter, 1)541 if len(m.GetNodeRefMock.expectationSeries) > 0 {542 if counter > uint64(len(m.GetNodeRefMock.expectationSeries)) {543 m.t.Fatalf("Unexpected call to CertificateMock.GetNodeRef.")544 return545 }546 result := m.GetNodeRefMock.expectationSeries[counter-1].result547 if result == nil {548 m.t.Fatal("No results are set for the CertificateMock.GetNodeRef")549 return550 }551 r = result.r552 return553 }554 if m.GetNodeRefMock.mainExpectation != nil {555 result := m.GetNodeRefMock.mainExpectation.result556 if result == nil {557 m.t.Fatal("No results are set for the CertificateMock.GetNodeRef")558 }559 r = result.r560 return561 }562 if m.GetNodeRefFunc == nil {563 m.t.Fatalf("Unexpected call to CertificateMock.GetNodeRef.")564 return565 }566 return m.GetNodeRefFunc()567}568//GetNodeRefMinimockCounter returns a count of CertificateMock.GetNodeRefFunc invocations569func (m *CertificateMock) GetNodeRefMinimockCounter() uint64 {570 return atomic.LoadUint64(&m.GetNodeRefCounter)571}572//GetNodeRefMinimockPreCounter returns the value of CertificateMock.GetNodeRef invocations573func (m *CertificateMock) GetNodeRefMinimockPreCounter() uint64 {574 return atomic.LoadUint64(&m.GetNodeRefPreCounter)575}576//GetNodeRefFinished returns true if mock invocations count is ok577func (m *CertificateMock) GetNodeRefFinished() bool {578 // if expectation series were set then invocations count should be equal to expectations count579 if len(m.GetNodeRefMock.expectationSeries) > 0 {580 return atomic.LoadUint64(&m.GetNodeRefCounter) == uint64(len(m.GetNodeRefMock.expectationSeries))581 }582 // if main expectation was set then invocations count should be greater than zero583 if m.GetNodeRefMock.mainExpectation != nil {584 return atomic.LoadUint64(&m.GetNodeRefCounter) > 0585 }586 // if func was set then invocations count should be greater than zero587 if m.GetNodeRefFunc != nil {588 return atomic.LoadUint64(&m.GetNodeRefCounter) > 0589 }590 return true591}592type mCertificateMockGetPublicKey struct {593 mock *CertificateMock594 mainExpectation *CertificateMockGetPublicKeyExpectation595 expectationSeries []*CertificateMockGetPublicKeyExpectation596}597type CertificateMockGetPublicKeyExpectation struct {598 result *CertificateMockGetPublicKeyResult599}600type CertificateMockGetPublicKeyResult struct {601 r crypto.PublicKey602}603//Expect specifies that invocation of Certificate.GetPublicKey is expected from 1 to Infinity times604func (m *mCertificateMockGetPublicKey) Expect() *mCertificateMockGetPublicKey {605 m.mock.GetPublicKeyFunc = nil606 m.expectationSeries = nil607 if m.mainExpectation == nil {608 m.mainExpectation = &CertificateMockGetPublicKeyExpectation{}609 }610 return m611}612//Return specifies results of invocation of Certificate.GetPublicKey613func (m *mCertificateMockGetPublicKey) Return(r crypto.PublicKey) *CertificateMock {614 m.mock.GetPublicKeyFunc = nil615 m.expectationSeries = nil616 if m.mainExpectation == nil {617 m.mainExpectation = &CertificateMockGetPublicKeyExpectation{}618 }619 m.mainExpectation.result = &CertificateMockGetPublicKeyResult{r}620 return m.mock621}622//ExpectOnce specifies that invocation of Certificate.GetPublicKey is expected once623func (m *mCertificateMockGetPublicKey) ExpectOnce() *CertificateMockGetPublicKeyExpectation {624 m.mock.GetPublicKeyFunc = nil625 m.mainExpectation = nil626 expectation := &CertificateMockGetPublicKeyExpectation{}627 m.expectationSeries = append(m.expectationSeries, expectation)628 return expectation629}630func (e *CertificateMockGetPublicKeyExpectation) Return(r crypto.PublicKey) {631 e.result = &CertificateMockGetPublicKeyResult{r}632}633//Set uses given function f as a mock of Certificate.GetPublicKey method634func (m *mCertificateMockGetPublicKey) Set(f func() (r crypto.PublicKey)) *CertificateMock {635 m.mainExpectation = nil636 m.expectationSeries = nil637 m.mock.GetPublicKeyFunc = f638 return m.mock639}640//GetPublicKey implements github.com/insolar/insolar/insolar.Certificate interface641func (m *CertificateMock) GetPublicKey() (r crypto.PublicKey) {642 counter := atomic.AddUint64(&m.GetPublicKeyPreCounter, 1)643 defer atomic.AddUint64(&m.GetPublicKeyCounter, 1)644 if len(m.GetPublicKeyMock.expectationSeries) > 0 {645 if counter > uint64(len(m.GetPublicKeyMock.expectationSeries)) {646 m.t.Fatalf("Unexpected call to CertificateMock.GetPublicKey.")647 return648 }649 result := m.GetPublicKeyMock.expectationSeries[counter-1].result650 if result == nil {651 m.t.Fatal("No results are set for the CertificateMock.GetPublicKey")652 return653 }654 r = result.r655 return656 }657 if m.GetPublicKeyMock.mainExpectation != nil {658 result := m.GetPublicKeyMock.mainExpectation.result659 if result == nil {660 m.t.Fatal("No results are set for the CertificateMock.GetPublicKey")661 }662 r = result.r663 return664 }665 if m.GetPublicKeyFunc == nil {666 m.t.Fatalf("Unexpected call to CertificateMock.GetPublicKey.")667 return668 }669 return m.GetPublicKeyFunc()670}671//GetPublicKeyMinimockCounter returns a count of CertificateMock.GetPublicKeyFunc invocations672func (m *CertificateMock) GetPublicKeyMinimockCounter() uint64 {673 return atomic.LoadUint64(&m.GetPublicKeyCounter)674}675//GetPublicKeyMinimockPreCounter returns the value of CertificateMock.GetPublicKey invocations676func (m *CertificateMock) GetPublicKeyMinimockPreCounter() uint64 {677 return atomic.LoadUint64(&m.GetPublicKeyPreCounter)678}679//GetPublicKeyFinished returns true if mock invocations count is ok680func (m *CertificateMock) GetPublicKeyFinished() bool {681 // if expectation series were set then invocations count should be equal to expectations count682 if len(m.GetPublicKeyMock.expectationSeries) > 0 {683 return atomic.LoadUint64(&m.GetPublicKeyCounter) == uint64(len(m.GetPublicKeyMock.expectationSeries))684 }685 // if main expectation was set then invocations count should be greater than zero686 if m.GetPublicKeyMock.mainExpectation != nil {687 return atomic.LoadUint64(&m.GetPublicKeyCounter) > 0688 }689 // if func was set then invocations count should be greater than zero690 if m.GetPublicKeyFunc != nil {691 return atomic.LoadUint64(&m.GetPublicKeyCounter) > 0692 }693 return true694}695type mCertificateMockGetRole struct {696 mock *CertificateMock697 mainExpectation *CertificateMockGetRoleExpectation698 expectationSeries []*CertificateMockGetRoleExpectation699}700type CertificateMockGetRoleExpectation struct {701 result *CertificateMockGetRoleResult702}703type CertificateMockGetRoleResult struct {704 r insolar.StaticRole705}706//Expect specifies that invocation of Certificate.GetRole is expected from 1 to Infinity times707func (m *mCertificateMockGetRole) Expect() *mCertificateMockGetRole {708 m.mock.GetRoleFunc = nil709 m.expectationSeries = nil710 if m.mainExpectation == nil {711 m.mainExpectation = &CertificateMockGetRoleExpectation{}712 }713 return m714}715//Return specifies results of invocation of Certificate.GetRole716func (m *mCertificateMockGetRole) Return(r insolar.StaticRole) *CertificateMock {717 m.mock.GetRoleFunc = nil718 m.expectationSeries = nil719 if m.mainExpectation == nil {720 m.mainExpectation = &CertificateMockGetRoleExpectation{}721 }722 m.mainExpectation.result = &CertificateMockGetRoleResult{r}723 return m.mock724}725//ExpectOnce specifies that invocation of Certificate.GetRole is expected once726func (m *mCertificateMockGetRole) ExpectOnce() *CertificateMockGetRoleExpectation {727 m.mock.GetRoleFunc = nil728 m.mainExpectation = nil729 expectation := &CertificateMockGetRoleExpectation{}730 m.expectationSeries = append(m.expectationSeries, expectation)731 return expectation732}733func (e *CertificateMockGetRoleExpectation) Return(r insolar.StaticRole) {734 e.result = &CertificateMockGetRoleResult{r}735}736//Set uses given function f as a mock of Certificate.GetRole method737func (m *mCertificateMockGetRole) Set(f func() (r insolar.StaticRole)) *CertificateMock {738 m.mainExpectation = nil739 m.expectationSeries = nil740 m.mock.GetRoleFunc = f741 return m.mock742}743//GetRole implements github.com/insolar/insolar/insolar.Certificate interface744func (m *CertificateMock) GetRole() (r insolar.StaticRole) {745 counter := atomic.AddUint64(&m.GetRolePreCounter, 1)746 defer atomic.AddUint64(&m.GetRoleCounter, 1)747 if len(m.GetRoleMock.expectationSeries) > 0 {748 if counter > uint64(len(m.GetRoleMock.expectationSeries)) {749 m.t.Fatalf("Unexpected call to CertificateMock.GetRole.")750 return751 }752 result := m.GetRoleMock.expectationSeries[counter-1].result753 if result == nil {754 m.t.Fatal("No results are set for the CertificateMock.GetRole")755 return756 }757 r = result.r758 return759 }760 if m.GetRoleMock.mainExpectation != nil {761 result := m.GetRoleMock.mainExpectation.result762 if result == nil {763 m.t.Fatal("No results are set for the CertificateMock.GetRole")764 }765 r = result.r766 return767 }768 if m.GetRoleFunc == nil {769 m.t.Fatalf("Unexpected call to CertificateMock.GetRole.")770 return771 }772 return m.GetRoleFunc()773}774//GetRoleMinimockCounter returns a count of CertificateMock.GetRoleFunc invocations775func (m *CertificateMock) GetRoleMinimockCounter() uint64 {776 return atomic.LoadUint64(&m.GetRoleCounter)777}778//GetRoleMinimockPreCounter returns the value of CertificateMock.GetRole invocations779func (m *CertificateMock) GetRoleMinimockPreCounter() uint64 {780 return atomic.LoadUint64(&m.GetRolePreCounter)781}782//GetRoleFinished returns true if mock invocations count is ok783func (m *CertificateMock) GetRoleFinished() bool {784 // if expectation series were set then invocations count should be equal to expectations count785 if len(m.GetRoleMock.expectationSeries) > 0 {786 return atomic.LoadUint64(&m.GetRoleCounter) == uint64(len(m.GetRoleMock.expectationSeries))787 }788 // if main expectation was set then invocations count should be greater than zero789 if m.GetRoleMock.mainExpectation != nil {790 return atomic.LoadUint64(&m.GetRoleCounter) > 0791 }792 // if func was set then invocations count should be greater than zero793 if m.GetRoleFunc != nil {794 return atomic.LoadUint64(&m.GetRoleCounter) > 0795 }796 return true797}798type mCertificateMockGetRootDomainReference struct {799 mock *CertificateMock800 mainExpectation *CertificateMockGetRootDomainReferenceExpectation801 expectationSeries []*CertificateMockGetRootDomainReferenceExpectation802}803type CertificateMockGetRootDomainReferenceExpectation struct {804 result *CertificateMockGetRootDomainReferenceResult805}806type CertificateMockGetRootDomainReferenceResult struct {807 r *insolar.Reference808}809//Expect specifies that invocation of Certificate.GetRootDomainReference is expected from 1 to Infinity times810func (m *mCertificateMockGetRootDomainReference) Expect() *mCertificateMockGetRootDomainReference {811 m.mock.GetRootDomainReferenceFunc = nil812 m.expectationSeries = nil813 if m.mainExpectation == nil {814 m.mainExpectation = &CertificateMockGetRootDomainReferenceExpectation{}815 }816 return m817}818//Return specifies results of invocation of Certificate.GetRootDomainReference819func (m *mCertificateMockGetRootDomainReference) Return(r *insolar.Reference) *CertificateMock {820 m.mock.GetRootDomainReferenceFunc = nil821 m.expectationSeries = nil822 if m.mainExpectation == nil {823 m.mainExpectation = &CertificateMockGetRootDomainReferenceExpectation{}824 }825 m.mainExpectation.result = &CertificateMockGetRootDomainReferenceResult{r}826 return m.mock827}828//ExpectOnce specifies that invocation of Certificate.GetRootDomainReference is expected once829func (m *mCertificateMockGetRootDomainReference) ExpectOnce() *CertificateMockGetRootDomainReferenceExpectation {830 m.mock.GetRootDomainReferenceFunc = nil831 m.mainExpectation = nil832 expectation := &CertificateMockGetRootDomainReferenceExpectation{}833 m.expectationSeries = append(m.expectationSeries, expectation)834 return expectation835}836func (e *CertificateMockGetRootDomainReferenceExpectation) Return(r *insolar.Reference) {837 e.result = &CertificateMockGetRootDomainReferenceResult{r}838}839//Set uses given function f as a mock of Certificate.GetRootDomainReference method840func (m *mCertificateMockGetRootDomainReference) Set(f func() (r *insolar.Reference)) *CertificateMock {841 m.mainExpectation = nil842 m.expectationSeries = nil843 m.mock.GetRootDomainReferenceFunc = f844 return m.mock845}846//GetRootDomainReference implements github.com/insolar/insolar/insolar.Certificate interface847func (m *CertificateMock) GetRootDomainReference() (r *insolar.Reference) {848 counter := atomic.AddUint64(&m.GetRootDomainReferencePreCounter, 1)849 defer atomic.AddUint64(&m.GetRootDomainReferenceCounter, 1)850 if len(m.GetRootDomainReferenceMock.expectationSeries) > 0 {851 if counter > uint64(len(m.GetRootDomainReferenceMock.expectationSeries)) {852 m.t.Fatalf("Unexpected call to CertificateMock.GetRootDomainReference.")853 return854 }855 result := m.GetRootDomainReferenceMock.expectationSeries[counter-1].result856 if result == nil {857 m.t.Fatal("No results are set for the CertificateMock.GetRootDomainReference")858 return859 }860 r = result.r861 return862 }863 if m.GetRootDomainReferenceMock.mainExpectation != nil {864 result := m.GetRootDomainReferenceMock.mainExpectation.result865 if result == nil {866 m.t.Fatal("No results are set for the CertificateMock.GetRootDomainReference")867 }868 r = result.r869 return870 }871 if m.GetRootDomainReferenceFunc == nil {872 m.t.Fatalf("Unexpected call to CertificateMock.GetRootDomainReference.")873 return874 }875 return m.GetRootDomainReferenceFunc()876}877//GetRootDomainReferenceMinimockCounter returns a count of CertificateMock.GetRootDomainReferenceFunc invocations878func (m *CertificateMock) GetRootDomainReferenceMinimockCounter() uint64 {879 return atomic.LoadUint64(&m.GetRootDomainReferenceCounter)880}881//GetRootDomainReferenceMinimockPreCounter returns the value of CertificateMock.GetRootDomainReference invocations882func (m *CertificateMock) GetRootDomainReferenceMinimockPreCounter() uint64 {883 return atomic.LoadUint64(&m.GetRootDomainReferencePreCounter)884}885//GetRootDomainReferenceFinished returns true if mock invocations count is ok886func (m *CertificateMock) GetRootDomainReferenceFinished() bool {887 // if expectation series were set then invocations count should be equal to expectations count888 if len(m.GetRootDomainReferenceMock.expectationSeries) > 0 {889 return atomic.LoadUint64(&m.GetRootDomainReferenceCounter) == uint64(len(m.GetRootDomainReferenceMock.expectationSeries))890 }891 // if main expectation was set then invocations count should be greater than zero892 if m.GetRootDomainReferenceMock.mainExpectation != nil {893 return atomic.LoadUint64(&m.GetRootDomainReferenceCounter) > 0894 }895 // if func was set then invocations count should be greater than zero896 if m.GetRootDomainReferenceFunc != nil {897 return atomic.LoadUint64(&m.GetRootDomainReferenceCounter) > 0898 }899 return true900}901type mCertificateMockSerializeNodePart struct {902 mock *CertificateMock903 mainExpectation *CertificateMockSerializeNodePartExpectation904 expectationSeries []*CertificateMockSerializeNodePartExpectation905}906type CertificateMockSerializeNodePartExpectation struct {907 result *CertificateMockSerializeNodePartResult908}909type CertificateMockSerializeNodePartResult struct {910 r []byte911}912//Expect specifies that invocation of Certificate.SerializeNodePart is expected from 1 to Infinity times913func (m *mCertificateMockSerializeNodePart) Expect() *mCertificateMockSerializeNodePart {914 m.mock.SerializeNodePartFunc = nil915 m.expectationSeries = nil916 if m.mainExpectation == nil {917 m.mainExpectation = &CertificateMockSerializeNodePartExpectation{}918 }919 return m920}921//Return specifies results of invocation of Certificate.SerializeNodePart922func (m *mCertificateMockSerializeNodePart) Return(r []byte) *CertificateMock {923 m.mock.SerializeNodePartFunc = nil924 m.expectationSeries = nil925 if m.mainExpectation == nil {926 m.mainExpectation = &CertificateMockSerializeNodePartExpectation{}927 }928 m.mainExpectation.result = &CertificateMockSerializeNodePartResult{r}929 return m.mock930}931//ExpectOnce specifies that invocation of Certificate.SerializeNodePart is expected once932func (m *mCertificateMockSerializeNodePart) ExpectOnce() *CertificateMockSerializeNodePartExpectation {933 m.mock.SerializeNodePartFunc = nil934 m.mainExpectation = nil935 expectation := &CertificateMockSerializeNodePartExpectation{}936 m.expectationSeries = append(m.expectationSeries, expectation)937 return expectation938}939func (e *CertificateMockSerializeNodePartExpectation) Return(r []byte) {940 e.result = &CertificateMockSerializeNodePartResult{r}941}942//Set uses given function f as a mock of Certificate.SerializeNodePart method943func (m *mCertificateMockSerializeNodePart) Set(f func() (r []byte)) *CertificateMock {944 m.mainExpectation = nil945 m.expectationSeries = nil946 m.mock.SerializeNodePartFunc = f947 return m.mock948}949//SerializeNodePart implements github.com/insolar/insolar/insolar.Certificate interface950func (m *CertificateMock) SerializeNodePart() (r []byte) {951 counter := atomic.AddUint64(&m.SerializeNodePartPreCounter, 1)952 defer atomic.AddUint64(&m.SerializeNodePartCounter, 1)953 if len(m.SerializeNodePartMock.expectationSeries) > 0 {954 if counter > uint64(len(m.SerializeNodePartMock.expectationSeries)) {955 m.t.Fatalf("Unexpected call to CertificateMock.SerializeNodePart.")956 return957 }958 result := m.SerializeNodePartMock.expectationSeries[counter-1].result959 if result == nil {960 m.t.Fatal("No results are set for the CertificateMock.SerializeNodePart")961 return962 }963 r = result.r964 return965 }966 if m.SerializeNodePartMock.mainExpectation != nil {967 result := m.SerializeNodePartMock.mainExpectation.result968 if result == nil {969 m.t.Fatal("No results are set for the CertificateMock.SerializeNodePart")970 }971 r = result.r972 return973 }974 if m.SerializeNodePartFunc == nil {975 m.t.Fatalf("Unexpected call to CertificateMock.SerializeNodePart.")976 return977 }978 return m.SerializeNodePartFunc()979}980//SerializeNodePartMinimockCounter returns a count of CertificateMock.SerializeNodePartFunc invocations981func (m *CertificateMock) SerializeNodePartMinimockCounter() uint64 {982 return atomic.LoadUint64(&m.SerializeNodePartCounter)983}984//SerializeNodePartMinimockPreCounter returns the value of CertificateMock.SerializeNodePart invocations985func (m *CertificateMock) SerializeNodePartMinimockPreCounter() uint64 {986 return atomic.LoadUint64(&m.SerializeNodePartPreCounter)987}988//SerializeNodePartFinished returns true if mock invocations count is ok989func (m *CertificateMock) SerializeNodePartFinished() bool {990 // if expectation series were set then invocations count should be equal to expectations count991 if len(m.SerializeNodePartMock.expectationSeries) > 0 {992 return atomic.LoadUint64(&m.SerializeNodePartCounter) == uint64(len(m.SerializeNodePartMock.expectationSeries))993 }994 // if main expectation was set then invocations count should be greater than zero995 if m.SerializeNodePartMock.mainExpectation != nil {996 return atomic.LoadUint64(&m.SerializeNodePartCounter) > 0997 }998 // if func was set then invocations count should be greater than zero999 if m.SerializeNodePartFunc != nil {1000 return atomic.LoadUint64(&m.SerializeNodePartCounter) > 01001 }1002 return true1003}1004//ValidateCallCounters checks that all mocked methods of the interface have been called at least once1005//Deprecated: please use MinimockFinish method or use Finish method of minimock.Controller1006func (m *CertificateMock) ValidateCallCounters() {1007 if !m.GetDiscoveryNodesFinished() {1008 m.t.Fatal("Expected call to CertificateMock.GetDiscoveryNodes")1009 }1010 if !m.GetDiscoverySignsFinished() {1011 m.t.Fatal("Expected call to CertificateMock.GetDiscoverySigns")1012 }1013 if !m.GetMajorityRuleFinished() {1014 m.t.Fatal("Expected call to CertificateMock.GetMajorityRule")1015 }1016 if !m.GetMinRolesFinished() {1017 m.t.Fatal("Expected call to CertificateMock.GetMinRoles")1018 }1019 if !m.GetNodeRefFinished() {1020 m.t.Fatal("Expected call to CertificateMock.GetNodeRef")1021 }1022 if !m.GetPublicKeyFinished() {1023 m.t.Fatal("Expected call to CertificateMock.GetPublicKey")1024 }1025 if !m.GetRoleFinished() {1026 m.t.Fatal("Expected call to CertificateMock.GetRole")1027 }1028 if !m.GetRootDomainReferenceFinished() {1029 m.t.Fatal("Expected call to CertificateMock.GetRootDomainReference")1030 }1031 if !m.SerializeNodePartFinished() {1032 m.t.Fatal("Expected call to CertificateMock.SerializeNodePart")1033 }1034}1035//CheckMocksCalled checks that all mocked methods of the interface have been called at least once1036//Deprecated: please use MinimockFinish method or use Finish method of minimock.Controller1037func (m *CertificateMock) CheckMocksCalled() {1038 m.Finish()1039}1040//Finish checks that all mocked methods of the interface have been called at least once1041//Deprecated: please use MinimockFinish or use Finish method of minimock.Controller1042func (m *CertificateMock) Finish() {1043 m.MinimockFinish()1044}1045//MinimockFinish checks that all mocked methods of the interface have been called at least once1046func (m *CertificateMock) MinimockFinish() {1047 if !m.GetDiscoveryNodesFinished() {1048 m.t.Fatal("Expected call to CertificateMock.GetDiscoveryNodes")1049 }1050 if !m.GetDiscoverySignsFinished() {1051 m.t.Fatal("Expected call to CertificateMock.GetDiscoverySigns")1052 }1053 if !m.GetMajorityRuleFinished() {1054 m.t.Fatal("Expected call to CertificateMock.GetMajorityRule")1055 }1056 if !m.GetMinRolesFinished() {1057 m.t.Fatal("Expected call to CertificateMock.GetMinRoles")1058 }1059 if !m.GetNodeRefFinished() {1060 m.t.Fatal("Expected call to CertificateMock.GetNodeRef")1061 }1062 if !m.GetPublicKeyFinished() {1063 m.t.Fatal("Expected call to CertificateMock.GetPublicKey")1064 }1065 if !m.GetRoleFinished() {1066 m.t.Fatal("Expected call to CertificateMock.GetRole")1067 }1068 if !m.GetRootDomainReferenceFinished() {1069 m.t.Fatal("Expected call to CertificateMock.GetRootDomainReference")1070 }1071 if !m.SerializeNodePartFinished() {1072 m.t.Fatal("Expected call to CertificateMock.SerializeNodePart")1073 }1074}1075//Wait waits for all mocked methods to be called at least once1076//Deprecated: please use MinimockWait or use Wait method of minimock.Controller1077func (m *CertificateMock) Wait(timeout time.Duration) {1078 m.MinimockWait(timeout)1079}1080//MinimockWait waits for all mocked methods to be called at least once1081//this method is called by minimock.Controller1082func (m *CertificateMock) MinimockWait(timeout time.Duration) {1083 timeoutCh := time.After(timeout)1084 for {1085 ok := true1086 ok = ok && m.GetDiscoveryNodesFinished()1087 ok = ok && m.GetDiscoverySignsFinished()1088 ok = ok && m.GetMajorityRuleFinished()1089 ok = ok && m.GetMinRolesFinished()1090 ok = ok && m.GetNodeRefFinished()1091 ok = ok && m.GetPublicKeyFinished()1092 ok = ok && m.GetRoleFinished()1093 ok = ok && m.GetRootDomainReferenceFinished()1094 ok = ok && m.SerializeNodePartFinished()1095 if ok {1096 return1097 }1098 select {1099 case <-timeoutCh:1100 if !m.GetDiscoveryNodesFinished() {1101 m.t.Error("Expected call to CertificateMock.GetDiscoveryNodes")1102 }1103 if !m.GetDiscoverySignsFinished() {1104 m.t.Error("Expected call to CertificateMock.GetDiscoverySigns")1105 }1106 if !m.GetMajorityRuleFinished() {1107 m.t.Error("Expected call to CertificateMock.GetMajorityRule")1108 }1109 if !m.GetMinRolesFinished() {1110 m.t.Error("Expected call to CertificateMock.GetMinRoles")1111 }1112 if !m.GetNodeRefFinished() {1113 m.t.Error("Expected call to CertificateMock.GetNodeRef")1114 }1115 if !m.GetPublicKeyFinished() {1116 m.t.Error("Expected call to CertificateMock.GetPublicKey")1117 }1118 if !m.GetRoleFinished() {1119 m.t.Error("Expected call to CertificateMock.GetRole")1120 }1121 if !m.GetRootDomainReferenceFinished() {1122 m.t.Error("Expected call to CertificateMock.GetRootDomainReference")1123 }1124 if !m.SerializeNodePartFinished() {1125 m.t.Error("Expected call to CertificateMock.SerializeNodePart")1126 }1127 m.t.Fatalf("Some mocks were not called on time: %s", timeout)1128 return1129 default:1130 time.Sleep(time.Millisecond)1131 }1132 }1133}1134//AllMocksCalled returns true if all mocked methods were called before the execution of AllMocksCalled,1135//it can be used with assert/require, i.e. assert.True(mock.AllMocksCalled())1136func (m *CertificateMock) AllMocksCalled() bool {1137 if !m.GetDiscoveryNodesFinished() {1138 return false1139 }1140 if !m.GetDiscoverySignsFinished() {1141 return false1142 }1143 if !m.GetMajorityRuleFinished() {1144 return false1145 }1146 if !m.GetMinRolesFinished() {1147 return false1148 }1149 if !m.GetNodeRefFinished() {1150 return false1151 }1152 if !m.GetPublicKeyFinished() {1153 return false1154 }1155 if !m.GetRoleFinished() {1156 return false1157 }1158 if !m.GetRootDomainReferenceFinished() {1159 return false1160 }1161 if !m.SerializeNodePartFinished() {1162 return false1163 }1164 return true1165}...

Full Screen

Full Screen

payloadrechargetosidechain.go

Source:payloadrechargetosidechain.go Github

copy

Full Screen

...25func (t *PayloadRechargeToSideChain) Serialize(w io.Writer, version byte) error {26 if version == RechargeToSideChainPayloadVersion0 {27 err := common.WriteVarBytes(w, t.MerkleProof)28 if err != nil {29 return errors.New("[PayloadRechargeToSideChain], MerkleProof serialize failed.")30 }31 err = common.WriteVarBytes(w, t.MainChainTransaction)32 if err != nil {33 return errors.New("[PayloadRechargeToSideChain], DepositTransaction serialize failed.")34 }35 } else if version == RechargeToSideChainPayloadVersion1 {36 err := t.MainChainTransactionHash.Serialize(w)37 if err != nil {38 return errors.New("[PayloadRechargeToSideChain], MainChainTransactionHash serialize failed.")39 }40 } else {41 return errors.New("[PayloadRechargeToSideChain] serialize: invalid payload version.")42 }43 return nil44}45func (t *PayloadRechargeToSideChain) Deserialize(r io.Reader, version byte) error {46 if version == RechargeToSideChainPayloadVersion0 {47 var err error48 if t.MerkleProof, err = common.ReadVarBytes(r, MaxPayloadDataSize,49 "PayloadRechargeToSideChain MerkleProof"); err != nil {50 return errors.New("[PayloadRechargeToSideChain], MerkleProof deserialize failed.")51 }52 if t.MainChainTransaction, err = common.ReadVarBytes(r, MaxPayloadDataSize,53 "PayloadRechargeToSideChain MainChainTransaction"); err != nil {54 return errors.New("[PayloadRechargeToSideChain], DepositTransaction deserialize failed.")55 }56 } else if version == RechargeToSideChainPayloadVersion1 {57 if err := t.MainChainTransactionHash.Deserialize(r); err != nil {58 return errors.New("[PayloadRechargeToSideChain], MainChainTransactionHash deserialize failed.")59 }60 } else {61 return errors.New("[PayloadRechargeToSideChain] deserialize: invalid payload version.")62 }63 return nil64}65func (t *PayloadRechargeToSideChain) GetMainchainTxHash(payloadVersion byte) (*common.Uint256, error) {66 if payloadVersion == RechargeToSideChainPayloadVersion0 {67 mainchainTx := new(types.Transaction)68 reader := bytes.NewReader(t.MainChainTransaction)69 if err := mainchainTx.Deserialize(reader); err != nil {70 return nil, errors.New("[GetMainchainTxHash] RechargeToSideChain mainChainTransaction deserialize failed")71 }72 hash := mainchainTx.Hash()73 return &hash, nil74 } else if payloadVersion == RechargeToSideChainPayloadVersion1 {75 return &t.MainChainTransactionHash, nil76 } else {77 return nil, errors.New("[GetMainchainTxHash] Invalid payload version")78 }79}...

Full Screen

Full Screen

serialize

Using AI Code Generation

copy

Full Screen

1import (2type Person struct {3}4func main() {5 p1 := Person{"James", 20}6 bs, _ := json.Marshal(p1)7 fmt.Println(string(bs))8}9{"Name":"James","Age":20}10import (11type Person struct {12}13func main() {14 p1 := Person{"James", 20}15 bs, _ := json.MarshalIndent(p1, "", " ")16 fmt.Println(string(bs))17}18{19}20import (21type Person struct {22}23func main() {24 jsonString := `{"Name":"James","Age":20}`25 json.Unmarshal([]byte(jsonString), &p1)26 fmt.Println(p1.Name)27 fmt.Println(p1.Age)28}29import (30type Person struct {31}32func main() {33 jsonString := `{34 }`35 json.Unmarshal([]byte(jsonString), &p

Full Screen

Full Screen

serialize

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 file, err := os.Create("test.txt")4 if err != nil {5 fmt.Println(err)6 }7 defer file.Close()8 writer := bufio.NewWriter(file)9 writer.WriteString("Hello World!")10 writer.Flush()11}12import (13func main() {14 file, err := os.Create("test.txt")15 if err != nil {16 fmt.Println(err)17 }18 defer file.Close()19 writer := bufio.NewWriter(file)20 writer.WriteString("Hello World!")21 writer.Flush()22}23import (24func main() {25 file, err := os.Open("test.txt")26 if err != nil {27 fmt.Println(err)28 }29 defer file.Close()30 reader := bufio.NewReader(file)31 bytes, err := reader.Peek(5)32 if err != nil {33 fmt.Println(err)34 }35 fmt.Println(string(bytes))36}37import (38func main() {39 file, err := os.Open("test.txt")40 if err != nil {41 fmt.Println(err)42 }43 defer file.Close()44 reader := bufio.NewReader(file)

Full Screen

Full Screen

serialize

Using AI Code Generation

copy

Full Screen

1import (2type Person struct {3}4func main() {5 p := Person{"John", "Smith", 30}6 b, _ := json.Marshal(p)7 fmt.Println(string(b))8}9{"FirstName":"John","LastName":"Smith","Age":30}10import (11type Person struct {12}13func main() {14 json.Unmarshal([]byte(`{"FirstName":"John","LastName":"Smith","Age":30}`), &p)15 fmt.Println(p)16}17{John Smith 30}18import (19type Person struct {20}21func main() {22 p := Person{"John", "Smith", 30}23 b, _ := json.MarshalIndent(p, "", " ")24 fmt.Println(string(b))25}26{27}28import (29type Person struct {30}31func main() {32 json.Unmarshal([]byte(`{"FirstName":"John","LastName":"Smith","Age":30}`), &p)33 fmt.Println(p.FirstName)34 fmt.Println(p.LastName)35 fmt.Println(p.Age)36}

Full Screen

Full Screen

serialize

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 a.serialize()4}5import (6func main() {7 a.deserialize()8}9import (10func main() {11 a.serialize()12}13import (14func main() {15 a.deserialize()16}17import (18func main() {19 a.serialize()20}21import (22func main() {23 a.deserialize()24}25import (26func main() {27 a.serialize()28}29import (30func main() {31 a.deserialize()32}33import (34func main() {

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful