-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: wallet withdraw test #386
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c82b49b
feat: wallet withdraw test
notanatol ae6a1bb
fix: config
notanatol 4ac367e
fix: missing query param
notanatol 9b99a71
fix: target info
notanatol 7caa117
fix: comparison
notanatol 5abc21d
fix: update config
notanatol d21beb5
fix: teplates and configs
notanatol e1c8854
fix: auth test order error info
notanatol 41dc0c9
fix: auth smaller amount
notanatol d6fbaa3
fix: smaller amount
notanatol 1a3a9d7
fix: sleep
notanatol 68e2090
fix: native token
notanatol 2410bcf
fix: pr feedback
notanatol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package withdraw | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethersphere/beekeeper/pkg/beekeeper" | ||
"github.com/ethersphere/beekeeper/pkg/logging" | ||
"github.com/ethersphere/beekeeper/pkg/orchestration" | ||
test "github.com/ethersphere/beekeeper/pkg/test" | ||
) | ||
|
||
// Options represents check options | ||
type Options struct { | ||
TargetAddr string | ||
} | ||
|
||
// NewDefaultOptions returns new default options | ||
func NewDefaultOptions() Options { | ||
return Options{} | ||
} | ||
|
||
// compile check whether Check implements interface | ||
var _ beekeeper.Action = (*Check)(nil) | ||
|
||
// Check instance | ||
type Check struct { | ||
logger logging.Logger | ||
} | ||
|
||
// NewCheck returns new check | ||
func NewCheck(logger logging.Logger) beekeeper.Action { | ||
return &Check{ | ||
logger: logger, | ||
} | ||
} | ||
|
||
func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts interface{}) (err error) { | ||
o, ok := opts.(Options) | ||
if !ok { | ||
return fmt.Errorf("invalid options type") | ||
} | ||
|
||
var checkCase *test.CheckCase | ||
|
||
if checkCase, err = test.NewCheckCase(ctx, cluster, test.CaseOptions{}, c.logger); err != nil { | ||
return err | ||
} | ||
|
||
target := checkCase.Bee(1) | ||
|
||
c.logger.Infof("target is %s", target.Name()) | ||
|
||
c.logger.Info("withdrawing native...") | ||
|
||
if err := target.Withdraw(ctx, "NativeToken", o.TargetAddr); err != nil { | ||
return fmt.Errorf("withdraw native: %w", err) | ||
} | ||
|
||
c.logger.Info("success") | ||
c.logger.Info("withdrawing to a non whitelisted address") | ||
|
||
var zeroAddr common.Address | ||
|
||
if err := target.Withdraw(ctx, "NativeToken", zeroAddr.String()); err == nil { | ||
return errors.New("withdraw to non-whitelisted address expected to fail") | ||
} | ||
|
||
c.logger.Info("success") | ||
c.logger.Info("withdrawing bzz...") | ||
|
||
if err := target.Withdraw(ctx, "BZZ", o.TargetAddr); err != nil { | ||
return fmt.Errorf("withdraw bzz: %w", err) | ||
} | ||
|
||
c.logger.Info("success") | ||
|
||
return nil | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the balance before and after the withdrawal should be compared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's being tested inside the function, this way I can use the same method for different coin/addresses:
https://github.com/ethersphere/beekeeper/pull/386/files#diff-26ffebd2abeeaff0e1d88eab9a47503856f31fcfc6fd6704b431ea5c4b72727cR125