Skip to content

Commit

Permalink
feat: moved object GenericPPError
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Nov 26, 2024
1 parent 98cbea4 commit a960be2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
9 changes: 0 additions & 9 deletions agglayer/proof_generation_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ type PPError interface {
String() string
}

type GenericError struct {
Key string
Values string
}

func (p *GenericError) String() string {
return fmt.Sprintf("Generic error: %s: %s", p.Key, p.Values)
}

// ProofGenerationError is a struct that represents an error that occurs when generating a proof.
type ProofGenerationError struct {
GenerationType string
Expand Down
11 changes: 10 additions & 1 deletion agglayer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,15 @@ func (c *ImportedBridgeExit) Hash() common.Hash {
)
}

type GenericPPError struct {
Key string
Values string
}

func (p *GenericPPError) String() string {
return fmt.Sprintf("Generic error: %s: %s", p.Key, p.Values)
}

// CertificateHeader is the structure returned by the interop_getCertificateHeader RPC call
type CertificateHeader struct {
NetworkID uint32 `json:"network_id"`
Expand Down Expand Up @@ -656,7 +665,7 @@ func (c *CertificateHeader) UnmarshalJSON(data []byte) error {
default:
valueStr, _ := json.Marshal(value)

ppError = &GenericError{Key: key, Values: string(valueStr)}
ppError = &GenericPPError{Key: key, Values: string(valueStr)}
}
}

Expand Down
5 changes: 5 additions & 0 deletions agglayer/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ const (
expectedSignedCertificateyMetadataJSON = `{"network_id":1,"height":1,"prev_local_exit_root":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"new_local_exit_root":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"bridge_exits":[{"leaf_type":"Transfer","token_info":null,"dest_network":0,"dest_address":"0x0000000000000000000000000000000000000000","amount":"1","metadata":[1,2,3]}],"imported_bridge_exits":[{"bridge_exit":{"leaf_type":"Transfer","token_info":null,"dest_network":0,"dest_address":"0x0000000000000000000000000000000000000000","amount":"1","metadata":[]},"claim_data":null,"global_index":{"mainnet_flag":false,"rollup_index":1,"leaf_index":1}}],"metadata":"0x0000000000000000000000000000000000000000000000000000000000000000","signature":{"r":"0x0000000000000000000000000000000000000000000000000000000000000000","s":"0x0000000000000000000000000000000000000000000000000000000000000000","odd_y_parity":false}}`
)

func TestMGenericPPError(t *testing.T) {
err := GenericPPError{"test", "value"}
require.Equal(t, "Generic error: test: value", err.String())
}

func TestMarshalJSON(t *testing.T) {
cert := SignedCertificate{
Certificate: &Certificate{
Expand Down

0 comments on commit a960be2

Please sign in to comment.