UNPKG

machinomy

Version:

Micropayments powered by Ethereum

29 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const sinon = require("sinon"); const ChainManager_1 = require("./ChainManager"); const Signature_1 = require("./Signature"); const expect = require("expect"); describe('ChainManager', () => { const SIGNATURE = '0xd8a923b39ae82bb39d3b64d58f06e1d776bcbcae34e5b4a6f4a952e8892e6a5b4c0f88833c06fe91729057035161e599fda536e8ce0ab4be2c214d6ea961e93a01'; const ADDRESS = '0xaddr'; const DATA = 'some data'; let web3; let manager; beforeEach(() => { web3 = {}; manager = new ChainManager_1.default(web3); }); describe('sign', () => { it('should sign the data with the address\'s private key', async () => { web3.eth = { sign: sinon.stub().withArgs(ADDRESS, DATA, sinon.match.func).callsFake((addr, data, cb) => { cb(null, SIGNATURE); }) }; let signature = await manager.sign(ADDRESS, DATA); expect(signature).toEqual(new Signature_1.default(SIGNATURE)); }); }); }); //# sourceMappingURL=ChainManager.test.js.map