diff --git a/pkg/rpc/server_helper_test.go b/pkg/rpc/server_helper_test.go index d2a25f792..369562930 100644 --- a/pkg/rpc/server_helper_test.go +++ b/pkg/rpc/server_helper_test.go @@ -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. diff --git a/pkg/rpc/server_test.go b/pkg/rpc/server_test.go index 00836bc64..dcf9bdc7b 100644 --- a/pkg/rpc/server_test.go +++ b/pkg/rpc/server_test.go @@ -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) + } }, }, {