Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jun 27, 2023
1 parent 4cb467a commit c2acc61
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/characters/cbd-recipient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,14 @@ export class CbdTDecDecrypter {
variant: number,
expectedRitualId: number
) {
const decryptedResponses = Object.entries(encryptedResponses).map(
([ursula, encryptedResponse]) =>
encryptedResponse.decrypt(sessionSharedSecret[ursula])
const decryptedResponses = Object.entries(sessionSharedSecret).map(
([ursula, sharedSecret]) => {
const encryptedResponse = encryptedResponses[ursula];
if (!encryptedResponse) {
throw new Error(`Missing encrypted response from ${ursula}`);
}
return encryptedResponse.decrypt(sharedSecret);
}
);

const ritualIds = decryptedResponses.map(({ ritualId }) => ritualId);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cbd-strategy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const makeCbdStrategy = async () => {
async function makeDeployedCbdStrategy() {
const strategy = await makeCbdStrategy();

const mockedDkg = fakeDkgFlow(variant, 0);
const mockedDkg = fakeDkgFlow(variant, 0, 4, 4);
const mockedDkgRitual = fakeDkgRitual(mockedDkg, mockedDkg.threshold);
const web3Provider = fakeWeb3Provider(aliceSecretKey.toBEBytes());
const getUrsulasSpy = mockGetUrsulas(ursulas);
Expand Down
10 changes: 6 additions & 4 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ export const mockDetectEthereumProvider = () => {
export const fakeDkgFlow = (
variant: FerveoVariant | FerveoVariant.Precomputed,
ritualId: number,
sharesNum = 4,
threshold = 3
sharesNum: number,
threshold: number
) => {
if (
variant !== FerveoVariant.Simple &&
Expand Down Expand Up @@ -358,9 +358,11 @@ export const fakeDkgTDecFlowE2e = (
variant: FerveoVariant,
message = toBytes('fake-message'),
aad = toBytes('fake-aad'),
ritualId = 0
ritualId = 0,
sharesNum = 4,
threshold = 4
) => {
const ritual = fakeDkgFlow(variant, ritualId, 4, 3);
const ritual = fakeDkgFlow(variant, ritualId, sharesNum, threshold);

// In the meantime, the client creates a ciphertext and decryption request
const ciphertext = ferveoEncrypt(message, aad, ritual.dkg.publicKey());
Expand Down

1 comment on commit c2acc61

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundled size for the package is listed below:

build/module/types/ethers-contracts/factories: 82.03 KB
build/module/types/ethers-contracts: 152.34 KB
build/module/types: 156.25 KB
build/module/test: 42.97 KB
build/module/src/sdk/strategy: 31.25 KB
build/module/src/sdk: 46.88 KB
build/module/src/characters: 89.84 KB
build/module/src/conditions/context: 42.97 KB
build/module/src/conditions/predefined: 19.53 KB
build/module/src/conditions/base: 54.69 KB
build/module/src/conditions: 156.25 KB
build/module/src/agents: 35.16 KB
build/module/src/policies: 19.53 KB
build/module/src/kits: 19.53 KB
build/module/src: 433.59 KB
build/module: 687.50 KB
build/main/types/ethers-contracts/factories: 82.03 KB
build/main/types/ethers-contracts: 152.34 KB
build/main/types: 156.25 KB
build/main/test: 46.88 KB
build/main/src/sdk/strategy: 31.25 KB
build/main/src/sdk: 46.88 KB
build/main/src/characters: 89.84 KB
build/main/src/conditions/context: 42.97 KB
build/main/src/conditions/predefined: 19.53 KB
build/main/src/conditions/base: 54.69 KB
build/main/src/conditions: 156.25 KB
build/main/src/agents: 35.16 KB
build/main/src/policies: 19.53 KB
build/main/src/kits: 19.53 KB
build/main/src: 437.50 KB
build/main: 695.31 KB
build: 1.35 MB

Please sign in to comment.