Skip to content

Commit 909e35f

Browse files
vibhavgobitgobot
authored andcommitted
refactor(sdk-core): use executeTillRound in round-3 verify test
Replace the manual initDsg/getFirstMessage/handleIncomingMessages handshake in the verifyPeerMessageRoundThree happy-path test with MPSUtil.executeTillRound(2, ...) from @bitgo/sdk-lib-mpc, which already drives two DSG parties to the requested round and is used for the same purpose in sdk-lib-mpc's own DSG tests. This removes duplicated round1/round2 handshake code from the test so it exercises only what verifyPeerMessageRoundThree needs, matching the existing helper pattern instead of re-deriving it inline. Ticket: WCI-1191 Session-Id: 0716649e-75cb-46dd-8d6a-ae0a701167d6 Task-Id: 3a82317d-853d-4878-97a8-50cf6fa938c5
1 parent 89afad6 commit 909e35f

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

modules/sdk-core/test/unit/bitgo/utils/tss/eddsa/eddsaMPCv2.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -348,22 +348,15 @@ describe('EdDSA MPS DSG helper functions', async () => {
348348

349349
it('verifyPeerMessageRoundThree should verify a valid BitGo round-3 message', async () => {
350350
const messageBuffer = Buffer.from(signableHex, 'hex');
351-
const userDsg = new EddsaMPSDsg.DSG(MPCv2PartiesEnum.USER);
352-
await userDsg.initDsg(userKeyShare, messageBuffer, derivationPath, MPCv2PartiesEnum.BITGO);
353-
const userMsg1 = userDsg.getFirstMessage();
354-
355-
const bitgoDsg = new EddsaMPSDsg.DSG(MPCv2PartiesEnum.BITGO);
356-
await bitgoDsg.initDsg(bitgoKeyShare, messageBuffer, derivationPath, MPCv2PartiesEnum.USER);
357-
const bitgoMsg1 = bitgoDsg.getFirstMessage();
358-
359-
const [bitgoMsg2] = bitgoDsg.handleIncomingMessages([bitgoMsg1, userMsg1]);
360-
const bitgoSignedMsg1 = await MPSComms.detachSignMpsMessage(Buffer.from(bitgoMsg1.payload), bitgoGpgPrivKey);
361-
const bitgoDeserializedMsg1 = await verifyPeerMessageRoundOne(
362-
{ type: 'round1Output', data: { msg1: bitgoSignedMsg1 } },
363-
bitgoGpgPubKey
364-
);
365-
const [userMsg2] = userDsg.handleIncomingMessages([userMsg1, bitgoDeserializedMsg1]);
366-
const [bitgoMsg3] = bitgoDsg.handleIncomingMessages([bitgoMsg2, userMsg2]);
351+
const [, [bitgoMsg3]] = (await MPSUtil.executeTillRound(
352+
2,
353+
new EddsaMPSDsg.DSG(MPCv2PartiesEnum.USER),
354+
new EddsaMPSDsg.DSG(MPCv2PartiesEnum.BITGO),
355+
userKeyShare,
356+
bitgoKeyShare,
357+
messageBuffer,
358+
derivationPath
359+
)) as MPSTypes.DeserializedMessages[];
367360
const bitgoSignedMsg3 = await MPSComms.detachSignMpsMessage(Buffer.from(bitgoMsg3.payload), bitgoGpgPrivKey);
368361

369362
const round3Output = {

0 commit comments

Comments
 (0)