Add RPC Server method ValidateAddress (#134)
* Add RPC Server method ValidateAddress - implement rpc method validateaddress (https://docs.neo.org/en-us/node/cli/2.9.4/api/validateaddress.html) - add tests - add to README.md * revert go.sum * remove break * more tests and C# errors * simplify * fix after master merge
This commit is contained in:
parent
763452fe33
commit
001a0e601e
4 changed files with 64 additions and 9 deletions
|
@ -56,7 +56,7 @@ func TestHandler(t *testing.T) {
|
|||
|
||||
{`{"jsonrpc": "2.0", "id": 1, "method": "getassetstate", "params": [123] }`,
|
||||
"getassetstate_4",
|
||||
`{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Params","data":"expected param at index 0 to be a valid string assetID parameter"},"id":1}`},
|
||||
`{"jsonrpc":"2.0","error":{"code":-2146233033,"message":"One of the identified items was in an invalid format."},"id":1}`},
|
||||
|
||||
{`{"jsonrpc": "2.0", "id": 1, "method": "getblockhash", "params": [10] }`,
|
||||
"getblockhash_1",
|
||||
|
@ -117,6 +117,34 @@ func TestHandler(t *testing.T) {
|
|||
method: "getaccountstate_4",
|
||||
expectedResult: `{"jsonrpc":"2.0","error":{"code":-2146233086,"message":"Index was out of range. Must be non-negative and less than the size of the collection.\nParameter name: index"},"id":1}`,
|
||||
},
|
||||
|
||||
// Good case, valid address
|
||||
{
|
||||
rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "validateaddress", "params": ["AQVh2pG732YvtNaxEGkQUei3YA4cvo7d2i"] }`,
|
||||
method: "validateaddress_1",
|
||||
expectedResult: `{"jsonrpc":"2.0","result":{"address":"AQVh2pG732YvtNaxEGkQUei3YA4cvo7d2i","isvalid":true},"id":1}`,
|
||||
},
|
||||
|
||||
// Bad case, invalid address
|
||||
{
|
||||
rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "validateaddress", "params": ["152f1muMCNa7goXYhYAQC61hxEgGacmncB"] }`,
|
||||
method: "validateaddress_2",
|
||||
expectedResult: `{"jsonrpc":"2.0","result":{"address":"152f1muMCNa7goXYhYAQC61hxEgGacmncB","isvalid":false},"id":1}`,
|
||||
},
|
||||
|
||||
// Bad case, not string
|
||||
{
|
||||
rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "validateaddress", "params": [1] }`,
|
||||
method: "validateaddress_3",
|
||||
expectedResult: `{"jsonrpc":"2.0","result":{"address":1,"isvalid":false},"id":1}`,
|
||||
},
|
||||
|
||||
// Bad case, empty params
|
||||
{
|
||||
rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "validateaddress", "params": [] }`,
|
||||
method: "validateaddress_4",
|
||||
expectedResult: `{"jsonrpc":"2.0","error":{"code":-2146233086,"message":"Index was out of range. Must be non-negative and less than the size of the collection.\nParameter name: index"},"id":1}`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue