-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make Transaction Receipt and Record consistent with other SDKs (#…
…1187) * fix: make receipt and record consistent with other SDKs Signed-off-by: Ivan Ivanov <[email protected]> * chore: fix PR feedback Signed-off-by: Ivan Ivanov <[email protected]> --------- Signed-off-by: Ivan Ivanov <[email protected]>
- Loading branch information
Showing
6 changed files
with
216 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,6 +287,13 @@ func TestUnitTransactionReceiptToJson(t *testing.T) { | |
Seconds: 1694689200, | ||
}, | ||
}, | ||
NextRate: &services.ExchangeRate{ | ||
HbarEquiv: 50000, | ||
CentEquiv: 154271, | ||
ExpirationTime: &services.TimestampSeconds{ | ||
Seconds: 1694689200, | ||
}, | ||
}, | ||
}, | ||
}, | ||
ChildTransactionReceipts: []*services.TransactionReceipt{ | ||
|
@@ -349,8 +356,8 @@ func TestUnitTransactionReceiptToJson(t *testing.T) { | |
TopicSequenceNumber: 10, | ||
TopicRunningHash: []byte{10}, | ||
ExchangeRate: &services.ExchangeRateSet{ | ||
CurrentRate: &services.ExchangeRate{ | ||
HbarEquiv: 30000, | ||
NextRate: &services.ExchangeRate{ | ||
HbarEquiv: 50000, | ||
CentEquiv: 154271, | ||
ExpirationTime: &services.TimestampSeconds{ | ||
Seconds: 1694689200, | ||
|
@@ -373,18 +380,109 @@ func TestUnitTransactionReceiptToJson(t *testing.T) { | |
require.NoError(t, err) | ||
receipt, err := tx.SetValidateStatus(true).GetReceipt(client) | ||
require.NoError(t, err) | ||
receiptBytes := receipt.ToBytes() | ||
receipt, err = TransactionReceiptFromBytes(receiptBytes) | ||
require.NoError(t, err) | ||
jsonBytes, err := receipt.MarshalJSON() | ||
require.NoError(t, err) | ||
expected := `{"accountId":"0.0.123","children":[{"accountId":"0.0.123","children":[],"contractId":"0.0.456","duplicates":[],"exchangeRate": | ||
{"hbars":30000,"cents":154271,"expirationTime":"2023-09-14T11:00:00.000Z"},"fileId":"0.0.789","nodeId":0,"scheduleId":"0.0.321", | ||
"scheduledTransactionId":"[email protected]","serialNumbers":[1,2,3],"status":"SUCCESS","tokenId":"0.0.987","topicId":"0.0.654", | ||
"topicRunningHash":"0a","topicRunningHashVersion":0,"topicSequenceNumber":10,"totalSupply":0}],"contractId":"0.0.456", | ||
"duplicates":[{"accountId":"0.0.123","children":[],"contractId":"0.0.456","duplicates":[],"exchangeRate":{"hbars":30000,"cents":154271, | ||
"expirationTime":"2023-09-14T11:00:00.000Z"},"fileId":"0.0.789","nodeId":0,"scheduleId":"0.0.321","scheduledTransactionId":"[email protected]", | ||
"serialNumbers":[1,2,3],"status":"SUCCESS","tokenId":"0.0.987","topicId":"0.0.654","topicRunningHash":"0a","topicRunningHashVersion":0, | ||
"topicSequenceNumber":10,"totalSupply":0}],"exchangeRate":{"hbars":30000,"cents":154271,"expirationTime":"2023-09-14T11:00:00.000Z"}, | ||
"fileId":"0.0.789","nodeId":1,"scheduleId":"0.0.321","scheduledTransactionId":"[email protected]","serialNumbers":[1,2,3],"status":"SUCCESS", | ||
"tokenId":"0.0.987","topicId":"0.0.654","topicRunningHash":"0a","topicRunningHashVersion":0,"topicSequenceNumber":10,"totalSupply":0}` | ||
expected := ` | ||
{ | ||
"accountId":"0.0.123", | ||
"children":[ | ||
{ | ||
"accountId":"0.0.123", | ||
"children":[ | ||
], | ||
"contractId":"0.0.456", | ||
"duplicates":[ | ||
], | ||
"exchangeRate":{ | ||
"hbars":30000, | ||
"cents":154271, | ||
"expirationTime":"2023-09-14T11:00:00.000Z" | ||
}, | ||
"fileId":"0.0.789", | ||
"nodeId":0, | ||
"scheduleId":"0.0.321", | ||
"scheduledTransactionId":"[email protected]", | ||
"serialNumbers":[ | ||
1, | ||
2, | ||
3 | ||
], | ||
"status":"SUCCESS", | ||
"tokenId":"0.0.987", | ||
"topicId":"0.0.654", | ||
"topicRunningHash":"0a", | ||
"topicRunningHashVersion":0, | ||
"topicSequenceNumber":10, | ||
"totalSupply":0 | ||
} | ||
], | ||
"contractId":"0.0.456", | ||
"duplicates":[ | ||
{ | ||
"accountId":"0.0.123", | ||
"children":[ | ||
], | ||
"contractId":"0.0.456", | ||
"duplicates":[ | ||
], | ||
"fileId":"0.0.789", | ||
"nextExchangeRate":{ | ||
"cents":154271, | ||
"expirationTime":"2023-09-14T11:00:00.000Z", | ||
"hbars":50000 | ||
}, | ||
"nodeId":0, | ||
"scheduleId":"0.0.321", | ||
"scheduledTransactionId":"[email protected]", | ||
"serialNumbers":[ | ||
1, | ||
2, | ||
3 | ||
], | ||
"status":"SUCCESS", | ||
"tokenId":"0.0.987", | ||
"topicId":"0.0.654", | ||
"topicRunningHash":"0a", | ||
"topicRunningHashVersion":0, | ||
"topicSequenceNumber":10, | ||
"totalSupply":0 | ||
} | ||
], | ||
"exchangeRate":{ | ||
"hbars":30000, | ||
"cents":154271, | ||
"expirationTime":"2023-09-14T11:00:00.000Z" | ||
}, | ||
"fileId":"0.0.789", | ||
"nextExchangeRate":{ | ||
"cents":154271, | ||
"expirationTime":"2023-09-14T11:00:00.000Z", | ||
"hbars":50000 | ||
}, | ||
"nodeId":1, | ||
"scheduleId":"0.0.321", | ||
"scheduledTransactionId":"[email protected]", | ||
"serialNumbers":[ | ||
1, | ||
2, | ||
3 | ||
], | ||
"status":"SUCCESS", | ||
"tokenId":"0.0.987", | ||
"topicId":"0.0.654", | ||
"topicRunningHash":"0a", | ||
"topicRunningHashVersion":0, | ||
"topicSequenceNumber":10, | ||
"totalSupply":0 | ||
} | ||
` | ||
|
||
assert.JSONEqf(t, expected, string(jsonBytes), "json should be equal") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters