From d272260a38adc8a172afc3c36f4453ddfab97b0d Mon Sep 17 00:00:00 2001 From: Borislav Itskov Date: Mon, 18 Sep 2023 15:00:42 +0300 Subject: [PATCH] add: maybe tests a bit more correct --- tests/schnorrkel/multiSigSign.test.ts | 8 +++++--- tests/schnorrkel/onchainMultiSign.test.ts | 6 ++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/schnorrkel/multiSigSign.test.ts b/tests/schnorrkel/multiSigSign.test.ts index 0a84848..4501383 100644 --- a/tests/schnorrkel/multiSigSign.test.ts +++ b/tests/schnorrkel/multiSigSign.test.ts @@ -19,7 +19,7 @@ describe('testing multiSigSign', () => { const publicKeys = [keyPairOne.publicKey, keyPairTwo.publicKey] const msg = 'test message' - const signature = schnorrkelOne.multiSigSign(keyPairOne.privateKey, ethers.utils.solidityKeccak256(['string'], [msg]), publicKeys, publicNonces) + const signature = schnorrkelOne.multiSigSign(keyPairOne.privateKey, ethers.utils.hashMessage(msg), publicKeys, publicNonces) expect(signature).toBeDefined() expect(signature.finalPublicNonce.buffer).toHaveLength(33) @@ -33,9 +33,10 @@ describe('testing multiSigSign', () => { const publicNonces = schnorrkel.generatePublicNonces(keyPair.privateKey) const msg = 'test message' + const msgHash = ethers.utils.hashMessage(msg) const publicKeys = [keyPair.publicKey] - expect(() => schnorrkel.multiSigSign(keyPair.privateKey, msg, publicKeys, [publicNonces])).toThrowError('At least 2 public keys should be provided') + expect(() => schnorrkel.multiSigSign(keyPair.privateKey, msgHash, publicKeys, [publicNonces])).toThrowError('At least 2 public keys should be provided') }) it('should requires nonces', () => { @@ -44,9 +45,10 @@ describe('testing multiSigSign', () => { const keyPairTwo = generateRandomKeys() const msg = 'test message' + const msgHash = ethers.utils.hashMessage(msg) const publicKeys = [keyPairOne.publicKey, keyPairTwo.publicKey] - expect(() => schnorrkel.multiSigSign(keyPairOne.privateKey, msg, publicKeys, [])).toThrowError('Nonces should be exchanged before signing') + expect(() => schnorrkel.multiSigSign(keyPairOne.privateKey, msgHash, publicKeys, [])).toThrowError('Nonces should be exchanged before signing') }) it('should generate multi signature by hash', () => { diff --git a/tests/schnorrkel/onchainMultiSign.test.ts b/tests/schnorrkel/onchainMultiSign.test.ts index c56a2b7..564dc70 100644 --- a/tests/schnorrkel/onchainMultiSign.test.ts +++ b/tests/schnorrkel/onchainMultiSign.test.ts @@ -44,8 +44,6 @@ describe('Multi Sign Tests', function () { // the multisig px and parity const px = ethers.utils.hexlify(combinedPublicKey.buffer.slice(1, 33)) - const combinedPublicAddress = '0x' + px.slice(px.length - 40, px.length) - const parity = combinedPublicKey.buffer[0] - 2 + 27 // wrap the result @@ -251,11 +249,11 @@ describe('Multi Sign Tests', function () { expect(e.message).to.equal('At least 2 public keys should be provided') } - const msg = 'just a test message' + const msgHash = ethers.utils.hashMessage('just a test message') const publicKeys = [signerOne.getPublicKey()] const publicNonces = [signerOne.getPublicNonces(), signerTwo.getPublicNonces()] try { - signerOne.multiSignMessage(msg, publicKeys, publicNonces) + signerOne.multiSignMessage(msgHash, publicKeys, publicNonces) } catch (e: any) { expect(e.message).to.equal('At least 2 public keys should be provided') }