config_test.go 2.0 KB

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