Skip to content

Commit

Permalink
Merge branch 'main' into hip-904-max-auto-associations-of-value--1
Browse files Browse the repository at this point in the history
  • Loading branch information
0xivanov authored Jul 3, 2024
2 parents 6b42011 + ac22f4f commit 780a43b
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

Expand All @@ -154,7 +154,7 @@ jobs:
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Install Task
run: go install github.com/go-task/task/v3/cmd/task@v3.17.0
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## v2.40.0

### Added

- Implemented custom derivation paths in Menmonic ECDSA private key derivation

### Fixed

- Revisited and fix failing examples
- Gracefully handle `PlatformNotActive` status code

## v2.39.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
golang.org/x/crypto v0.24.0
golang.org/x/text v0.16.0
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.1
google.golang.org/protobuf v1.34.2
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1262,8 +1262,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
4 changes: 2 additions & 2 deletions transaction_receipt_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (q *TransactionReceiptQuery) shouldRetry(_ Executable, response interface{}
status := Status(response.(*services.Response).GetTransactionGetReceipt().GetHeader().GetNodeTransactionPrecheckCode())

switch status {
case StatusPlatformTransactionNotCreated, StatusBusy, StatusUnknown, StatusReceiptNotFound, StatusRecordNotFound:
case StatusPlatformTransactionNotCreated, StatusBusy, StatusUnknown, StatusReceiptNotFound, StatusRecordNotFound, StatusPlatformNotActive:
return executionStateRetry
case StatusOk:
break
Expand All @@ -280,7 +280,7 @@ func (q *TransactionReceiptQuery) shouldRetry(_ Executable, response interface{}
status = Status(response.(*services.Response).GetTransactionGetReceipt().GetReceipt().GetStatus())

switch status {
case StatusBusy, StatusUnknown, StatusOk, StatusReceiptNotFound, StatusRecordNotFound:
case StatusBusy, StatusUnknown, StatusOk, StatusReceiptNotFound, StatusRecordNotFound, StatusPlatformNotActive:
return executionStateRetry
default:
return executionStateFinished
Expand Down
49 changes: 49 additions & 0 deletions transaction_receipt_query_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,54 @@ func TestUnitTransactionReceiptQueryNothingSet(t *testing.T) {
balance.GetQueryPayment()
balance.GetMaxQueryPayment()
}

func TestUnitTransactionPlatformNotActiveGracefulHandling(t *testing.T) {
t.Parallel()

responses := [][]interface{}{{
&services.TransactionResponse{
NodeTransactionPrecheckCode: services.ResponseCodeEnum_OK,
},
&services.Response{
Response: &services.Response_TransactionGetReceipt{
TransactionGetReceipt: &services.TransactionGetReceiptResponse{
Header: &services.ResponseHeader{
Cost: 0,
ResponseType: services.ResponseType_ANSWER_ONLY,
},
Receipt: &services.TransactionReceipt{
Status: services.ResponseCodeEnum_PLATFORM_NOT_ACTIVE,
},
},
},
},
&services.Response{
Response: &services.Response_TransactionGetReceipt{
TransactionGetReceipt: &services.TransactionGetReceiptResponse{
Header: &services.ResponseHeader{
Cost: 0,
ResponseType: services.ResponseType_ANSWER_ONLY,
},
Receipt: &services.TransactionReceipt{
Status: services.ResponseCodeEnum_SUCCESS,
},
},
},
},
}}
client, server := NewMockClientAndServer(responses)
defer server.Close()
tx, err := NewTransferTransaction().
SetNodeAccountIDs([]AccountID{{Account: 3}}).
AddHbarTransfer(AccountID{Account: 2}, HbarFromTinybar(-1)).
AddHbarTransfer(AccountID{Account: 3}, HbarFromTinybar(1)).
Execute(client)
client.SetMaxAttempts(2)
require.NoError(t, err)
_, err = tx.SetValidateStatus(true).GetReceipt(client)
require.NoError(t, err)
}

func TestUnitTransactionReceiptNotFound(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -163,6 +211,7 @@ func TestUnitTransactionReceiptNotFound(t *testing.T) {
require.Equal(t, "exceptional precheck status RECEIPT_NOT_FOUND", err.Error())
require.Equal(t, StatusReceiptNotFound, receipt.Status)
}

func TestUnitTransactionReceiptUknown(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions transaction_record_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (q *TransactionRecordQuery) shouldRetry(_ Executable, response interface{})
status := Status(response.(*services.Response).GetTransactionGetRecord().GetHeader().GetNodeTransactionPrecheckCode())

switch status {
case StatusPlatformTransactionNotCreated, StatusBusy, StatusUnknown, StatusReceiptNotFound, StatusRecordNotFound:
case StatusPlatformTransactionNotCreated, StatusBusy, StatusUnknown, StatusReceiptNotFound, StatusRecordNotFound, StatusPlatformNotActive:
return executionStateRetry
case StatusOk:
if response.(*services.Response).GetTransactionGetRecord().GetHeader().ResponseType == services.ResponseType_COST_ANSWER {
Expand All @@ -263,7 +263,7 @@ func (q *TransactionRecordQuery) shouldRetry(_ Executable, response interface{})
status = Status(response.(*services.Response).GetTransactionGetRecord().GetTransactionRecord().GetReceipt().GetStatus())

switch status {
case StatusBusy, StatusUnknown, StatusOk, StatusReceiptNotFound, StatusRecordNotFound:
case StatusBusy, StatusUnknown, StatusOk, StatusReceiptNotFound, StatusRecordNotFound, StatusPlatformNotActive:
return executionStateRetry
case StatusSuccess:
return executionStateFinished
Expand Down
95 changes: 95 additions & 0 deletions transaction_record_query_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,101 @@ func TestUnitTransactionRecordQueryNothingSet(t *testing.T) {
require.Equal(t, Hbar{}, query.GetMaxQueryPayment())
}

func TestUnitTransactionRecordPlatformNotActiveGracefulHandling(t *testing.T) {
t.Parallel()

responses := [][]interface{}{{
&services.TransactionResponse{
NodeTransactionPrecheckCode: services.ResponseCodeEnum_OK,
},
&services.Response{
Response: &services.Response_TransactionGetReceipt{
TransactionGetReceipt: &services.TransactionGetReceiptResponse{
Header: &services.ResponseHeader{
Cost: 0,
ResponseType: services.ResponseType_ANSWER_ONLY,
},
Receipt: &services.TransactionReceipt{
Status: services.ResponseCodeEnum_SUCCESS,
},
},
},
},
&services.Response{
Response: &services.Response_TransactionGetRecord{
TransactionGetRecord: &services.TransactionGetRecordResponse{
Header: &services.ResponseHeader{
Cost: 0,
ResponseType: services.ResponseType_ANSWER_ONLY,
},
TransactionRecord: &services.TransactionRecord{
Receipt: &services.TransactionReceipt{
Status: services.ResponseCodeEnum_PLATFORM_NOT_ACTIVE,
},
},
},
},
},
&services.Response{
Response: &services.Response_TransactionGetRecord{
TransactionGetRecord: &services.TransactionGetRecordResponse{
Header: &services.ResponseHeader{
Cost: 0,
ResponseType: services.ResponseType_ANSWER_ONLY,
},
TransactionRecord: &services.TransactionRecord{
Receipt: &services.TransactionReceipt{
Status: services.ResponseCodeEnum_SUCCESS,
},
},
},
},
},
&services.Response{
Response: &services.Response_TransactionGetRecord{
TransactionGetRecord: &services.TransactionGetRecordResponse{
Header: &services.ResponseHeader{
Cost: 0,
ResponseType: services.ResponseType_ANSWER_ONLY,
},
TransactionRecord: &services.TransactionRecord{
Receipt: &services.TransactionReceipt{
Status: services.ResponseCodeEnum_PLATFORM_NOT_ACTIVE,
},
},
},
},
},
&services.Response{
Response: &services.Response_TransactionGetRecord{
TransactionGetRecord: &services.TransactionGetRecordResponse{
Header: &services.ResponseHeader{
Cost: 0,
ResponseType: services.ResponseType_ANSWER_ONLY,
},
TransactionRecord: &services.TransactionRecord{
Receipt: &services.TransactionReceipt{
Status: services.ResponseCodeEnum_SUCCESS,
},
},
},
},
},
}}

client, server := NewMockClientAndServer(responses)
defer server.Close()
tx, err := NewTransferTransaction().
SetNodeAccountIDs([]AccountID{{Account: 3}}).
AddHbarTransfer(AccountID{Account: 2}, HbarFromTinybar(-1)).
AddHbarTransfer(AccountID{Account: 3}, HbarFromTinybar(1)).
Execute(client)
client.SetMaxAttempts(2)
require.NoError(t, err)
_, err = tx.SetValidateStatus(true).GetRecord(client)
require.NoError(t, err)
}

func TestUnitTransactionRecordReceiptNotFound(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 780a43b

Please sign in to comment.