Skip to content

Commit

Permalink
tests for vote receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-av committed Jul 25, 2024
1 parent 127a5ae commit e307ef0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/av_client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export type BoardItem =
VoterSessionItem |
VoterCommitmentItem |
BoardCommitmentItem |
BallotCryptogramItem
BallotCryptogramItem |
CastRequestItem

export type BoardItemType =
"BallotCryptogramsItem" |
Expand Down Expand Up @@ -190,6 +191,10 @@ export interface SpoilRequestItem extends BaseBoardItem {
type: "SpoilRequestItem"
}

export interface CastRequestItem extends BaseBoardItem {
type: "CastRequestItem"
}

export interface CommitmentOpening {
randomizers: ContestMap<string[][]>
commitmentRandomness: string
Expand Down
21 changes: 21 additions & 0 deletions test/generate_receipt.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {expect} from 'chai';
import {generateReceipt} from '../lib/av_client/generate_receipt';
import {CastRequestItem} from '../lib/av_client/types';
import {baseItemAttributes} from "./fixtures/itemHelper";

const castRequest: CastRequestItem = {
...baseItemAttributes(),
type: 'CastRequestItem'
}

const serverReceipt = "dummy signature string"

describe('generateReceipt', () => {
context('when given a valid arguments', () => {
it('constructs a vote receipt', async () => {
const voteReceipt = generateReceipt(serverReceipt, castRequest)
expect(voteReceipt).to.have.keys('trackingCode', 'receipt')
expect(voteReceipt.receipt).to.have.keys('address', 'parentAddress', 'previousAddress', 'registeredAt', 'dbbSignature', 'voterSignature')
})
})
})

0 comments on commit e307ef0

Please sign in to comment.