diff --git a/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/Decryption/CiphertextDecryptionTally.cs b/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/Decryption/CiphertextDecryptionTally.cs index d7123e28e..60991b7ee 100644 --- a/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/Decryption/CiphertextDecryptionTally.cs +++ b/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/Decryption/CiphertextDecryptionTally.cs @@ -116,12 +116,12 @@ public void AddSpoiledBallot(CiphertextBallot ballot) { if (!_tally.HasBallot(ballot.ObjectId)) { - throw new ArgumentException("Tally does not contain ballot"); + throw new ArgumentException($"Tally does not contain ballot {ballot.ObjectId}"); } if (!ballot.IsSpoiled) { - throw new ArgumentException("Cannot add unspoiled ballot"); + throw new ArgumentException($"Cannot add unspoiled ballot {ballot.ObjectId} {ballot.State}"); } if (!_spoiledBallots.ContainsKey(ballot.ObjectId)) @@ -146,18 +146,18 @@ public void AddBallotShare( { if (!_tally.HasBallot(ballot.ObjectId)) { - throw new ArgumentException("Tally does not contain ballot"); + throw new ArgumentException($"Tally {_tally.TallyId} does not contain ballot {ballot.ObjectId}"); } if (ballot.IsSpoiled) { - throw new ArgumentException("Cannot decrypt spoiled ballot"); + throw new ArgumentException($"Cannot decrypt spoiled ballot {ballot.ObjectId}"); } if (!ballotShare.IsValid( ballot, guardian, _tally.Context.CryptoExtendedBaseHash)) { - throw new ArgumentException("Invalid ballot share"); + throw new ArgumentException($"Invalid ballot share {ballotShare.TallyId}-{ballotShare.GuardianId}"); } AddGuardian(guardian); diff --git a/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/DecryptionMediator.cs b/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/DecryptionMediator.cs index ab16a7b80..02c330452 100644 --- a/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/DecryptionMediator.cs +++ b/bindings/netstandard/ElectionGuard/ElectionGuard.Decryption/DecryptionMediator.cs @@ -149,7 +149,8 @@ List ballots SubmitShare(shares.TallyShare); if (ballots.Count > 0) { - SubmitShares(shares.BallotShares.Values.Select(i => new BallotShare(i)).ToList(), + SubmitShares( + shares.BallotShares.Values.Select(i => new BallotShare(i)).ToList(), ballots.Select(i => new CiphertextBallot(i)).ToList()); } } @@ -303,12 +304,12 @@ private void EnsureCiphertextDecryptionTally(TallyShare share) { if (!Tallies.ContainsKey(share.TallyId)) { - throw new ArgumentException("Tally does not exist"); + throw new ArgumentException($"Tally does not exist {share.TallyId}"); } if (!Guardians.ContainsKey(share.GuardianId)) { - throw new ArgumentException("Guardian does not exist"); + throw new ArgumentException($"Guardian does not exist {share.GuardianId}"); } if (!TallyDecryptions.ContainsKey(share.TallyId)) diff --git a/src/electionguard-ui/ElectionGuard.UI/ViewModels/BallotUploadViewModel.cs b/src/electionguard-ui/ElectionGuard.UI/ViewModels/BallotUploadViewModel.cs index f91dbb7e7..9dc9d3399 100644 --- a/src/electionguard-ui/ElectionGuard.UI/ViewModels/BallotUploadViewModel.cs +++ b/src/electionguard-ui/ElectionGuard.UI/ViewModels/BallotUploadViewModel.cs @@ -237,14 +237,17 @@ await Parallel.ForEachAsync(ballots, async (currentBallot, cancellationToken) => ResultsText = $"{AppResources.SuccessText} {totalCount} {AppResources.Success2Text}"; ShowPanel = BallotUploadPanel.Results; - var record = new CiphertextTallyRecord() + if ( totalSpoiled + totalChallenged + totalImported > 0 ) { - ElectionId = ElectionId, - UploadId = upload.UploadId!, - IsExportable = false, - CiphertextTallyData = ciphertextTally.ToJson() - }; - _ = await _ciphertextTallyService.SaveAsync(record); + var record = new CiphertextTallyRecord() + { + ElectionId = ElectionId, + UploadId = upload.UploadId!, + IsExportable = false, + CiphertextTallyData = ciphertextTally.ToJson() + }; + _ = await _ciphertextTallyService.SaveAsync(record); + } } catch (Exception) {