improved send coins test
This commit is contained in:
parent
8cd9e05fc2
commit
5cc0acf274
|
@ -221,8 +221,11 @@ func TestCoinSend(t *testing.T) {
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
r := initRouter(cdc)
|
r := initRouter(cdc)
|
||||||
|
|
||||||
addr := "some address in genesis"
|
// TODO make that account has coins
|
||||||
seed := "some seed of a address in genesis"
|
kb := client.MockKeyBase()
|
||||||
|
info, seed, err := kb.Create("account_with_coins", "1234567890", cryptoKeys.CryptoAlgo("ed25519"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
addr := string(info.Address())
|
||||||
|
|
||||||
// query empty
|
// query empty
|
||||||
res := request(t, r, "GET", "/accounts/1234567890123456789012345678901234567890", nil)
|
res := request(t, r, "GET", "/accounts/1234567890123456789012345678901234567890", nil)
|
||||||
|
@ -241,26 +244,25 @@ func TestCoinSend(t *testing.T) {
|
||||||
]
|
]
|
||||||
}`, res.Body.String())
|
}`, res.Body.String())
|
||||||
|
|
||||||
// create account for default coins
|
// create account to send in keybase
|
||||||
var jsonStr = []byte(fmt.Sprintf(`{"name":"test", "password":"1234567890", "seed": "%s"}`, seed))
|
var jsonStr = []byte(fmt.Sprintf(`{"name":"test", "password":"1234567890", "seed": "%s"}`, seed))
|
||||||
res = request(t, r, "POST", "/keys", jsonStr)
|
res = request(t, r, "POST", "/keys", jsonStr)
|
||||||
require.Equal(t, http.StatusOK, res.Code, res.Body.String())
|
require.Equal(t, http.StatusOK, res.Code, res.Body.String())
|
||||||
|
|
||||||
// create random account
|
// create receive address
|
||||||
res = request(t, r, "GET", "/keys/seed", nil)
|
receiveInfo, _, err := kb.Create("receive_address", "1234567890", cryptoKeys.CryptoAlgo("ed25519"))
|
||||||
require.Equal(t, http.StatusOK, res.Code, res.Body.String())
|
require.NoError(t, err)
|
||||||
receiveSeed := res.Body.String()
|
receiveAddr := string(receiveInfo.Address())
|
||||||
|
|
||||||
jsonStr = []byte(fmt.Sprintf(`{"name":"receive", "password":"1234567890", "seed": "%s"}`, receiveSeed))
|
|
||||||
res = request(t, r, "POST", "/keys", jsonStr)
|
|
||||||
require.Equal(t, http.StatusOK, res.Code, res.Body.String())
|
|
||||||
receiveAddr := res.Body.String()
|
|
||||||
|
|
||||||
// send
|
// send
|
||||||
jsonStr = []byte(`{"name":"test", "password":"1234567890", "amount":[{
|
jsonStr = []byte(`{
|
||||||
"denom": "mycoin",
|
"name":"test",
|
||||||
"amount": 1
|
"password":"1234567890",
|
||||||
}]}`)
|
"amount":[{
|
||||||
|
"denom": "mycoin",
|
||||||
|
"amount": 1
|
||||||
|
}]
|
||||||
|
}`)
|
||||||
res = request(t, r, "POST", "/accounts/"+receiveAddr+"/send", jsonStr)
|
res = request(t, r, "POST", "/accounts/"+receiveAddr+"/send", jsonStr)
|
||||||
require.Equal(t, http.StatusOK, res.Code, res.Body.String())
|
require.Equal(t, http.StatusOK, res.Code, res.Body.String())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue