Skip to content

Commit

Permalink
Merge pull request #6668 from spacemeshos/node-split-poc-fix-hare-tot…
Browse files Browse the repository at this point in the history
…al-weight

[node-split] fix hare total weight
  • Loading branch information
poszu authored Jan 30, 2025
2 parents d90cbef + d4b6405 commit 0402f25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions api/node/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/spacemeshos/go-spacemesh/api/node/models"
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/hare3"
"github.com/spacemeshos/go-spacemesh/hare3/eligibility"
"github.com/spacemeshos/go-spacemesh/p2p/pubsub"
)

Expand Down Expand Up @@ -288,6 +289,9 @@ func (s *Server) GetHareWeightNodeIdLayer(ctx context.Context,
}
weight, err := s.hare.MinerWeight(ctx, id, types.LayerID(request.Layer))
if err != nil {
if errors.Is(err, eligibility.ErrNotActive) {
return &GetHareWeightNodeIdLayer200JSONResponse{Weight: 0}, nil
}
return nil, fmt.Errorf("miner weight: %w", err)
}
return &GetHareWeightNodeIdLayer200JSONResponse{Weight: weight}, nil
Expand Down
11 changes: 7 additions & 4 deletions systest/tests/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ func testTransactions(
}

diff := batch * amount * int(sendFor-1) * cl.Accounts()
for i := 0; i < cl.Total(); i++ {
client := cl.Client(i)
for _, client := range nodesReceivingTxs {
state := pb.NewGlobalStateServiceClient(client.PubConn())
response, err := state.Account(
tctx,
Expand All @@ -119,7 +118,11 @@ func testTransactions(
"expected-diff", diff,
"diff", after.Value-before.Value,
)
require.Equal(tb, int(before.Value)+diff,
int(response.AccountWrapper.StateCurrent.Balance.Value), "client=%s", client.Name)
require.Equal(tb,
before.Value+uint64(diff),
response.AccountWrapper.StateCurrent.Balance.Value,
"client=%s",
client.Name,
)
}
}

0 comments on commit 0402f25

Please sign in to comment.