forked from cerc-io/ipld-eth-server
Rename Cid to CID
This commit is contained in:
+33
-33
@@ -254,81 +254,81 @@ var _ = Describe("GraphQL", func() {
|
||||
|
||||
Describe("allEthHeaderCids", func() {
|
||||
It("Retrieves header_cids that matches the provided blockNumber", func() {
|
||||
allEthHeaderCidsResp, err := client.AllEthHeaderCids(ctx, graphql.EthHeaderCidCondition{BlockNumber: new(graphql.BigInt).SetUint64(2)})
|
||||
allEthHeaderCIDsResp, err := client.AllEthHeaderCIDs(ctx, graphql.EthHeaderCIDCondition{BlockNumber: new(graphql.BigInt).SetUint64(2)})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
headerCIDs, err := backend.Retriever.RetrieveHeaderAndTxCIDsByBlockNumber(2)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
for idx, headerCID := range headerCIDs {
|
||||
ethHeaderCid := allEthHeaderCidsResp.Nodes[idx]
|
||||
ethHeaderCID := allEthHeaderCIDsResp.Nodes[idx]
|
||||
|
||||
compareEthHeaderCid(ethHeaderCid, headerCID)
|
||||
compareEthHeaderCID(ethHeaderCID, headerCID)
|
||||
}
|
||||
})
|
||||
|
||||
It("Retrieves header_cids that matches the provided blockHash", func() {
|
||||
blockHash := blocks[1].Hash().String()
|
||||
allEthHeaderCidsResp, err := client.AllEthHeaderCids(ctx, graphql.EthHeaderCidCondition{BlockHash: &blockHash})
|
||||
allEthHeaderCIDsResp, err := client.AllEthHeaderCIDs(ctx, graphql.EthHeaderCIDCondition{BlockHash: &blockHash})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
headerCID, err := backend.Retriever.RetrieveHeaderAndTxCIDsByBlockHash(blocks[1].Hash())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
Expect(len(allEthHeaderCidsResp.Nodes)).To(Equal(1))
|
||||
ethHeaderCid := allEthHeaderCidsResp.Nodes[0]
|
||||
compareEthHeaderCid(ethHeaderCid, headerCID)
|
||||
Expect(len(allEthHeaderCIDsResp.Nodes)).To(Equal(1))
|
||||
ethHeaderCID := allEthHeaderCIDsResp.Nodes[0]
|
||||
compareEthHeaderCID(ethHeaderCID, headerCID)
|
||||
})
|
||||
})
|
||||
|
||||
Describe("ethTransactionCidByTxHash", func() {
|
||||
It("Retrieves tx_cid that matches the provided txHash", func() {
|
||||
txHash := blocks[2].Transactions()[0].Hash().String()
|
||||
ethTransactionCidResp, err := client.EthTransactionCidByTxHash(ctx, txHash)
|
||||
ethTransactionCIDResp, err := client.EthTransactionCIDByTxHash(ctx, txHash)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
txCID, err := backend.Retriever.RetrieveTxCIDByHash(txHash)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
compareEthTxCid(*ethTransactionCidResp, txCID)
|
||||
compareEthTxCID(*ethTransactionCIDResp, txCID)
|
||||
|
||||
Expect(ethTransactionCidResp.BlockByMhKey.Data).To(Equal(graphql.Bytes(txCID.IPLD.Data).String()))
|
||||
Expect(ethTransactionCIDResp.BlockByMhKey.Data).To(Equal(graphql.Bytes(txCID.IPLD.Data).String()))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
func compareEthHeaderCid(ethHeaderCid graphql.EthHeaderCidResponse, headerCID eth.HeaderCidRecord) {
|
||||
func compareEthHeaderCID(ethHeaderCID graphql.EthHeaderCIDResponse, headerCID eth.HeaderCIDRecord) {
|
||||
blockNumber, err := strconv.ParseInt(headerCID.BlockNumber, 10, 64)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
td, err := strconv.ParseInt(headerCID.TotalDifficulty, 10, 64)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
Expect(ethHeaderCid.Cid).To(Equal(headerCID.CID))
|
||||
Expect(ethHeaderCid.BlockNumber).To(Equal(*new(graphql.BigInt).SetUint64(uint64(blockNumber))))
|
||||
Expect(ethHeaderCid.BlockHash).To(Equal(headerCID.BlockHash))
|
||||
Expect(ethHeaderCid.ParentHash).To(Equal(headerCID.ParentHash))
|
||||
Expect(ethHeaderCid.Timestamp).To(Equal(*new(graphql.BigInt).SetUint64(headerCID.Timestamp)))
|
||||
Expect(ethHeaderCid.StateRoot).To(Equal(headerCID.StateRoot))
|
||||
Expect(ethHeaderCid.Td).To(Equal(*new(graphql.BigInt).SetUint64(uint64(td))))
|
||||
Expect(ethHeaderCid.TxRoot).To(Equal(headerCID.TxRoot))
|
||||
Expect(ethHeaderCid.ReceiptRoot).To(Equal(headerCID.RctRoot))
|
||||
Expect(ethHeaderCid.UncleRoot).To(Equal(headerCID.UncleRoot))
|
||||
Expect(ethHeaderCid.Bloom).To(Equal(graphql.Bytes(headerCID.Bloom).String()))
|
||||
Expect(ethHeaderCID.CID).To(Equal(headerCID.CID))
|
||||
Expect(ethHeaderCID.BlockNumber).To(Equal(*new(graphql.BigInt).SetUint64(uint64(blockNumber))))
|
||||
Expect(ethHeaderCID.BlockHash).To(Equal(headerCID.BlockHash))
|
||||
Expect(ethHeaderCID.ParentHash).To(Equal(headerCID.ParentHash))
|
||||
Expect(ethHeaderCID.Timestamp).To(Equal(*new(graphql.BigInt).SetUint64(headerCID.Timestamp)))
|
||||
Expect(ethHeaderCID.StateRoot).To(Equal(headerCID.StateRoot))
|
||||
Expect(ethHeaderCID.Td).To(Equal(*new(graphql.BigInt).SetUint64(uint64(td))))
|
||||
Expect(ethHeaderCID.TxRoot).To(Equal(headerCID.TxRoot))
|
||||
Expect(ethHeaderCID.ReceiptRoot).To(Equal(headerCID.RctRoot))
|
||||
Expect(ethHeaderCID.UncleRoot).To(Equal(headerCID.UncleRoot))
|
||||
Expect(ethHeaderCID.Bloom).To(Equal(graphql.Bytes(headerCID.Bloom).String()))
|
||||
|
||||
for tIdx, txCID := range headerCID.TransactionCids {
|
||||
ethTxCid := ethHeaderCid.EthTransactionCidsByHeaderId.Nodes[tIdx]
|
||||
compareEthTxCid(ethTxCid, txCID)
|
||||
for tIdx, txCID := range headerCID.TransactionCIDs {
|
||||
ethTxCID := ethHeaderCID.EthTransactionCIDsByHeaderId.Nodes[tIdx]
|
||||
compareEthTxCID(ethTxCID, txCID)
|
||||
}
|
||||
|
||||
Expect(ethHeaderCid.BlockByMhKey.Data).To(Equal(graphql.Bytes(headerCID.IPLD.Data).String()))
|
||||
Expect(ethHeaderCid.BlockByMhKey.Key).To(Equal(headerCID.IPLD.Key))
|
||||
Expect(ethHeaderCID.BlockByMhKey.Data).To(Equal(graphql.Bytes(headerCID.IPLD.Data).String()))
|
||||
Expect(ethHeaderCID.BlockByMhKey.Key).To(Equal(headerCID.IPLD.Key))
|
||||
}
|
||||
|
||||
func compareEthTxCid(ethTxCid graphql.EthTransactionCidResponse, txCID eth.TransactionCidRecord) {
|
||||
Expect(ethTxCid.Cid).To(Equal(txCID.CID))
|
||||
Expect(ethTxCid.TxHash).To(Equal(txCID.TxHash))
|
||||
Expect(ethTxCid.Index).To(Equal(int32(txCID.Index)))
|
||||
Expect(ethTxCid.Src).To(Equal(txCID.Src))
|
||||
Expect(ethTxCid.Dst).To(Equal(txCID.Dst))
|
||||
func compareEthTxCID(ethTxCID graphql.EthTransactionCIDResponse, txCID eth.TransactionCIDRecord) {
|
||||
Expect(ethTxCID.CID).To(Equal(txCID.CID))
|
||||
Expect(ethTxCID.TxHash).To(Equal(txCID.TxHash))
|
||||
Expect(ethTxCID.Index).To(Equal(int32(txCID.Index)))
|
||||
Expect(ethTxCID.Src).To(Equal(txCID.Src))
|
||||
Expect(ethTxCID.Dst).To(Equal(txCID.Dst))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user