Skip to content

Commit

Permalink
Merge pull request #4 from coinbase/patrick/allow-network-status
Browse files Browse the repository at this point in the history
Add /network/status to allowedMethods
  • Loading branch information
patrick-ogrady authored Apr 3, 2020
2 parents e0ac42f + abd514a commit ab8a333
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
29 changes: 17 additions & 12 deletions asserter/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ import (
rosetta "github.com/coinbase/rosetta-sdk-go/gen"
)

var (
// AllowedMethods are all the methods that are considered
// valid in a Options.Methods array.
AllowedMethods = []string{
"/account/balance",
"/account/transactions",
"/block",
"/block/transaction",
"/construction/metadata",
"/construction/submit",
"/mempool",
"/mempool/transaction",
"/network/status",
}
)

// SubNetworkIdentifier asserts a rosetta.SubNetworkIdentifer is valid (if not nil).
func SubNetworkIdentifier(subNetworkIdentifier *rosetta.SubNetworkIdentifier) error {
if subNetworkIdentifier == nil {
Expand Down Expand Up @@ -131,19 +147,8 @@ func SupportedMethods(methods []string) error {
return errors.New("no Options.Methods found")
}

allowedMethods := []string{
"/block",
"/block/transaction",
"/mempool",
"/mempool/transaction",
"/account/balance",
"/account/transactions",
"/construction/metadata",
"/construction/submit",
}

for _, method := range methods {
if !contains(allowedMethods, method) {
if !contains(AllowedMethods, method) {
return fmt.Errorf("%s is not a valid method", method)
}
}
Expand Down
3 changes: 2 additions & 1 deletion asserter/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ func TestVersion(t *testing.T) {
func TestNetworkOptions(t *testing.T) {
var (
methods = []string{
"/block",
"/account/balance",
"/block",
"/network/status",
}

operationStatuses = []*rosetta.OperationStatus{
Expand Down

0 comments on commit ab8a333

Please sign in to comment.