forked from TrueCloudLab/neoneo-go
Update tests for getblock
action
- replace `GetBlockResponse.Result` with `wrappers.Block` - update `getblock` checker and add more assets
This commit is contained in:
parent
41ebf12eb3
commit
64e325d9af
2 changed files with 14 additions and 28 deletions
|
@ -89,30 +89,7 @@ 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"`
|
||||
Result wrappers.Block `json:"result"`
|
||||
ID int `json:"id"`
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue