-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into e2e-new-chain-support
- Loading branch information
Showing
42 changed files
with
1,634 additions
and
1,147 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package chains | ||
|
||
import "errors" | ||
|
||
// ReceiveStatusFromString returns a ReceiveStatus from a string using in CLI | ||
// 0 for success, 1 for failed | ||
// TODO: remove "receive" naming ans use outbound | ||
// https://github.com/zeta-chain/node/issues/1797 | ||
func ReceiveStatusFromString(str string) (ReceiveStatus, error) { | ||
switch str { | ||
case "0": | ||
return ReceiveStatus_Success, nil | ||
case "1": | ||
return ReceiveStatus_Failed, nil | ||
default: | ||
return ReceiveStatus(0), errors.New("wrong status, must be 0 for success or 1 for failed") | ||
} | ||
} |
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,47 @@ | ||
package chains_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/zeta-chain/zetacore/pkg/chains" | ||
) | ||
|
||
func TestReceiveStatusFromString(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
str string | ||
want chains.ReceiveStatus | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "success", | ||
str: "0", | ||
want: chains.ReceiveStatus_Success, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "failed", | ||
str: "1", | ||
want: chains.ReceiveStatus_Failed, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "wrong status", | ||
str: "2", | ||
want: chains.ReceiveStatus(0), | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := chains.ReceiveStatusFromString(tt.str) | ||
if tt.wantErr { | ||
require.Error(t, err) | ||
} else if got != tt.want { | ||
require.NoError(t, err) | ||
require.Equal(t, tt.want, got) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.