rpc: adjust submitblock RPC-call

It should return block hash instead of boolean.
This commit is contained in:
Anna Shaleva 2020-07-21 10:41:18 +03:00
parent c2534b1a0b
commit 889a5d7eb6
4 changed files with 22 additions and 20 deletions

View file

@ -716,16 +716,19 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
{
name: "positive",
invoke: func(c *Client) (interface{}, error) {
return nil, c.SubmitBlock(block.Block{
return c.SubmitBlock(block.Block{
Base: block.Base{},
Transactions: nil,
Trimmed: false,
})
},
serverResponse: `{"jsonrpc":"2.0","id":1,"result":true}`,
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"hash":"0x1bdea8f80eb5bd97fade38d5e7fb93b02c9d3e01394e9f4324218132293f7ea6"}}`,
result: func(c *Client) interface{} {
// no error expected
return nil
h, err := util.Uint256DecodeStringLE("1bdea8f80eb5bd97fade38d5e7fb93b02c9d3e01394e9f4324218132293f7ea6")
if err != nil {
panic(fmt.Errorf("can't decode `submitblock` result hash: %v", err))
}
return h
},
},
},
@ -840,7 +843,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
{
name: "submitblock_bad_server_answer",
invoke: func(c *Client) (interface{}, error) {
return nil, c.SubmitBlock(block.Block{
return c.SubmitBlock(block.Block{
Base: block.Base{},
Transactions: nil,
Trimmed: false,
@ -996,7 +999,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
{
name: "submitblock_invalid_params_error",
invoke: func(c *Client) (interface{}, error) {
return nil, c.SubmitBlock(block.Block{})
return c.SubmitBlock(block.Block{})
},
},
{
@ -1178,7 +1181,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
{
name: "submitblock_unmarshalling_error",
invoke: func(c *Client) (interface{}, error) {
return nil, c.SubmitBlock(block.Block{
return c.SubmitBlock(block.Block{
Base: block.Base{},
Transactions: nil,
Trimmed: false,