@@ -14,10 +14,12 @@ import (
14
14
"go.dedis.ch/dela/core/validation"
15
15
"golang.org/x/xerrors"
16
16
17
+ "github.com/dedis/d-voting/contracts/evoting"
17
18
etypes "github.com/dedis/d-voting/contracts/evoting/types"
18
19
"github.com/dedis/d-voting/internal/testing/fake"
19
20
"github.com/dedis/d-voting/services/dkg"
20
21
"github.com/dedis/d-voting/services/dkg/pedersen/types"
22
+ "github.com/prometheus/client_golang/prometheus/testutil"
21
23
"github.com/stretchr/testify/require"
22
24
"go.dedis.ch/dela/core/ordering/cosipbft/authority"
23
25
"go.dedis.ch/dela/core/store/kv"
@@ -301,6 +303,8 @@ func TestPedersen_TwoListens(t *testing.T) {
301
303
}
302
304
303
305
func TestPedersen_Setup (t * testing.T ) {
306
+ initMetrics ()
307
+
304
308
electionID := "d3adbeef"
305
309
306
310
service := fake .NewService (electionID , etypes.Election {
@@ -325,6 +329,7 @@ func TestPedersen_Setup(t *testing.T) {
325
329
326
330
_ , err := actor .Setup ()
327
331
require .EqualError (t , err , "failed to get election: election does not exist: <nil>" )
332
+ require .Equal (t , float64 (dkg .Failed ), testutil .ToFloat64 (evoting .PromElectionDkgStatus ))
328
333
329
334
actor .electionID = electionID
330
335
@@ -333,6 +338,7 @@ func TestPedersen_Setup(t *testing.T) {
333
338
334
339
_ , err = actor .Setup ()
335
340
require .EqualError (t , err , fake .Err ("failed to stream" ))
341
+ require .Equal (t , float64 (dkg .Failed ), testutil .ToFloat64 (evoting .PromElectionDkgStatus ))
336
342
337
343
// RPC is bogus 2
338
344
actor .rpc = fake .NewRPC ()
@@ -396,6 +402,7 @@ func TestPedersen_Setup(t *testing.T) {
396
402
// We test that particular behaviour later.
397
403
_ , err = actor .Setup ()
398
404
require .NoError (t , err )
405
+ require .Equal (t , float64 (dkg .Setup ), testutil .ToFloat64 (evoting .PromElectionDkgStatus ))
399
406
}
400
407
401
408
func TestPedersen_GetPublicKey (t * testing.T ) {
@@ -623,6 +630,10 @@ func TestPedersen_ComputePubshares_OK(t *testing.T) {
623
630
// -----------------------------------------------------------------------------
624
631
// Utility functions
625
632
633
+ func initMetrics () {
634
+ evoting .PromElectionDkgStatus .Reset ()
635
+ }
636
+
626
637
// actorsEqual checks that two actors hold the same data
627
638
func requireActorsEqual (t require.TestingT , actor1 , actor2 dkg.Actor ) {
628
639
actor1Data , err := actor1 .MarshalJSON ()
0 commit comments