Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions e2e/runner/require.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (

"github.com/zeta-chain/node/testutil/sample"
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types"
emissionstypes "github.com/zeta-chain/node/x/emissions/types"
"github.com/zeta-chain/node/x/observer/types"
)

// EnsureNoTrackers ensures that there are no trackers left on zetacore
Expand Down Expand Up @@ -62,18 +64,27 @@ func ensureZRC20ZeroBalance(r *E2ERunner, zrc20 *zrc20.ZRC20, address ethcommon.

// EnsureNoStaleBallots ensures that there are no stale ballots left on the chain.
func (r *E2ERunner) EnsureNoStaleBallots() {
// TODO: fix
//https://github.com/zeta-chain/node/issues/3626
//ballotsRes, err := r.ObserverClient.Ballots(r.Ctx, &types.QueryBallotsRequest{})
//require.NoError(r, err)
//currentBlockHeight, err := r.Clients.Zetacore.GetBlockHeight(r.Ctx)
//require.NoError(r, err)
//emissionsParams, err := r.EmissionsClient.Params(r.Ctx, &emissionstypes.QueryParamsRequest{})
//require.NoError(r, err)
//staleBlockStart := currentBlockHeight - emissionsParams.Params.BallotMaturityBlocks
//if len(ballotsRes.Ballots) < 1 {
// return
//}
//firstBallotCreationHeight := ballotsRes.Ballots[0].BallotCreationHeight
//require.GreaterOrEqual(r, firstBallotCreationHeight, staleBlockStart, "there should be no stale ballots")
ballotsRes, err := r.ObserverClient.Ballots(r.Ctx, &types.QueryBallotsRequest{})
require.NoError(r, err)
currentBlockHeight, err := r.Clients.Zetacore.GetBlockHeight(r.Ctx)
require.NoError(r, err)
emissionsParams, err := r.EmissionsClient.Params(r.Ctx, &emissionstypes.QueryParamsRequest{})
require.NoError(r, err)
staleBlockStart := currentBlockHeight - emissionsParams.Params.BallotMaturityBlocks
if len(ballotsRes.Ballots) < 1 {
return
}
firstBallotCreationHeight := int64(0)

for _, ballot := range ballotsRes.Ballots {
if ballot.IsFinalized() {
firstBallotCreationHeight = ballot.BallotCreationHeight
break
}
}

if firstBallotCreationHeight == 0 {
return
}
require.GreaterOrEqual(r, firstBallotCreationHeight, staleBlockStart, "there should be no stale ballots")
}