github.com/braveheart12/insolar-09-08-19@v0.8.7/testutils/nodekeeper/nodekeeper.go (about) 1 /* 2 * Copyright 2019 Insolar Technologies 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package nodekeeper 18 19 import ( 20 "github.com/insolar/insolar/core" 21 "github.com/insolar/insolar/network" 22 "github.com/insolar/insolar/network/nodenetwork" 23 ) 24 25 func GetTestNodekeeper(cs core.CryptographyService) network.NodeKeeper { 26 pk, err := cs.GetPublicKey() 27 if err != nil { 28 panic(err) 29 } 30 31 ref, err := core.NewRefFromBase58("4K3NiGuqYGqKPnYp6XeGd2kdN4P9veL6rYcWkLKWXZCu.7ZQboaH24PH42sqZKUvoa7UBrpuuubRtShp6CKNuWGZa") 32 if err != nil { 33 panic(err) 34 } 35 36 keeper := nodenetwork.NewNodeKeeper( 37 nodenetwork.NewNode( 38 *ref, 39 core.StaticRoleVirtual, 40 pk, 41 // TODO implement later 42 "127.0.0.1:5432", 43 "", 44 )) 45 46 // dirty hack - we need 3 nodes as validators, pass one node 3 times 47 getValidator := func() core.Node { 48 return nodenetwork.NewNode( 49 *ref, 50 core.StaticRoleVirtual, 51 pk, 52 // TODO implement later 53 "127.0.0.1:5432", 54 "", 55 ) 56 } 57 nodes := []core.Node{getValidator(), getValidator(), getValidator()} 58 keeper.AddActiveNodes(nodes) 59 60 return keeper 61 }