Update tests for getblock action

- replace `GetBlockResponse.Result` with `wrappers.Block`
- update `getblock` checker and add more assets
This commit is contained in:
Evgeniy Kulikov 2020-02-12 17:25:44 +03:00
parent 41ebf12eb3
commit 64e325d9af
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2
2 changed files with 14 additions and 28 deletions

View file

@ -88,32 +88,9 @@ type StringResultResponse struct {
// GetBlockResponse struct for testing.
type GetBlockResponse struct {
Jsonrpc string `json:"jsonrpc"`
Result struct {
Version int `json:"version"`
Previousblockhash string `json:"previousblockhash"`
Merkleroot string `json:"merkleroot"`
Time int `json:"time"`
Height int `json:"height"`
Nonce int `json:"nonce"`
NextConsensus string `json:"next_consensus"`
Script struct {
Invocation string `json:"invocation"`
Verification string `json:"verification"`
} `json:"script"`
Tx []struct {
Type string `json:"type"`
Version int `json:"version"`
Attributes interface{} `json:"attributes"`
Vin interface{} `json:"vin"`
Vout interface{} `json:"vout"`
Scripts interface{} `json:"scripts"`
} `json:"tx"`
Confirmations int `json:"confirmations"`
Nextblockhash string `json:"nextblockhash"`
Hash string `json:"hash"`
} `json:"result"`
ID int `json:"id"`
Jsonrpc string `json:"jsonrpc"`
Result wrappers.Block `json:"result"`
ID int `json:"id"`
}
// GetAssetResponse struct for testing.

View file

@ -12,6 +12,7 @@ import (
"testing"
"github.com/CityOfZion/neo-go/pkg/core"
"github.com/CityOfZion/neo-go/pkg/core/transaction"
"github.com/CityOfZion/neo-go/pkg/rpc/wrappers"
"github.com/CityOfZion/neo-go/pkg/util"
"github.com/stretchr/testify/assert"
@ -123,8 +124,16 @@ var rpcTestCases = map[string][]rpcTestCase{
block, err := e.chain.GetBlock(e.chain.GetHeaderHash(1))
require.NoErrorf(t, err, "could not get block")
expectedHash := "0x" + block.Hash().StringLE()
assert.Equal(t, expectedHash, res.Result.Hash)
assert.Equal(t, block.Hash(), res.Result.Hash)
for i := range res.Result.Tx {
tx := res.Result.Tx[i]
require.Equal(t, transaction.MinerType, tx.Type)
miner, ok := block.Transactions[i].Data.(*transaction.MinerTX)
require.True(t, ok)
require.Equal(t, miner.Nonce, tx.Nonce)
require.Equal(t, block.Transactions[i].Hash(), tx.TxID)
}
},
},
{