Skip to content

Commit

Permalink
Merge pull request #1 from MaximeZmt/Work-Mzmt-RefactorEvotingMod_Test
Browse files Browse the repository at this point in the history
Change some error checking method
  • Loading branch information
MaximeZmt authored Feb 27, 2024
2 parents c819e31 + 7998bd6 commit 036084d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions contracts/evoting/mod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ func TestCommand_CastVote(t *testing.T) {
require.EqualError(t, err, unmarshalTransactionErr)

err = cmd.castVote(fake.NewBadSnapshot(), makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), "failed to get key")
require.ErrorContains(t, err, "failed to get key")

snap := fake.NewSnapshot()

err = snap.Set(dummyFormIDBuff, invalidForm)
require.NoError(t, err)

err = cmd.castVote(snap, makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), deserializeErr)
require.ErrorContains(t, err, deserializeErr)

err = snap.Set(dummyFormIDBuff, formBuf)
require.NoError(t, err)
Expand Down Expand Up @@ -330,15 +330,15 @@ func TestCommand_CloseForm(t *testing.T) {
require.EqualError(t, err, unmarshalTransactionErr)

err = cmd.closeForm(fake.NewBadSnapshot(), makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), "failed to get key")
require.ErrorContains(t, err, "failed to get key")

snap := fake.NewSnapshot()

err = snap.Set(dummyFormIDBuff, invalidForm)
require.NoError(t, err)

err = cmd.closeForm(snap, makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), deserializeErr)
require.ErrorContains(t, err, deserializeErr)

err = snap.Set(dummyFormIDBuff, formBuf)
require.NoError(t, err)
Expand Down Expand Up @@ -533,7 +533,7 @@ func TestCommand_ShuffleBallotsFormatErrors(t *testing.T) {
require.EqualError(t, err, unmarshalTransactionErr)

err = cmd.shuffleBallots(fake.NewBadSnapshot(), makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), "failed to get key")
require.ErrorContains(t, err, "failed to get key")

// Wrong form id format
snap := fake.NewSnapshot()
Expand All @@ -542,7 +542,7 @@ func TestCommand_ShuffleBallotsFormatErrors(t *testing.T) {
require.NoError(t, err)

err = cmd.shuffleBallots(snap, makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), deserializeErr)
require.ErrorContains(t, err, deserializeErr)

// Form not closed
err = snap.Set(dummyFormIDBuff, formBuf)
Expand Down Expand Up @@ -759,15 +759,15 @@ func TestCommand_RegisterPubShares(t *testing.T) {
require.EqualError(t, err, unmarshalTransactionErr)

err = cmd.registerPubshares(fake.NewBadSnapshot(), makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), "failed to get key")
require.ErrorContains(t, err, "failed to get key")

snap := fake.NewSnapshot()

err = snap.Set(dummyFormIDBuff, invalidForm)
require.NoError(t, err)

err = cmd.registerPubshares(snap, makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), deserializeErr)
require.ErrorContains(t, err, deserializeErr)

err = snap.Set(dummyFormIDBuff, formBuf)
require.NoError(t, err)
Expand Down Expand Up @@ -960,15 +960,15 @@ func TestCommand_DecryptBallots(t *testing.T) {
require.EqualError(t, err, unmarshalTransactionErr)

err = cmd.combineShares(fake.NewBadSnapshot(), makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), "failed to get key")
require.ErrorContains(t, err, "failed to get key")

snap := fake.NewSnapshot()

err = snap.Set(dummyFormIDBuff, invalidForm)
require.NoError(t, err)

err = cmd.combineShares(snap, makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), deserializeErr)
require.ErrorContains(t, err, deserializeErr)

err = snap.Set(dummyFormIDBuff, formBuf)
require.NoError(t, err)
Expand Down Expand Up @@ -1060,15 +1060,15 @@ func TestCommand_CancelForm(t *testing.T) {
require.EqualError(t, err, unmarshalTransactionErr)

err = cmd.cancelForm(fake.NewBadSnapshot(), makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), "failed to get key")
require.ErrorContains(t, err, "failed to get key")

snap := fake.NewSnapshot()

err = snap.Set(dummyFormIDBuff, invalidForm)
require.NoError(t, err)

err = cmd.cancelForm(snap, makeStep(t, FormArg, string(data)))
require.Contains(t, err.Error(), deserializeErr)
require.ErrorContains(t, err, deserializeErr)

err = snap.Set(dummyFormIDBuff, formBuf)
require.NoError(t, err)
Expand Down

0 comments on commit 036084d

Please sign in to comment.