@ledgerhq/coin-tron
Version:
Ledger Tron Coin integration
67 lines • 2.75 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require(".");
const config_1 = __importDefault(require("../config"));
const fetchTronAccountTxs_fixture_json_1 = __importDefault(require("./fixtures/fetchTronAccountTxs.fixture.json"));
/**
* Tests used to help to develop and debug. Can't be reliable for the CI.
*/
describe("TronGrid", () => {
const address = "TY2ksFgpvb82TgGPwUSa7iseqPW5weYQyh";
beforeAll(() => {
config_1.default.setCoinConfig(() => ({
status: {
type: "active",
},
explorer: {
url: "https://tron.coin.ledger.com",
},
}));
});
describe("fetchTronAccountTxs", () => {
it("maps all fields correctly", async () => {
// WHEN
const results = await (0, _1.fetchTronAccountTxs)(address, txs => txs.length < 100, {});
// THEN
expect(results).not.toHaveLength(0);
}, 10 * 1000);
});
describe("fetchTronAccount", () => {
it("retrieves exactly one element", async () => {
const result = await (0, _1.fetchTronAccount)(address);
expect(result).toHaveLength(1);
expect(result[0]).toHaveProperty("balance");
});
});
describe("getTronAccountNetwork", () => {
it("works", async () => {
const result = await (0, _1.getTronAccountNetwork)(address);
expect(result.family).toEqual("tron");
for (const p of [
"freeNetUsed",
"freeNetLimit",
"netUsed",
"netLimit",
"energyUsed",
"energyLimit",
]) {
expect(result).toHaveProperty(p);
}
});
});
describe("fetchTronTxDetail", () => {
it("retrieves details for a transaction", async () => {
const elts = await fetchTronAccountTxs_fixture_json_1.default.TL24LCps5FKwp3PoU1MvrYrwhi5LU1tHre["428XjpfuumKvTadJgnfch1qNene43UrokeHgYu1CauQWzY8x1JTvnfoGTGYrt8M2giksdRcDPRBCQbYPdQHDqfzKJkoYpHJNZtZgNi4UW2RVF4YQ2Dk52RKuFD4utVXCUQjLE425frExMYWyDNNvb4tU3QP9i57WaAManuaFucAZGhq16q5oSXi7CX1NnrToboCQqpgWhUS8KXNi96DmrG9i99tNgxpHKML"].data;
const txInfo = {};
for (const { txID } of elts) {
const result = await (0, _1.fetchTronTxDetail)(txID);
Object.assign(txInfo, { [txID]: result });
}
expect(Object.keys(txInfo).length).toEqual(5);
});
});
});
//# sourceMappingURL=index.integ.test.js.map