@helium/http
Version:
HTTP library for interacting with the Helium blockchain API
81 lines • 3.95 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const currency_1 = require("@helium/currency");
const address_1 = require("@helium/address");
const Account_1 = __importDefault(require("../Account"));
const Client_1 = __importDefault(require("../../Client"));
const ECC_COMPACT_ADDRESS = '112qB3YaH5bZkCnKA5uRH7tBtGNv2Y5B4smv1jsmvGUzgKT71QpE';
const TESTNET_ADDRESS = '1bijtibPhc16wx4oJbyK8vtkAgdoRoaUvJeo7rXBnBCufEYakfd';
describe('balances', () => {
it('returns a Balance', () => {
var _a, _b, _c, _d, _e, _f;
const client = new Client_1.default();
const account = new Account_1.default(client, {
speculative_nonce: 1,
staked_balance: 100,
sec_nonce: 1,
sec_balance: 1,
nonce: 1,
dc_balance: 1,
dc_nonce: 1,
block: 1,
balance: 1,
address: ECC_COMPACT_ADDRESS,
hotspot_count: 650,
validator_count: 10,
});
expect((_a = account.balance) === null || _a === void 0 ? void 0 : _a.integerBalance).toBe(1);
expect((_c = (_b = account.balance) === null || _b === void 0 ? void 0 : _b.type) === null || _c === void 0 ? void 0 : _c.ticker).toBe(currency_1.CurrencyType.networkToken.ticker);
expect(account.netType).toBe(address_1.NetTypes.MAINNET);
expect((_d = account.secBalance) === null || _d === void 0 ? void 0 : _d.integerBalance).toBe(1);
expect((_e = account.dcBalance) === null || _e === void 0 ? void 0 : _e.integerBalance).toBe(1);
expect((_f = account.stakedBalance) === null || _f === void 0 ? void 0 : _f.integerBalance).toBe(100);
expect(account.hotspotCount).toBe(650);
expect(account.validatorCount).toBe(10);
});
it('returns a testnet Balance', () => {
var _a, _b, _c, _d, _e, _f;
const client = new Client_1.default();
const account = new Account_1.default(client, {
speculative_nonce: 1,
staked_balance: 100,
sec_nonce: 1,
sec_balance: 1,
nonce: 1,
dc_balance: 1,
dc_nonce: 1,
block: 1,
balance: 1,
address: TESTNET_ADDRESS,
});
expect((_a = account.balance) === null || _a === void 0 ? void 0 : _a.integerBalance).toBe(1);
expect((_c = (_b = account.balance) === null || _b === void 0 ? void 0 : _b.type) === null || _c === void 0 ? void 0 : _c.ticker).toBe(currency_1.CurrencyType.testNetworkToken.ticker);
expect(account.netType).toBe(address_1.NetTypes.TESTNET);
expect((_d = account.secBalance) === null || _d === void 0 ? void 0 : _d.integerBalance).toBe(1);
expect((_e = account.dcBalance) === null || _e === void 0 ? void 0 : _e.integerBalance).toBe(1);
expect((_f = account.stakedBalance) === null || _f === void 0 ? void 0 : _f.integerBalance).toBe(100);
});
it('still returns a balance even if it is 0', () => {
var _a, _b, _c;
const client = new Client_1.default();
const account = new Account_1.default(client, {
speculative_nonce: 1,
staked_balance: 100,
sec_nonce: 1,
sec_balance: 0,
nonce: 1,
dc_balance: 0,
dc_nonce: 1,
block: 1,
balance: 0,
address: ECC_COMPACT_ADDRESS,
});
expect((_a = account.balance) === null || _a === void 0 ? void 0 : _a.integerBalance).toBe(0);
expect((_b = account.secBalance) === null || _b === void 0 ? void 0 : _b.integerBalance).toBe(0);
expect((_c = account.dcBalance) === null || _c === void 0 ? void 0 : _c.integerBalance).toBe(0);
});
});
//# sourceMappingURL=Account.spec.js.map