@ledgerhq/coin-casper
Version:
Ledger Casper integration
53 lines • 2.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const abandonseed_1 = require("@ledgerhq/cryptoassets/abandonseed");
const _1 = require(".");
const config_1 = require("../config");
const pubkey = "0202664e3958608cd8dc2b80d4c73f18f76ef197f1cccca2f4f817c70bb050b248bd";
const pubkeyAbandon = (0, abandonseed_1.getAbandonSeedAddress)("casper");
jest.mock("../config");
describe("Casper API", () => {
jest.mocked(config_1.getCoinConfig).mockReturnValue({
...{},
infra: {
API_CASPER_NODE_ENDPOINT: "https://casper.coin.ledger.com/node/",
API_CASPER_INDEXER: "https://casper.coin.ledger.com/indexer/",
},
});
it("should be able to fetch the network status", async () => {
const blockHeight = await (0, _1.fetchBlockHeight)();
expect(blockHeight).toBeDefined();
});
it("shouldnt fetch account state info if account doesnt exist", async () => {
const accountStateInfo = await (0, _1.fetchAccountStateInfo)(pubkeyAbandon);
expect(accountStateInfo).toEqual({
purseUref: undefined,
accountHash: undefined,
});
});
it("should fetch account state info if account exists", async () => {
const accountStateInfo = await (0, _1.fetchAccountStateInfo)(pubkey);
expect(accountStateInfo.purseUref).toBeDefined();
expect(accountStateInfo.accountHash).toBeDefined();
});
it("should fetch balance", async () => {
const accountStateInfo = await (0, _1.fetchAccountStateInfo)(pubkey);
expect(accountStateInfo.purseUref).toBeDefined();
if (!accountStateInfo.purseUref) {
throw new Error("Purse Uref is undefined");
}
const balance = await (0, _1.fetchBalance)(accountStateInfo.purseUref);
expect(balance).toBeDefined();
});
it("should fetch txs", async () => {
const txs = await (0, _1.fetchTxs)(pubkey);
expect(txs).toBeDefined();
expect(txs.length).toBeGreaterThan(0);
});
it("should fetch txs for abandon seed address", async () => {
const txs = await (0, _1.fetchTxs)(pubkeyAbandon);
expect(txs).toBeDefined();
expect(txs.length).toBe(0);
});
});
//# sourceMappingURL=index.integ.test.js.map