Skip to content

Commit

Permalink
feat: swip 20 (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
istae authored Jul 24, 2024
1 parent b017aef commit 7fc9752
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/ethersphere/beekeeper

go 1.22

toolchain go1.22.0

replace github.com/codahale/hdrhistogram => github.com/HdrHistogram/hdrhistogram-go v1.1.2

require (
Expand Down
6 changes: 3 additions & 3 deletions pkg/bee/api/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func (s *StakingService) GetStakedAmount(ctx context.Context) (stakedAmount *big
return r.StakedAmount.Int, nil
}

// WithdrawStake withdraws stake
func (s *StakingService) WithdrawStake(ctx context.Context) (txHash string, err error) {
// MigrateStake withdraws stake
func (s *StakingService) MigrateStake(ctx context.Context) (txHash string, err error) {
r := new(stakeWithdrawResponse)
err = s.client.requestJSON(ctx, http.MethodDelete, "/stake", nil, r)
err = s.client.requestJSON(ctx, http.MethodPost, "/stake/migrate", nil, r)
if err != nil {
return "", err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/bee/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,9 +822,9 @@ func (c *Client) GetStake(ctx context.Context) (*big.Int, error) {
return c.api.Stake.GetStakedAmount(ctx)
}

// WithdrawStake withdraws stake
func (c *Client) WithdrawStake(ctx context.Context) (string, error) {
return c.api.Stake.WithdrawStake(ctx)
// MigrateStake withdraws stake
func (c *Client) MigrateStake(ctx context.Context) (string, error) {
return c.api.Stake.MigrateStake(ctx)
}

// WalletBalance fetches the balance for the given token
Expand Down
9 changes: 5 additions & 4 deletions pkg/check/stake/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"errors"
"fmt"
"github.com/ethersphere/beekeeper/pkg/bee/api"
"math/big"

"github.com/ethersphere/beekeeper/pkg/bee/api"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethersphere/beekeeper/pkg/bee"
"github.com/ethersphere/beekeeper/pkg/beekeeper"
Expand Down Expand Up @@ -84,7 +85,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
client := clients[node]

if err := expectStakeAmountIs(ctx, client, zero); err != nil {
return errors.New("check initial staked amount")
return err
}

// depositing insufficient amount should fail
Expand Down Expand Up @@ -121,7 +122,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
}

// should not allow withdrawing from a running contract
_, err = client.WithdrawStake(ctx)
_, err = client.MigrateStake(ctx)
if err == nil {
return errors.New("withdraw from running contract should fail")
}
Expand All @@ -147,7 +148,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
}()

// successful withdraw should set the staked amount to 0
_, err = client.WithdrawStake(ctx)
_, err = client.MigrateStake(ctx)
if err != nil {
return fmt.Errorf("withdraw from paused contract: %w", err)
}
Expand Down

0 comments on commit 7fc9752

Please sign in to comment.