UNPKG

@helium/http

Version:

HTTP library for interacting with the Helium blockchain API

47 lines 2.56 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Client_1 = __importDefault(require("../../Client")); const Validator_1 = __importDefault(require("../Validator")); const mockHTTPValidator = { version_heartbeat: 10000008, status: { online: 'online', listen_addrs: ['/ip4/11.111.111.111/tcp/2154'], height: 923303 }, stake_status: 'staked', stake: 1000000000000, penalty: 1.123, consensus_groups: 20, penalties: [ { type: 'performance', height: 921773, amount: 0.099 }, { type: 'tenure', height: 921622, amount: 0.5 }, ], owner: 'fake-owner-address', name: 'fake-name', last_heartbeat: 923338, block_added: 123456, block: 923409, address: 'fake-address', }; test('create Hotspot from HTTP response', () => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; const validator = new Validator_1.default(new Client_1.default(), mockHTTPValidator); expect(validator.versionHeartbeat).toBe(10000008); expect((_a = validator.status) === null || _a === void 0 ? void 0 : _a.online).toBe('online'); expect((_c = (_b = validator.status) === null || _b === void 0 ? void 0 : _b.listenAddrs) === null || _c === void 0 ? void 0 : _c[0]).toBe('/ip4/11.111.111.111/tcp/2154'); expect((_d = validator.status) === null || _d === void 0 ? void 0 : _d.height).toBe(923303); expect(validator.stakeStatus).toBe('staked'); expect((_e = validator.stake) === null || _e === void 0 ? void 0 : _e.integerBalance).toBe(1000000000000); expect(validator.penalty).toBe(1.123); expect((_g = (_f = validator.penalties) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.type).toBe('performance'); expect((_j = (_h = validator.penalties) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.height).toBe(921773); expect((_l = (_k = validator.penalties) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.amount).toBe(0.099); expect(validator.owner).toBe('fake-owner-address'); expect(validator.name).toBe('fake-name'); expect(validator.lastHeartbeat).toBe(923338); expect(validator.blockAdded).toBe(123456); expect(validator.block).toBe(923409); expect(validator.address).toBe('fake-address'); expect(validator.consensusGroups).toBe(20); }); //# sourceMappingURL=Validator.spec.js.map