diff --git a/pkg/bee/debugapi/node.go b/pkg/bee/debugapi/node.go index 7683ca68c..134895799 100644 --- a/pkg/bee/debugapi/node.go +++ b/pkg/bee/debugapi/node.go @@ -265,13 +265,13 @@ func (n *NodeService) Wallet(ctx context.Context) (resp Wallet, err error) { // Withdraw calls wallet withdraw endpoint func (n *NodeService) Withdraw(ctx context.Context, token, addr string) (tx common.Hash, err error) { - endpoint := fmt.Sprintf("/wallet/withdraw/%s?address=%s&amount=1", token, addr) + endpoint := fmt.Sprintf("/wallet/withdraw/%s?address=%s&amount=10000000000000000", token, addr) r := struct { TransactionHash common.Hash `json:"transactionHash"` }{} - err = n.client.requestJSON(ctx, http.MethodPost, endpoint, nil, r) + err = n.client.requestJSON(ctx, http.MethodPost, endpoint, nil, &r) if err != nil { return } diff --git a/pkg/check/withdraw/withdraw.go b/pkg/check/withdraw/withdraw.go index 4d0b71418..f474036af 100644 --- a/pkg/check/withdraw/withdraw.go +++ b/pkg/check/withdraw/withdraw.go @@ -5,6 +5,7 @@ import ( "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" @@ -48,7 +49,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int return err } - target := checkCase.RandomBee() + target := checkCase.Bee(1) c.logger.Infof("target is %s", target.Name()) c.logger.Info("withdrawing bzz...") @@ -60,14 +61,16 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int c.logger.Info("success") c.logger.Info("withdrawing native...") - if err := target.Withdraw(ctx, "sETH", o.TargetAddr); err != nil { - return fmt.Errorf("withdraw bzz: %w", err) + if err := target.Withdraw(ctx, "xDAI", o.TargetAddr); err != nil { + return fmt.Errorf("withdraw native: %w", err) } c.logger.Info("success") c.logger.Info("withdrawing to a non whitelisted address") - if err := target.Withdraw(ctx, "sETH", "0x0000000000000000000000"); err == nil { + var zeroAddr common.Address + + if err := target.Withdraw(ctx, "sETH", zeroAddr.String()); err == nil { return errors.New("withdraw to non-whitelisted address expected to fail") } diff --git a/pkg/test/node.go b/pkg/test/node.go index 2b7c17e7f..de9a6b58b 100644 --- a/pkg/test/node.go +++ b/pkg/test/node.go @@ -7,6 +7,7 @@ import ( "fmt" "math/big" "math/rand" + "time" "github.com/ethersphere/bee/pkg/swarm" "github.com/ethersphere/beekeeper/pkg/bee" @@ -113,14 +114,18 @@ func (b *BeeV2) Withdraw(ctx context.Context, token, addr string) error { return fmt.Errorf("(%s) withdraw balance %w", b.name, err) } + time.Sleep(2 * time.Second) + after, err := b.client.WalletBalance(ctx, token) if err != nil { return fmt.Errorf("(%s) wallet balance %w", b.name, err) } - if after.Cmp(before) < 0 { - return nil + want := big.NewInt(0).Sub(before, big.NewInt(10000000000000000)) + + if after.Cmp(want) > 0 { + return errors.New("incorrect balance after withdraw") } - return errors.New("incorrect balance after withdraw") + return nil }