@ledgerhq/coin-tezos
Version:
86 lines • 3.25 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const rpc_1 = require("@taquito/rpc");
const _1 = require(".");
const config_1 = __importDefault(require("../config"));
const config_2 = require("../test/config");
/**
* https://teztnets.com/ghostnet-about
* https://api.tzkt.io/#section/Get-Started/Free-TzKT-API
*/
describe("Tezos Api", () => {
const address = "tz1heMGVHQnx7ALDcDKqez8fan64Eyicw4DJ";
beforeAll(() => {
config_1.default.setCoinConfig(() => config_2.mockConfig);
});
it("should craft a send transaction", async () => {
// When
const result = await (0, _1.craftTransaction)({ address }, {
type: "send",
recipient: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9", // spell-checker: disable-line
amount: BigInt(10),
fee: { fees: BigInt(1).toString() },
});
// Then
expect(result.type).toBe("OUT");
expect(result.contents).toEqual(expect.objectContaining([
{
kind: rpc_1.OpKind.TRANSACTION,
amount: "10",
destination: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
source: address,
counter: expect.any(String),
fee: "1",
gas_limit: "0",
storage_limit: "0",
},
]));
});
it("should craft a delegate transaction", async () => {
// When
const result = await (0, _1.craftTransaction)({ address }, {
type: "delegate",
recipient: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9", // spell-checker: disable-line
amount: BigInt(10),
fee: { fees: BigInt(1).toString(), gasLimit: "200", storageLimit: "300" },
});
// Then
expect(result.type).toBe("DELEGATE");
expect(result.contents).toEqual(expect.objectContaining([
{
kind: rpc_1.OpKind.DELEGATION,
source: address,
counter: expect.any(String),
delegate: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
fee: "1",
gas_limit: "200",
storage_limit: "300",
},
]));
});
it("should craft a undelegate transaction", async () => {
// When
const result = await (0, _1.craftTransaction)({ address }, {
type: "undelegate",
recipient: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9", // spell-checker: disable-line
amount: BigInt(10),
fee: { fees: BigInt(1).toString(), gasLimit: "200", storageLimit: "300" },
});
// Then
expect(result.type).toBe("UNDELEGATE");
expect(result.contents).toEqual(expect.objectContaining([
{
kind: rpc_1.OpKind.DELEGATION,
source: address,
counter: expect.any(String),
fee: "1",
gas_limit: "200",
storage_limit: "300",
},
]));
});
});
//# sourceMappingURL=craftTransaction.integ.test.js.map