forked from onflow/flow-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into leo/export-evm-state-from-gobs
- Loading branch information
Showing
41 changed files
with
1,507 additions
and
329 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package parser | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/onflow/flow-go/model/flow" | ||
) | ||
|
||
// Finalized and Sealed represents the status of a block. | ||
// It is used in rest arguments to provide block status. | ||
const ( | ||
Finalized = "finalized" | ||
Sealed = "sealed" | ||
) | ||
|
||
func ParseBlockStatus(blockStatus string) (flow.BlockStatus, error) { | ||
switch blockStatus { | ||
case Finalized: | ||
return flow.BlockStatusFinalized, nil | ||
case Sealed: | ||
return flow.BlockStatusSealed, nil | ||
} | ||
return flow.BlockStatusUnknown, fmt.Errorf("invalid 'block_status', must be '%s' or '%s'", Finalized, Sealed) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package parser | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/onflow/flow-go/model/flow" | ||
) | ||
|
||
// TestParseBlockStatus_Invalid tests the ParseBlockStatus function with invalid inputs. | ||
// It verifies that for each invalid block status string, the function returns an error | ||
// matching the expected error message format. | ||
func TestParseBlockStatus_Invalid(t *testing.T) { | ||
tests := []string{"unknown", "pending", ""} | ||
expectedErr := fmt.Sprintf("invalid 'block_status', must be '%s' or '%s'", Finalized, Sealed) | ||
|
||
for _, input := range tests { | ||
_, err := ParseBlockStatus(input) | ||
assert.EqualError(t, err, expectedErr) | ||
} | ||
} | ||
|
||
// TestParseBlockStatus_Valid tests the ParseBlockStatus function with valid inputs. | ||
// It ensures that the function returns the correct flow.BlockStatus for valid status | ||
// strings "finalized" and "sealed" without errors. | ||
func TestParseBlockStatus_Valid(t *testing.T) { | ||
tests := map[string]flow.BlockStatus{ | ||
Finalized: flow.BlockStatusFinalized, | ||
Sealed: flow.BlockStatusSealed, | ||
} | ||
|
||
for input, expectedStatus := range tests { | ||
status, err := ParseBlockStatus(input) | ||
assert.NoError(t, err) | ||
assert.Equal(t, expectedStatus, status) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
engine/access/rest/http/request/id.go → engine/access/rest/common/parser/id.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package request | ||
package parser | ||
|
||
import ( | ||
"errors" | ||
|
2 changes: 1 addition & 1 deletion
2
engine/access/rest/http/request/id_test.go → engine/access/rest/common/parser/id_test.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package request | ||
package parser | ||
|
||
import ( | ||
"testing" | ||
|
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
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
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
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
Oops, something went wrong.