-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tx hash in return values of upload apis (#52)
- Loading branch information
1 parent
2cf72f6
commit 38cc4c7
Showing
9 changed files
with
77 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package node_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/0glabs/0g-storage-client/node" | ||
"gotest.tools/assert" | ||
) | ||
|
||
func extractRPCError(err error) *node.RPCError { | ||
var rpcError *node.RPCError | ||
if errors.As(err, &rpcError) { | ||
return rpcError | ||
} | ||
return nil | ||
} | ||
|
||
func TestErrorAs(t *testing.T) { | ||
err := fmt.Errorf("123") | ||
assert.Equal(t, extractRPCError(err) == nil, true) | ||
err = &node.RPCError{ | ||
Method: "test", | ||
URL: "127.0.0.1:1234", | ||
Message: "test error", | ||
} | ||
assert.DeepEqual( | ||
t, | ||
extractRPCError(errors.WithMessage(err, "failed to upload")), | ||
err, | ||
) | ||
assert.DeepEqual( | ||
t, | ||
extractRPCError(errors.WithMessage(errors.WithMessage(err, "failed to upload segment"), "Failed to upload file")), | ||
err, | ||
) | ||
} |
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