1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

fix previously not running tests

This commit is contained in:
Matthias Kretschmann 2020-09-03 12:52:55 +02:00
parent 31bec3c7af
commit 1c60e11555
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -1,22 +1,22 @@
import { assert, expect, spy, use } from 'chai' import { assert, expect, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import Web3 from 'web3' import Web3 from 'web3'
import config from '../../config' import { SignatureUtils } from '../../../../src/ocean/utils/SignatureUtils'
import { Logger } from '../../../../src/utils'
import { Ocean } from '../../../../src/ocean/Ocean'
use(spies) use(spies)
const web3 = new Web3('http://127.0.0.1:8545')
describe('SignatureUtils', () => { describe('SignatureUtils', () => {
const publicKey = `0x${'a'.repeat(40)}` const publicKey = `0x${'a'.repeat(40)}`
const text = '0123456789abcde' const text = '0123456789abcde'
const signature = `0x${'a'.repeat(130)}` const signature = `0x${'a'.repeat(130)}`
let web3: Web3
let ocean: Ocean let signatureUtils: SignatureUtils
before(async () => { before(async () => {
ocean = await Ocean.getInstance(config) signatureUtils = new SignatureUtils(web3, new Logger())
web3 = (ocean as any).web3
}) })
afterEach(() => { afterEach(() => {
@ -31,14 +31,14 @@ describe('SignatureUtils', () => {
}) })
it('should sign a text as expected', async () => { it('should sign a text as expected', async () => {
const signed = await ocean.utils.signature.signText(text, publicKey) const signed = await signatureUtils.signText(text, publicKey)
assert.equal(signed, signature) assert.equal(signed, signature)
expect(personalSignSpy).to.have.been.called.with(text, publicKey) expect(personalSignSpy).to.have.been.called.with(text, publicKey)
}) })
it('should sign a text as expected using password', async () => { it('should sign a text as expected using password', async () => {
const signed = await ocean.utils.signature.signText(text, publicKey, 'test') const signed = await signatureUtils.signText(text, publicKey, 'test')
assert.equal(signed, signature) assert.equal(signed, signature)
expect(personalSignSpy).to.have.been.called.with(text, publicKey, 'test') expect(personalSignSpy).to.have.been.called.with(text, publicKey, 'test')
@ -49,7 +49,7 @@ describe('SignatureUtils', () => {
it('should recover the privateKey of a signed message', async () => { it('should recover the privateKey of a signed message', async () => {
const personalRecoverSpy = spy.on(web3.eth.personal, 'ecRecover', () => publicKey) const personalRecoverSpy = spy.on(web3.eth.personal, 'ecRecover', () => publicKey)
const verifiedPublicKey = await ocean.utils.signature.verifyText(text, signature) const verifiedPublicKey = await signatureUtils.verifyText(text, signature)
assert.equal(publicKey, verifiedPublicKey) assert.equal(publicKey, verifiedPublicKey)
expect(personalRecoverSpy).to.have.been.called.with(text, signature) expect(personalRecoverSpy).to.have.been.called.with(text, signature)