Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Access] Implement integration test for new websockets [WIP] #6907

Draft
wants to merge 107 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
2e8d95b
change tx result retrieving
Guitarheroua Nov 15, 2024
de3851a
Fixed unit tests
Guitarheroua Nov 19, 2024
dfb40cf
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
Guitarheroua Nov 19, 2024
edb0636
fixed comment
Guitarheroua Nov 19, 2024
23a2214
simplify unit test
Guitarheroua Nov 19, 2024
e3a43a0
remove second block extraction
Guitarheroua Nov 19, 2024
ef8136d
removed unnecessary comment
Guitarheroua Nov 19, 2024
543fb9e
added missing documentation
Guitarheroua Nov 19, 2024
9ee3d6a
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
Guitarheroua Nov 20, 2024
b49bb7c
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
Guitarheroua Dec 2, 2024
2baa1a3
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
Guitarheroua Dec 4, 2024
8c0c247
Fixed remark
Guitarheroua Dec 4, 2024
2ecd739
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
Guitarheroua Dec 5, 2024
8f0e956
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
Guitarheroua Dec 12, 2024
35d3da9
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
Guitarheroua Dec 17, 2024
ed80a0c
Merge branch 'master' into AndriiSlisarchuk/6573-pending-should-retur…
Guitarheroua Dec 17, 2024
103d15d
Merge branch 'master' into AndriiSlisarchuk/6573-pending-should-retur…
peterargue Dec 17, 2024
86e6096
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
peterargue Dec 17, 2024
5c246f6
Added skeleton for websocket integration tests happy cases
UlyanaAndrukhiv Dec 19, 2024
5ba75c8
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
Guitarheroua Dec 19, 2024
4b7275b
Apply suggestions from code review
Guitarheroua Dec 20, 2024
5ede502
fixed remarks
Guitarheroua Dec 20, 2024
80b63eb
Merge branch 'master' into AndriiSlisarchuk/6573-pending-should-retur…
Guitarheroua Dec 20, 2024
8004129
Added logs, and basic test
UlyanaAndrukhiv Dec 23, 2024
c048094
Merge branch 'UlianaAndrukhiv/6799-inactivity-tracker' of github.com:…
UlyanaAndrukhiv Dec 23, 2024
bd2ea23
Added more logs
UlyanaAndrukhiv Dec 23, 2024
f39a952
Merged with illia-malachyn/6642-ws-controller-error-handling
UlyanaAndrukhiv Dec 23, 2024
7633849
Fixed error handling in websockets controller on read messages
UlyanaAndrukhiv Dec 24, 2024
2a0de6c
Merge branch 'UlyanaAndrukhiv/6775-websocket-responses' of github.com…
UlyanaAndrukhiv Dec 24, 2024
898e8e3
Updated checking error on websockets read messages, updated tests
UlyanaAndrukhiv Dec 24, 2024
db7bc48
Added inactivity test
Guitarheroua Dec 24, 2024
78a3e08
Refactored happy path block headers test, added common test helpers
UlyanaAndrukhiv Dec 26, 2024
298a1af
Merge branch 'UlianaAndrukhiv/6641-websockets-integration-tests' of g…
UlyanaAndrukhiv Dec 26, 2024
2a1f2f8
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
Guitarheroua Dec 27, 2024
c1dc45a
Apply suggestions from code review
Guitarheroua Dec 27, 2024
0f1ad0d
Merge branch 'master' into AndriiSlisarchuk/6573-pending-should-retur…
Guitarheroua Dec 27, 2024
a17b05b
Added happy cases for block and events subscription
UlyanaAndrukhiv Dec 27, 2024
e53c356
Merge branch 'master' into AndriiSlisarchuk/6573-pending-should-retur…
peterargue Dec 27, 2024
93c69c1
change to irrecoverable throw
Guitarheroua Dec 30, 2024
40a3323
Merge branch 'master' into AndriiSlisarchuk/6574-improve-tx-sub-statuses
Guitarheroua Dec 30, 2024
9504849
Added mor inactivity tests
Guitarheroua Jan 2, 2025
9350aa0
Updated listening websocket responses for websockets integration tests
UlyanaAndrukhiv Jan 2, 2025
1541f62
Uncomments test cases
UlyanaAndrukhiv Jan 2, 2025
2dd8d38
Merged with UlyanaAndrukhiv/6775-websocket-responses
UlyanaAndrukhiv Jan 2, 2025
a162ba2
Merge branch 'master' into AndriiSlisarchuk/6573-pending-should-retur…
peterargue Jan 2, 2025
0b864e5
Merged with master
UlyanaAndrukhiv Jan 3, 2025
4135267
Created common module for access integration tests for common helper …
UlyanaAndrukhiv Jan 3, 2025
581798e
Refactored tests
UlyanaAndrukhiv Jan 3, 2025
ff373f7
Fixed parsing arguments for SendAndGetTransactionStatusesDataProvider…
UlyanaAndrukhiv Jan 5, 2025
1bb47cb
Merged with AndriiSlisarchuk/6574-improve-tx-sub-statuses
UlyanaAndrukhiv Jan 5, 2025
f9bffd7
Reverted back last merge changes
UlyanaAndrukhiv Jan 5, 2025
c77eaeb
Linted
UlyanaAndrukhiv Jan 5, 2025
8db6b3e
added error case tests
Guitarheroua Jan 6, 2025
e697d1c
Updated validation for events and added account statuses validation f…
UlyanaAndrukhiv Jan 6, 2025
8b071f4
Merge branch 'UlianaAndrukhiv/6641-websockets-integration-tests' of g…
UlyanaAndrukhiv Jan 6, 2025
36f9832
Merge branch 'AndriiSlisarchuk/6573-pending-should-return-immediately…
UlyanaAndrukhiv Jan 6, 2025
3928046
Merge branch 'UlyanaAndrukhiv/6775-websocket-responses' of github.com…
UlyanaAndrukhiv Jan 6, 2025
63e39fb
Refactored send and subscribe tx statuses provider, updated tests
UlyanaAndrukhiv Jan 7, 2025
702c02d
Updated integration test to use require
UlyanaAndrukhiv Jan 7, 2025
9793215
Reverted back commented test cases
UlyanaAndrukhiv Jan 7, 2025
6f9ad9a
Added unsubscribe verification for subscriptions to integration websc…
UlyanaAndrukhiv Jan 7, 2025
6c18dd5
Updated websocket integration tests to use reuire from suite
UlyanaAndrukhiv Jan 7, 2025
383b7e8
Implement remarks. Added txRefID for subscribe calls. Added test.
Guitarheroua Jan 8, 2025
2349589
Added websocket integration test to verify list of subscription funct…
UlyanaAndrukhiv Jan 8, 2025
1a1280e
Merge branch 'AndriiDiachuk/6819-make-response-for-data-providers-con…
UlyanaAndrukhiv Jan 8, 2025
831cdaa
Merged with AndriiDiachuk/6819-make-response-for-data-providers-consi…
UlyanaAndrukhiv Jan 8, 2025
7184c8e
Started to implement state detection on transaction suscription
Guitarheroua Jan 9, 2025
207a5c5
Merged with illia-malachyn/6845-unify-subscription-and-message-id
UlyanaAndrukhiv Jan 9, 2025
99fab4d
Added verifications for expected error code, refactored happy cases a…
UlyanaAndrukhiv Jan 9, 2025
ae42e91
Fixed parsing arguments for account and events data providers, update…
UlyanaAndrukhiv Jan 10, 2025
1779e20
Merge branch 'master' of github.com:The-K-R-O-K/flow-go into UlianaAn…
UlyanaAndrukhiv Jan 10, 2025
81b8898
Removed test duplication
UlyanaAndrukhiv Jan 10, 2025
60065ae
Added required verification for conroller error response, updated err…
UlyanaAndrukhiv Jan 10, 2025
f1ac11b
Updated websocket integration tests
UlyanaAndrukhiv Jan 13, 2025
422b4a2
Updated reading unsubscribe response for inactivitu timeout integrati…
UlyanaAndrukhiv Jan 13, 2025
59a4521
Merge branch 'UlianaAndrukhiv/6865-data-provider-arguments' of github…
UlyanaAndrukhiv Jan 13, 2025
920b823
Merged with UlianaAndrukhiv/6865-data-provider-arguments, updated Tes…
UlyanaAndrukhiv Jan 13, 2025
fd79b5b
Merge branch 'UlianaAndrukhiv/6865-data-provider-arguments' of github…
UlyanaAndrukhiv Jan 13, 2025
725ccda
Fixed issues with test failint
Guitarheroua Jan 13, 2025
fb39848
Removed back extra controller logs
UlyanaAndrukhiv Jan 14, 2025
297de4f
Merged with illia-malachyn/6845-unify-subscription-and-message-id
UlyanaAndrukhiv Jan 15, 2025
e48a97c
Renamed parsing method, fixed unit test
UlyanaAndrukhiv Jan 15, 2025
25493da
Get rid of unnecessary api calls
Guitarheroua Jan 16, 2025
733a485
Merge branch 'master' of github.com:The-K-R-O-K/flow-go into AndriiSl…
Guitarheroua Jan 16, 2025
84fae87
Updated subscription id for websocket integration tests according to …
UlyanaAndrukhiv Jan 16, 2025
655d701
Merge branch 'AndriiSlisarchuk/6573-pending-should-return-immediately…
UlyanaAndrukhiv Jan 16, 2025
1170a55
Fixed crash
Guitarheroua Jan 16, 2025
ee68d7c
Expanded client error message during providing invalid subscription i…
UlyanaAndrukhiv Jan 16, 2025
d9ecd5c
Merge branch 'AndriiSlisarchuk/6573-pending-should-return-immediately…
UlyanaAndrukhiv Jan 16, 2025
ef3c242
Merged with /AndriiSlisarchuk/6573-pending-should-return-immediately …
UlyanaAndrukhiv Jan 16, 2025
b427e33
Fixed issue with statuses sending
Guitarheroua Jan 16, 2025
d4c4430
Merge branch 'AndriiSlisarchuk/6573-pending-should-return-immediately…
UlyanaAndrukhiv Jan 16, 2025
fb82ca5
Fixed transaction statuses tests
UlyanaAndrukhiv Jan 16, 2025
3211331
Renamed and updated websocket integration tests
UlyanaAndrukhiv Jan 16, 2025
f286069
Added missed godoc for controller, fixed integration test for inactiv…
UlyanaAndrukhiv Jan 16, 2025
912469b
Updated unit test according to last subscribe transaction statuses ch…
UlyanaAndrukhiv Jan 16, 2025
d173b15
Fixed tidy
UlyanaAndrukhiv Jan 16, 2025
81173b4
Linted integration test
UlyanaAndrukhiv Jan 16, 2025
b5b9f2f
Added comment for webscocket controller to clarification, fixed flack…
UlyanaAndrukhiv Jan 17, 2025
5c41d9b
Added implementation for max subscription per connection limitation, …
UlyanaAndrukhiv Jan 20, 2025
1d54095
Added integration test for max subscription per connection limitation
UlyanaAndrukhiv Jan 20, 2025
58731f2
Updated error handling for websocket controller, updated godoc, updat…
UlyanaAndrukhiv Jan 20, 2025
d5e7859
Added light updates for websocket integration tests
UlyanaAndrukhiv Jan 20, 2025
f6751dd
remove active subs counter as it is not needed
illia-malachyn Jan 21, 2025
e898de1
change default cosntants for ws limits
illia-malachyn Jan 21, 2025
fe304e1
Merge branch 'master' into UlianaAndrukhiv/6641-websockets-integratio…
peterargue Jan 21, 2025
e62a4ab
Merge branch 'master' of github.com:The-K-R-O-K/flow-go into UlianaAn…
Guitarheroua Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 15 additions & 29 deletions access/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,41 +203,19 @@ type API interface {
//
// If invalid parameters will be supplied SubscribeBlockDigestsFromLatest will return a failed subscription.
SubscribeBlockDigestsFromLatest(ctx context.Context, blockStatus flow.BlockStatus) subscription.Subscription
// SubscribeTransactionStatusesFromStartBlockID subscribes to transaction status updates for a given transaction ID.
// Monitoring begins from the specified block ID. The subscription streams status updates until the transaction
// reaches a final state (TransactionStatusSealed or TransactionStatusExpired). When the transaction reaches one of
// these final statuses, the subscription will automatically terminate.
//
// Parameters:
// - ctx: The context to manage the subscription's lifecycle, including cancellation.
// - txID: The identifier of the transaction to monitor.
// - startBlockID: The block ID from which to start monitoring.
// - requiredEventEncodingVersion: The version of event encoding required for the subscription.
SubscribeTransactionStatusesFromStartBlockID(ctx context.Context, txID flow.Identifier, startBlockID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) subscription.Subscription
// SubscribeTransactionStatusesFromStartHeight subscribes to transaction status updates for a given transaction ID.
// Monitoring begins from the specified block height. The subscription streams status updates until the transaction
// reaches a final state (TransactionStatusSealed or TransactionStatusExpired). When the transaction reaches one of
// these final statuses, the subscription will automatically terminate.
// SubscribeTransactionStatuses subscribes to transaction status updates for a given transaction ID. The subscription
// streams status updates until the transaction reaches the final state ([flow.TransactionStatusSealed] or
// [flow.TransactionStatusExpired]). When the transaction reaches one of these final states, the subscription will
// automatically terminate.
//
// Parameters:
// - ctx: The context to manage the subscription's lifecycle, including cancellation.
// - txID: The unique identifier of the transaction to monitor.
// - startHeight: The block height from which to start monitoring.
// - requiredEventEncodingVersion: The version of event encoding required for the subscription.
SubscribeTransactionStatusesFromStartHeight(ctx context.Context, txID flow.Identifier, startHeight uint64, requiredEventEncodingVersion entities.EventEncodingVersion) subscription.Subscription
// SubscribeTransactionStatusesFromLatest subscribes to transaction status updates for a given transaction ID.
// Monitoring begins from the latest block. The subscription streams status updates until the transaction
// reaches a final state (TransactionStatusSealed or TransactionStatusExpired). When the transaction reaches one of
// these final statuses, the subscription will automatically terminate.
//
// Parameters:
// - ctx: The context to manage the subscription's lifecycle, including cancellation.
// - txID: The unique identifier of the transaction to monitor.
// - requiredEventEncodingVersion: The version of event encoding required for the subscription.
SubscribeTransactionStatusesFromLatest(ctx context.Context, txID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) subscription.Subscription
// SendAndSubscribeTransactionStatuses sends a transaction to the network and subscribes to its status updates.
SubscribeTransactionStatuses(ctx context.Context, txID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) subscription.Subscription
// SendAndSubscribeTransactionStatuses sends a transaction to the execution node and subscribes to its status updates.
// Monitoring begins from the reference block saved in the transaction itself and streams status updates until the transaction
// reaches a final state (TransactionStatusSealed or TransactionStatusExpired). Once a final status is reached, the subscription
// reaches the final state ([flow.TransactionStatusSealed] or [flow.TransactionStatusExpired]). Once the final status has been reached, the subscription
// automatically terminates.
//
// Parameters:
Expand All @@ -261,6 +239,14 @@ type TransactionResult struct {
BlockHeight uint64
}

func (r *TransactionResult) IsExecuted() bool {
return r.Status == flow.TransactionStatusExecuted || r.Status == flow.TransactionStatusSealed
}

func (r *TransactionResult) IsFinal() bool {
return r.Status == flow.TransactionStatusSealed || r.Status == flow.TransactionStatusExpired
}

func TransactionResultToMessage(result *TransactionResult) *access.TransactionResultResponse {
return &access.TransactionResultResponse{
Status: entities.TransactionStatus(result.Status),
Expand Down
46 changes: 3 additions & 43 deletions access/mock/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion cmd/access/node_builder/access_node_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1454,10 +1454,19 @@ func (builder *FlowAccessNodeBuilder) extraFlags() {
defaultConfig.registerDBPruneThreshold,
fmt.Sprintf("specifies the number of blocks below the latest stored block height to keep in register db. default: %d", defaultConfig.registerDBPruneThreshold))

// websockets config
flags.DurationVar(&builder.rpcConf.WebSocketConfig.InactivityTimeout,
"websocket-inactivity-timeout",
defaultConfig.rpcConf.WebSocketConfig.InactivityTimeout,
"specifies the duration a WebSocket connection can remain open without any active subscriptions before being automatically closed")
"the duration a WebSocket connection can remain open without any active subscriptions before being automatically closed")
flags.Uint64Var(&builder.rpcConf.WebSocketConfig.MaxSubscriptionsPerConnection,
"websocket-max-subscriptions-per-connection",
defaultConfig.rpcConf.WebSocketConfig.MaxSubscriptionsPerConnection,
"the maximum number of active WebSocket subscriptions allowed per connection")
flags.Uint64Var(&builder.rpcConf.WebSocketConfig.MaxResponsesPerSecond,
"websocket-max-responses-per-second",
defaultConfig.rpcConf.WebSocketConfig.MaxResponsesPerSecond,
"the maximum number of responses that can be sent to a single client per second")
}).ValidateFlags(func() error {
if builder.supportsObserver && (builder.PublicNetworkConfig.BindAddress == cmd.NotSet || builder.PublicNetworkConfig.BindAddress == "") {
return errors.New("public-network-address must be set if supports-observer is true")
Expand Down
11 changes: 10 additions & 1 deletion cmd/observer/node_builder/observer_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,19 @@ func (builder *ObserverServiceBuilder) extraFlags() {
defaultConfig.registerDBPruneThreshold,
fmt.Sprintf("specifies the number of blocks below the latest stored block height to keep in register db. default: %d", defaultConfig.registerDBPruneThreshold))

// websockets config
flags.DurationVar(&builder.rpcConf.WebSocketConfig.InactivityTimeout,
"websocket-inactivity-timeout",
defaultConfig.rpcConf.WebSocketConfig.InactivityTimeout,
"specifies the duration a WebSocket connection can remain open without any active subscriptions before being automatically closed")
"the duration a WebSocket connection can remain open without any active subscriptions before being automatically closed")
flags.Uint64Var(&builder.rpcConf.WebSocketConfig.MaxSubscriptionsPerConnection,
"websocket-max-subscriptions-per-connection",
defaultConfig.rpcConf.WebSocketConfig.MaxSubscriptionsPerConnection,
"the maximum number of active WebSocket subscriptions allowed per connection")
flags.Uint64Var(&builder.rpcConf.WebSocketConfig.MaxResponsesPerSecond,
"websocket-max-responses-per-second",
defaultConfig.rpcConf.WebSocketConfig.MaxResponsesPerSecond,
"the maximum number of responses that can be sent to a single client per second")
}).ValidateFlags(func() error {
if builder.executionDataSyncEnabled {
if builder.executionDataConfig.FetchTimeout <= 0 {
Expand Down
25 changes: 5 additions & 20 deletions cmd/util/cmd/run-script/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/onflow/flow-go/module/metrics"
)

var ErrNotImplemented = errors.New("not implemented")

var (
flagPayloads string
flagState string
Expand Down Expand Up @@ -532,35 +534,18 @@ func (*api) SubscribeBlockDigestsFromLatest(
return nil
}

func (a *api) SubscribeTransactionStatusesFromStartBlockID(
_ context.Context,
_ flow.Identifier,
_ flow.Identifier,
_ entities.EventEncodingVersion,
) subscription.Subscription {
return nil
}

func (a *api) SubscribeTransactionStatusesFromStartHeight(
func (a *api) SubscribeTransactionStatuses(
_ context.Context,
_ flow.Identifier,
_ uint64,
_ entities.EventEncodingVersion,
) subscription.Subscription {
return nil
return subscription.NewFailedSubscription(ErrNotImplemented, "failed to call SubscribeTransactionStatuses")
}

func (a *api) SubscribeTransactionStatusesFromLatest(
_ context.Context,
_ flow.Identifier,
_ entities.EventEncodingVersion,
) subscription.Subscription {
return nil
}
func (a *api) SendAndSubscribeTransactionStatuses(
_ context.Context,
_ *flow.TransactionBody,
_ entities.EventEncodingVersion,
) subscription.Subscription {
return nil
return subscription.NewFailedSubscription(ErrNotImplemented, "failed to call SendAndSubscribeTransactionStatuses")
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package request
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package request
package parser

import (
"strings"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package request
package parser

import (
"fmt"
Expand All @@ -7,6 +7,7 @@ import (
)

const maxArgumentsLength = 100
const MaxAllowedScriptArguments = 100

type Arguments [][]byte

Expand All @@ -25,7 +26,7 @@ func (a *Arguments) Parse(raw []string) error {
}

if len(args) > maxArgumentsLength {
return fmt.Errorf("too many arguments. Maximum arguments allowed: %d", maxAllowedScriptArguments)
return fmt.Errorf("too many arguments. Maximum arguments allowed: %d", MaxAllowedScriptArguments)
}

*a = args
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package request
package parser

import (
"fmt"
Expand All @@ -21,13 +21,13 @@ func TestArguments_InvalidParse(t *testing.T) {
assert.EqualError(t, err, "invalid argument encoding: illegal base64 data at input byte 0", a)
}

tooLong := make([]string, maxAllowedScriptArguments+1)
tooLong := make([]string, MaxAllowedScriptArguments+1)
for i := range tooLong {
tooLong[i] = "dGVzdA=="
}

err := arguments.Parse(tooLong)
assert.EqualError(t, err, fmt.Sprintf("too many arguments. Maximum arguments allowed: %d", maxAllowedScriptArguments))
assert.EqualError(t, err, fmt.Sprintf("too many arguments. Maximum arguments allowed: %d", MaxAllowedScriptArguments))
}

func TestArguments_ValidParse(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package request
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package request
package parser

import (
"encoding/hex"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package request
package parser

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
package request
package parser

import (
"fmt"
"io"

"github.com/onflow/flow-go/engine/access/rest/common/parser"
"github.com/onflow/flow-go/engine/access/rest/common"
"github.com/onflow/flow-go/engine/access/rest/http/models"
"github.com/onflow/flow-go/engine/access/rest/util"
"github.com/onflow/flow-go/engine/common/rpc/convert"
"github.com/onflow/flow-go/model/flow"
)

const maxAuthorizers = 100
const maxAllowedScriptArguments = 100

type Transaction flow.TransactionBody

func (t *Transaction) Parse(raw io.Reader, chain flow.Chain) error {
var tx models.TransactionsBody
err := parseBody(raw, &tx)
err := common.ParseBody(raw, &tx)
if err != nil {
return err
}
Expand All @@ -35,8 +34,8 @@ func (t *Transaction) Parse(raw io.Reader, chain flow.Chain) error {
if len(tx.Authorizers) > maxAuthorizers {
return fmt.Errorf("too many authorizers. Maximum authorizers allowed: %d", maxAuthorizers)
}
if len(tx.Arguments) > maxAllowedScriptArguments {
return fmt.Errorf("too many arguments. Maximum arguments allowed: %d", maxAllowedScriptArguments)
if len(tx.Arguments) > MaxAllowedScriptArguments {
return fmt.Errorf("too many arguments. Maximum arguments allowed: %d", MaxAllowedScriptArguments)
}
if tx.ReferenceBlockId == "" {
return fmt.Errorf("reference block not provided")
Expand Down Expand Up @@ -90,7 +89,7 @@ func (t *Transaction) Parse(raw io.Reader, chain flow.Chain) error {
return fmt.Errorf("invalid transaction script encoding")
}

var blockID parser.ID
var blockID ID
err = blockID.Parse(tx.ReferenceBlockId)
if err != nil {
return fmt.Errorf("invalid reference block ID: %w", err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package request
package parser

import (
"bytes"
Expand Down
Loading
Loading