github.com/yinchengtsinghua/golang-Eos-dpos-Ethereum@v0.0.0-20190121132951-92cc4225ed8e/swarm/api/config_test.go (about) 1 2 //此源码被清华学神尹成大魔王专业翻译分析并修改 3 //尹成QQ77025077 4 //尹成微信18510341407 5 //尹成所在QQ群721929980 6 //尹成邮箱 yinc13@mails.tsinghua.edu.cn 7 //尹成毕业于清华大学,微软区块链领域全球最有价值专家 8 //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 9 // 10 // 11 // 12 // 13 // 14 // 15 // 16 // 17 // 18 // 19 // 20 // 21 // 22 // 23 // 24 25 package api 26 27 import ( 28 "reflect" 29 "testing" 30 31 "github.com/ethereum/go-ethereum/common" 32 "github.com/ethereum/go-ethereum/crypto" 33 ) 34 35 func TestConfig(t *testing.T) { 36 37 var hexprvkey = "65138b2aa745041b372153550584587da326ab440576b2a1191dd95cee30039c" 38 39 prvkey, err := crypto.HexToECDSA(hexprvkey) 40 if err != nil { 41 t.Fatalf("failed to load private key: %v", err) 42 } 43 44 one := NewConfig() 45 two := NewConfig() 46 47 one.LocalStoreParams = two.LocalStoreParams 48 if equal := reflect.DeepEqual(one, two); !equal { 49 t.Fatal("Two default configs are not equal") 50 } 51 52 one.Init(prvkey) 53 54 // 55 if one.BzzKey == "" { 56 t.Fatal("Expected BzzKey to be set") 57 } 58 if one.PublicKey == "" { 59 t.Fatal("Expected PublicKey to be set") 60 } 61 if one.Swap.PayProfile.Beneficiary == (common.Address{}) && one.SwapEnabled { 62 t.Fatal("Failed to correctly initialize SwapParams") 63 } 64 if one.ChunkDbPath == one.Path { 65 t.Fatal("Failed to correctly initialize StoreParams") 66 } 67 }