github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/swarm/api/config_test.go (about) 1 2 //<developer> 3 // <name>linapex 曹一峰</name> 4 // <email>linapex@163.com</email> 5 // <wx>superexc</wx> 6 // <qqgroup>128148617</qqgroup> 7 // <url>https://jsq.ink</url> 8 // <role>pku engineer</role> 9 // <date>2019-03-16 12:09:46</date> 10 //</624342668809342976> 11 12 // 13 // 14 // 15 // 16 // 17 // 18 // 19 // 20 // 21 // 22 // 23 // 24 // 25 // 26 // 27 28 package api 29 30 import ( 31 "reflect" 32 "testing" 33 34 "github.com/ethereum/go-ethereum/common" 35 "github.com/ethereum/go-ethereum/crypto" 36 ) 37 38 func TestConfig(t *testing.T) { 39 40 var hexprvkey = "65138b2aa745041b372153550584587da326ab440576b2a1191dd95cee30039c" 41 42 prvkey, err := crypto.HexToECDSA(hexprvkey) 43 if err != nil { 44 t.Fatalf("failed to load private key: %v", err) 45 } 46 47 one := NewConfig() 48 two := NewConfig() 49 50 one.LocalStoreParams = two.LocalStoreParams 51 if equal := reflect.DeepEqual(one, two); !equal { 52 t.Fatal("Two default configs are not equal") 53 } 54 55 one.Init(prvkey) 56 57 // 58 if one.BzzKey == "" { 59 t.Fatal("Expected BzzKey to be set") 60 } 61 if one.PublicKey == "" { 62 t.Fatal("Expected PublicKey to be set") 63 } 64 if one.Swap.PayProfile.Beneficiary == (common.Address{}) && one.SwapEnabled { 65 t.Fatal("Failed to correctly initialize SwapParams") 66 } 67 if one.ChunkDbPath == one.Path { 68 t.Fatal("Failed to correctly initialize StoreParams") 69 } 70 } 71