@@ -11,6 +11,8 @@ import (
11
11
12
12
"github.com/zeta-chain/node/testutil/sample"
13
13
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types"
14
+ emissionstypes "github.com/zeta-chain/node/x/emissions/types"
15
+ "github.com/zeta-chain/node/x/observer/types"
14
16
)
15
17
16
18
// EnsureNoTrackers ensures that there are no trackers left on zetacore
@@ -62,18 +64,27 @@ func ensureZRC20ZeroBalance(r *E2ERunner, zrc20 *zrc20.ZRC20, address ethcommon.
62
64
63
65
// EnsureNoStaleBallots ensures that there are no stale ballots left on the chain.
64
66
func (r * E2ERunner ) EnsureNoStaleBallots () {
65
- // TODO: fix
66
- //https://github.com/zeta-chain/node/issues/3626
67
- //ballotsRes, err := r.ObserverClient.Ballots(r.Ctx, &types.QueryBallotsRequest{})
68
- //require.NoError(r, err)
69
- //currentBlockHeight, err := r.Clients.Zetacore.GetBlockHeight(r.Ctx)
70
- //require.NoError(r, err)
71
- //emissionsParams, err := r.EmissionsClient.Params(r.Ctx, &emissionstypes.QueryParamsRequest{})
72
- //require.NoError(r, err)
73
- //staleBlockStart := currentBlockHeight - emissionsParams.Params.BallotMaturityBlocks
74
- //if len(ballotsRes.Ballots) < 1 {
75
- // return
76
- //}
77
- //firstBallotCreationHeight := ballotsRes.Ballots[0].BallotCreationHeight
78
- //require.GreaterOrEqual(r, firstBallotCreationHeight, staleBlockStart, "there should be no stale ballots")
67
+ ballotsRes , err := r .ObserverClient .Ballots (r .Ctx , & types.QueryBallotsRequest {})
68
+ require .NoError (r , err )
69
+ currentBlockHeight , err := r .Clients .Zetacore .GetBlockHeight (r .Ctx )
70
+ require .NoError (r , err )
71
+ emissionsParams , err := r .EmissionsClient .Params (r .Ctx , & emissionstypes.QueryParamsRequest {})
72
+ require .NoError (r , err )
73
+ staleBlockStart := currentBlockHeight - emissionsParams .Params .BallotMaturityBlocks
74
+ if len (ballotsRes .Ballots ) < 1 {
75
+ return
76
+ }
77
+ firstBallotCreationHeight := int64 (0 )
78
+
79
+ for _ , ballot := range ballotsRes .Ballots {
80
+ if ballot .IsFinalized () {
81
+ firstBallotCreationHeight = ballot .BallotCreationHeight
82
+ break
83
+ }
84
+ }
85
+
86
+ if firstBallotCreationHeight == 0 {
87
+ return
88
+ }
89
+ require .GreaterOrEqual (r , firstBallotCreationHeight , staleBlockStart , "there should be no stale ballots" )
79
90
}
0 commit comments