UNPKG

machinomy

Version:

Micropayments powered by Ethereum

39 lines 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const support = require("../support"); const ChannelId_1 = require("../ChannelId"); const PaymentChannel_1 = require("../PaymentChannel"); const BigNumber = require("bignumber.js"); const expect = require("expect"); const tmpStorage_1 = require("../util/tmpStorage"); describe('TokensDatabase', () => { let tokens; let channels; const inflator = {}; beforeEach(async () => { const storage = await tmpStorage_1.tmpStorage(inflator); tokens = storage.tokensDatabase; channels = storage.channelsDatabase; }); describe('#isPresent', () => { it('check if non-existent token is absent', () => { const randomToken = support.randomInteger().toString(); return tokens.isPresent(randomToken).then((isPresent) => { expect(isPresent).toBeFalsy(); }); }); it('check if existing token is present', () => { const randomToken = support.randomInteger().toString(); const channelId = ChannelId_1.default.random(); return channels.save(new PaymentChannel_1.PaymentChannel('sender', 'receiver', channelId.toString(), new BigNumber.BigNumber(10), new BigNumber.BigNumber(0), undefined, '')) .then(() => { return tokens.save(randomToken, channelId).then(() => { return tokens.isPresent(randomToken); }).then((isPresent) => { expect(isPresent).toBeTruthy(); }); }); }); }); }); //# sourceMappingURL=TokensDatabase.test.js.map