Skip to content

Commit

Permalink
Merge pull request #102 from kaleido-io/standard-receipt-format
Browse files Browse the repository at this point in the history
Update fabconnect to send receipts conforming to FireFly receipt stru…
  • Loading branch information
nguyer authored Jan 19, 2023
2 parents f799590 + f13a48a commit fc749c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
13 changes: 7 additions & 6 deletions internal/messages/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,15 @@ type LedgerQueryResult struct {
Result interface{} `json:"result"`
}

// TransactionReceipt is sent when a transaction has been successfully mined
// TransactionReceipt is sent when a transaction has been successfully mined. Must
// conform to the FireFly standard structure for a blockchain receipt (see BlockchainReceiptNotification{})
type TransactionReceipt struct {
ReplyCommon
BlockNumber uint64 `json:"blockNumber"`
SignerMSP string `json:"signerMSP"`
Signer string `json:"signer"`
TransactionID string `json:"transactionID"`
Status string `json:"status"`
BlockNumber uint64 `json:"blockNumber"`
SignerMSP string `json:"signerMSP"`
Signer string `json:"signer"`
TransactionHash string `json:"transactionHash"`
Status string `json:"status"`
}

type ErrorReply struct {
Expand Down
8 changes: 4 additions & 4 deletions internal/rest/receipt/receiptstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestReplyProcessorWithValidReply(t *testing.T) {
replyMsg.Headers.ID = utils.UUIDv4()
replyMsg.Headers.ReqID = utils.UUIDv4()
replyMsg.Headers.ReqOffset = "topic:1:2"
replyMsg.TransactionID = "9c842ffd430a56a5338f353a7b5b5052b4ac604564d82318af9329b4bf46dd89"
replyMsg.TransactionHash = "9c842ffd430a56a5338f353a7b5b5052b4ac604564d82318af9329b4bf46dd89"
replyMsgBytes, _ := json.Marshal(&replyMsg)

r.ProcessReceipt(replyMsgBytes)
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestReplyProcessorWithPeristenceErrorPanics(t *testing.T) {
replyMsg.Headers.ID = utils.UUIDv4()
replyMsg.Headers.ReqID = utils.UUIDv4()
replyMsg.Headers.ReqOffset = "topic:1:2"
replyMsg.TransactionID = "9c842ffd430a56a5338f353a7b5b5052b4ac604564d82318af9329b4bf46dd89"
replyMsg.TransactionHash = "9c842ffd430a56a5338f353a7b5b5052b4ac604564d82318af9329b4bf46dd89"
replyMsgBytes, _ := json.Marshal(&replyMsg)

assert.Panics(t, func() {
Expand All @@ -99,7 +99,7 @@ func TestReplyProcessorWithPeristenceErrorDuplicateSwallows(t *testing.T) {
replyMsg.Headers.ID = utils.UUIDv4()
replyMsg.Headers.ReqID = utils.UUIDv4()
replyMsg.Headers.ReqOffset = "topic:1:2"
replyMsg.TransactionID = "9c842ffd430a56a5338f353a7b5b5052b4ac604564d82318af9329b4bf46dd89"
replyMsg.TransactionHash = "9c842ffd430a56a5338f353a7b5b5052b4ac604564d82318af9329b4bf46dd89"
replyMsgBytes, _ := json.Marshal(&replyMsg)

r.ProcessReceipt(replyMsgBytes)
Expand Down Expand Up @@ -181,7 +181,7 @@ func TestSendReplyBroadcast(t *testing.T) {
replyMsg.Headers.ID = utils.UUIDv4()
replyMsg.Headers.ReqID = utils.UUIDv4()
replyMsg.Headers.ReqOffset = "topic:1:2"
replyMsg.TransactionID = "9c842ffd430a56a5338f353a7b5b5052b4ac604564d82318af9329b4bf46dd89"
replyMsg.TransactionHash = "9c842ffd430a56a5338f353a7b5b5052b4ac604564d82318af9329b4bf46dd89"
replyMsgBytes, _ := json.Marshal(&replyMsg)

r.ProcessReceipt(replyMsgBytes)
Expand Down
2 changes: 1 addition & 1 deletion internal/tx/txprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (p *txProcessor) waitForCompletion(inflight *inflightTx, initialWaitDelay t
reply.BlockNumber = receipt.BlockNumber
reply.Signer = receipt.Signer
reply.SignerMSP = receipt.SignerMSP
reply.TransactionID = receipt.TransactionID
reply.TransactionHash = receipt.TransactionID

inflight.txContext.Reply(&reply)
}
Expand Down

0 comments on commit fc749c3

Please sign in to comment.