github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/swarm/api/config_test.go (about) 1 // This file is part of the go-sberex library. The go-sberex library is 2 // free software: you can redistribute it and/or modify it under the terms 3 // of the GNU Lesser General Public License as published by the Free 4 // Software Foundation, either version 3 of the License, or (at your option) 5 // any later version. 6 // 7 // The go-sberex library is distributed in the hope that it will be useful, 8 // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 // General Public License <http://www.gnu.org/licenses/> for more details. 11 12 package api 13 14 import ( 15 "reflect" 16 "testing" 17 18 "github.com/Sberex/go-sberex/common" 19 "github.com/Sberex/go-sberex/crypto" 20 ) 21 22 func TestConfig(t *testing.T) { 23 24 var hexprvkey = "65138b2aa745041b372153550584587da326ab440576b2a1191dd95cee30039c" 25 26 prvkey, err := crypto.HexToECDSA(hexprvkey) 27 if err != nil { 28 t.Fatalf("failed to load private key: %v", err) 29 } 30 31 one := NewDefaultConfig() 32 two := NewDefaultConfig() 33 34 if equal := reflect.DeepEqual(one, two); !equal { 35 t.Fatal("Two default configs are not equal") 36 } 37 38 one.Init(prvkey) 39 40 //the init function should set the following fields 41 if one.BzzKey == "" { 42 t.Fatal("Expected BzzKey to be set") 43 } 44 if one.PublicKey == "" { 45 t.Fatal("Expected PublicKey to be set") 46 } 47 48 //the Init function should append subdirs to the given path 49 if one.Swap.PayProfile.Beneficiary == (common.Address{}) { 50 t.Fatal("Failed to correctly initialize SwapParams") 51 } 52 53 if one.SyncParams.RequestDbPath == one.Path { 54 t.Fatal("Failed to correctly initialize SyncParams") 55 } 56 57 if one.HiveParams.KadDbPath == one.Path { 58 t.Fatal("Failed to correctly initialize HiveParams") 59 } 60 61 if one.StoreParams.ChunkDbPath == one.Path { 62 t.Fatal("Failed to correctly initialize StoreParams") 63 } 64 }