6 cfg "github.com/vapor/config"
7 "github.com/vapor/crypto/ed25519/chainkd"
8 "github.com/vapor/util"
12 func mockConfig() *cfg.Config {
13 var config = cfg.DefaultConfig()
14 config.Wallet.Disable = false
16 config.ApiAddress = "127.0.0.1:9889"
20 // Test net-info call api.
22 data, exitCode := util.ClientCall("/net-info")
23 if exitCode != util.Success {
26 dataMap, ok := data.(map[string]interface{})
27 if ok && dataMap["listening"].(bool) && dataMap["syncing"].(bool) && dataMap["mining"].(bool) {
33 // Test create-key delete-key list-key api and function.
36 Alias string `json:"alias"`
37 Password string `json:"password"`
38 }{Alias: "alice", Password: "123456"}
40 data, exitCode := util.ClientCall("/create-key", &key)
41 if exitCode != util.Success {
44 dataMap, ok := data.(map[string]interface{})
45 if (ok && dataMap["alias"].(string) == "alice") == false {
49 _, exitCode1 := util.ClientCall("/list-keys")
50 if exitCode1 != util.Success {
54 fmt.Println("dataMap", dataMap)
55 xpub := new(chainkd.XPub)
56 if err := xpub.UnmarshalText([]byte(dataMap["xpub"].(string))); err != nil {
62 XPub chainkd.XPub `json:"xpubs"`
63 }{XPub: *xpub, Password: "123456"}
65 if _, exitCode := util.ClientCall("/delete-key", &key1); exitCode != util.Success {
73 /*func TestRunNode(t *testing.T) {
74 // Create & start node
75 config := mockConfig()
76 n := node.NewNodeDefault(config)
77 if _, err := n.Start(); err != nil {
78 t.Fatalf("Failed to start node: %v", err)
82 time.Sleep(3000 * time.Millisecond)
83 if testNet() && testKey() {
84 os.RemoveAll("./data")
85 os.RemoveAll("./keystore")
88 os.RemoveAll("./data")
89 os.RemoveAll("./keystore")
93 // Trap signal, run forever.