@@ -213,6 +213,35 @@ var _ = Describe("Types JSON Marshaling and Unmarshaling", func() {
213213 []byte (`{"blockHash":"0x1234567", "blockNumber":"", "to":"", "input":"","transactionIndex":"", "hash":"", "gasPrice":"0x0", "value":"0x0"}` )),
214214 )
215215
216+ DescribeTable ("TxReceipt MarshalJSON" ,
217+ func (txReceipt TxReceipt , bytes []byte ) {
218+ marshalledData , err := txReceipt .MarshalJSON ()
219+ Expect (err ).ToNot (HaveOccurred ())
220+
221+ var target TxReceipt
222+ err = json .Unmarshal (marshalledData , & target )
223+ Expect (err ).ToNot (HaveOccurred ())
224+
225+ var expectedReceipt TxReceipt
226+ err = json .Unmarshal (bytes , & expectedReceipt )
227+ Expect (err ).ToNot (HaveOccurred ())
228+
229+ Expect (target ).To (Equal (expectedReceipt ))
230+ },
231+
232+ Entry ("empty receipt object" ,
233+ TxReceipt {},
234+ []byte (`{"transactionHash":"","transactionIndex":"","blockHash":"","blockNumber":"","gasUsed":0,"cumulativeGasUsed":0,"to":"","logs":[],"status":"","from":""}` )),
235+
236+ Entry ("non-empty receipt object" ,
237+ TxReceipt {Status : "0x1" , TransactionHash : "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b" , CumulativeGasUsed : 314159 , GasUsed : 30234 },
238+ []byte (`{"transactionHash":"0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b","transactionIndex":"","blockHash":"","blockNumber":"","gasUsed":30234,"cumulativeGasUsed":314159,"to":"","logs":[],"status":"0x1","from":""}` )),
239+
240+ Entry ("non-empty logs field" ,
241+ TxReceipt {Logs : make ([]Log , 1 ), Status : "0x1" , TransactionHash : "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b" , CumulativeGasUsed : 314159 , GasUsed : 30234 },
242+ []byte (`{"transactionHash":"0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b","transactionIndex":"","blockHash":"","blockNumber":"","gasUsed":30234,"cumulativeGasUsed":314159,"to":"","contractAddress":"","gasUsed":30234,"cumulativeGasUsed":314159,"to":"","logs":[{"address":"","topics":null,"blockNumber":"","transactionHash":"","transactionIndex":"","blockHash":"","logIndex":""}],"status":"0x1","from":""}` )),
243+ )
244+
216245 DescribeTable ("Block MarshalJSON" ,
217246 func (blk Block , bytes []byte ) {
218247 By ("copying the original struct" )
0 commit comments