mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-21 12:07:43 +00:00
rpc: support stringified address in getnep5balances RPC
This commit is contained in:
parent
78900148ee
commit
59cd19f5d4
2 changed files with 18 additions and 10 deletions
|
@ -566,7 +566,7 @@ func (s *Server) getClaimable(ps request.Params) (interface{}, *response.Error)
|
|||
}
|
||||
|
||||
func (s *Server) getNEP5Balances(ps request.Params) (interface{}, *response.Error) {
|
||||
u, err := ps.ValueWithType(0, request.StringT).GetUint160FromHex()
|
||||
u, err := ps.Value(0).GetUint160FromAddressOrHex()
|
||||
if err != nil {
|
||||
return nil, response.ErrInvalidParams
|
||||
}
|
||||
|
|
|
@ -169,15 +169,13 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
name: "positive",
|
||||
params: `["a90f00d94349a320376b7cb86c884b53ad76aa2b"]`,
|
||||
result: func(e *executor) interface{} { return &result.NEP5Balances{} },
|
||||
check: func(t *testing.T, e *executor, acc interface{}) {
|
||||
res, ok := acc.(*result.NEP5Balances)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, "AKkkumHbBipZ46UMZJoFynJMXzSRnBvKcs", res.Address)
|
||||
require.Equal(t, 1, len(res.Balances))
|
||||
require.Equal(t, "8.77", res.Balances[0].Amount)
|
||||
require.Equal(t, testContractHash, res.Balances[0].Asset.StringLE())
|
||||
require.Equal(t, uint32(208), res.Balances[0].LastUpdated)
|
||||
},
|
||||
check: checkNep5Balances,
|
||||
},
|
||||
{
|
||||
name: "positive_address",
|
||||
params: `["AKkkumHbBipZ46UMZJoFynJMXzSRnBvKcs"]`,
|
||||
result: func(e *executor) interface{} { return &result.NEP5Balances{} },
|
||||
check: checkNep5Balances,
|
||||
},
|
||||
},
|
||||
"getnep5transfers": {
|
||||
|
@ -1158,3 +1156,13 @@ func doRPCCallOverHTTP(rpcCall string, url string, t *testing.T) []byte {
|
|||
assert.NoErrorf(t, err, "could not read response from the request: %s", rpcCall)
|
||||
return bytes.TrimSpace(body)
|
||||
}
|
||||
|
||||
func checkNep5Balances(t *testing.T, e *executor, acc interface{}) {
|
||||
res, ok := acc.(*result.NEP5Balances)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, "AKkkumHbBipZ46UMZJoFynJMXzSRnBvKcs", res.Address)
|
||||
require.Equal(t, 1, len(res.Balances))
|
||||
require.Equal(t, "8.77", res.Balances[0].Amount)
|
||||
require.Equal(t, testContractHash, res.Balances[0].Asset.StringLE())
|
||||
require.Equal(t, uint32(208), res.Balances[0].LastUpdated)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue