|
@@ -139,7 +139,8 @@ func Test_TransferAccounts(t *testing.T) {
|
|
*/
|
|
*/
|
|
func Test_ChainHeight(t *testing.T) {
|
|
func Test_ChainHeight(t *testing.T) {
|
|
client := http.DefaultClient
|
|
client := http.DefaultClient
|
|
- geturl := fmt.Sprintf(`http://localhost:15741/coinproxy/blockchain/height`)
|
|
|
|
|
|
+ geturl := fmt.Sprintf(`http://118.31.213.53:6784/coinproxy/blockchain/height`)
|
|
|
|
+ //geturl := fmt.Sprintf(`http://localhost:15741/coinproxy/blockchain/height`)
|
|
timestamp := fmt.Sprintf("%v", time.Now().Unix())
|
|
timestamp := fmt.Sprintf("%v", time.Now().Unix())
|
|
t.Logf("post url:%v", geturl)
|
|
t.Logf("post url:%v", geturl)
|
|
|
|
|
|
@@ -168,12 +169,41 @@ func Test_ChainHeight(t *testing.T) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func Test_ListUnspent(t *testing.T) {
|
|
|
|
|
|
+func Test_AccountsBalance(t *testing.T) {
|
|
client := http.DefaultClient
|
|
client := http.DefaultClient
|
|
- geturl := fmt.Sprintf(`http://localhost:15741/coinproxy/listunspent`)
|
|
|
|
- timestamp := fmt.Sprintf("%v", time.Now().Unix())
|
|
|
|
|
|
+ geturl := fmt.Sprintf(`http://192.168.1.107:15741/coinproxy/accountsbalance`)
|
|
|
|
+ timetamp := fmt.Sprintf("%v", time.Now().Unix())
|
|
|
|
+
|
|
t.Logf("post url:%v", geturl)
|
|
t.Logf("post url:%v", geturl)
|
|
|
|
|
|
|
|
+ posdata := fmt.Sprintf(`{"cointype":"BTC","timestamp":"%v"}`, timetamp)
|
|
|
|
+ request, err := http.NewRequest("POST", geturl, strings.NewReader(posdata))
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Error("err:%s", err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ resp, err := client.Do(request)
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Errorf("err:%s", err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ defer resp.Body.Close()
|
|
|
|
+ rbs, err := ioutil.ReadAll(resp.Body)
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Errorf("err:%s", err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ t.Logf("read bytes:%v", string(rbs))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*func Test_ListUnspent(t *testing.T) {
|
|
|
|
+ client := http.DefaultClient
|
|
|
|
+ geturl := fmt.Sprintf(`http://118.31.212.137:6784/coinproxy/listunspent`)
|
|
|
|
+ //geturl := fmt.Sprintf(`http://192.168.1.107:15741/coinproxy/listunspent`)
|
|
|
|
+ timestamp := fmt.Sprintf("%v", time.Now().Unix())
|
|
|
|
+ t.Logf("post url:%v", geturl)
|
|
|
|
|
|
postdata := fmt.Sprintf(`{"cointype":"BTC","address":[],"timestamp":"%v","signature":"%v"}`, timestamp, Signature([]byte("/coinproxy/listunspent"), timestamp))
|
|
postdata := fmt.Sprintf(`{"cointype":"BTC","address":[],"timestamp":"%v","signature":"%v"}`, timestamp, Signature([]byte("/coinproxy/listunspent"), timestamp))
|
|
request, err := http.NewRequest("POST", geturl, strings.NewReader(postdata))
|
|
request, err := http.NewRequest("POST", geturl, strings.NewReader(postdata))
|
|
@@ -226,8 +256,8 @@ func Test_SendRawTransaction(t *testing.T) {
|
|
|
|
|
|
t.Logf("read bytes:%v", string(rbs))
|
|
t.Logf("read bytes:%v", string(rbs))
|
|
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
|
|
+ return
|
|
|
|
+}*/
|
|
|
|
|
|
|
|
|
|
func Signature(body []byte, timestamp string) string {
|
|
func Signature(body []byte, timestamp string) string {
|