Skip to content

Commit

Permalink
add: maybe tests a bit more correct
Browse files Browse the repository at this point in the history
  • Loading branch information
borislav-itskov committed Sep 18, 2023
1 parent 7474b82 commit d272260
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 5 additions & 3 deletions tests/schnorrkel/multiSigSign.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand Down
6 changes: 2 additions & 4 deletions tests/schnorrkel/onchainMultiSign.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
}
Expand Down

0 comments on commit d272260

Please sign in to comment.