@ledgerhq/coin-aptos
Version:
Ledger Aptos Coin integration
98 lines • 4.29 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
const client_1 = require("@apollo/client");
const validators_1 = require("../../network/validators");
const bignumber_js_1 = __importDefault(require("bignumber.js"));
jest.mock("@aptos-labs/ts-sdk");
let mockedAptos;
jest.mock("@apollo/client");
let mockedApolloClient;
describe("getValidators", () => {
beforeEach(() => {
mockedAptos = jest.mocked(ts_sdk_1.Aptos);
mockedApolloClient = jest.mocked(client_1.ApolloClient);
});
afterAll(() => {
jest.useRealTimers();
});
const current_delegator_balances = [
{
__typename: "current_delegator_balances",
current_pool_balance: {
__typename: "current_delegated_staking_pool_balances",
total_coins: 211045219713562,
operator_commission_percentage: 900,
staking_pool_address: "0x001232f58b963938486a11f88c1c36d61d82738b1828625a95a1e85b4c8d1282",
total_shares: 200020456320587.72,
},
shares: 94692342176,
delegator_address: "0xb1a1d4624c5163445c993d9db9cd5bd3fc6b2c5e85a14216c3781d04d4f92d08",
staking_pool_metadata: {
__typename: "current_staking_pool_voter",
operator_aptos_name: [],
},
},
{
__typename: "current_delegator_balances",
current_pool_balance: {
__typename: "current_delegated_staking_pool_balances",
total_coins: 116781362397133,
operator_commission_percentage: 499,
staking_pool_address: "0x05dece2ed08c68f8730527e9b3ebb3536efc3361f4ef37ba0b16a3310db836af",
total_shares: 115552903623705.77,
},
shares: 15149284011,
delegator_address: "0x4ee1f2b7a1069a09b7d9c800928bfe851bc7649a0fb4e0d918554e0d445db4bc",
staking_pool_metadata: {
__typename: "current_staking_pool_voter",
operator_aptos_name: [
{
__typename: "current_aptos_names",
domain_with_suffix: "cryptomolot.apt",
is_active: true,
},
],
},
},
];
const expectedResponse = [
{
activeStake: (0, bignumber_js_1.default)(211045219713562),
address: "0x001232f58b963938486a11f88c1c36d61d82738b1828625a95a1e85b4c8d1282",
commission: (0, bignumber_js_1.default)(9),
name: "0x001232f58b963938486a11f88c1c36d61d82738b1828625a95a1e85b4c8d1282",
nextUnlockTime: "32d 5h 26m",
shares: 200020456320587.72,
wwwUrl: "https://explorer.aptoslabs.com/account/0x001232f58b963938486a11f88c1c36d61d82738b1828625a95a1e85b4c8d1282?network=mainnet",
},
{
activeStake: (0, bignumber_js_1.default)(116781362397133),
address: "0x05dece2ed08c68f8730527e9b3ebb3536efc3361f4ef37ba0b16a3310db836af",
commission: (0, bignumber_js_1.default)(4.99),
name: "cryptomolot.apt",
nextUnlockTime: "32d 5h 26m",
shares: 115552903623705.77,
wwwUrl: "https://explorer.aptoslabs.com/account/0x05dece2ed08c68f8730527e9b3ebb3536efc3361f4ef37ba0b16a3310db836af?network=mainnet",
},
];
it("returns the correct information", async () => {
mockedAptos.mockImplementation(() => ({
getAccountResource: async () => ({ locked_until_secs: "1750051574" }),
}));
mockedApolloClient.mockImplementation(() => ({
query: async () => ({
data: {
current_delegator_balances,
},
}),
}));
jest.useFakeTimers().setSystemTime(new Date("2025-05-15"));
const validators = await (0, validators_1.getValidators)("aptos");
expect(validators).toMatchObject(expectedResponse);
});
});
//# sourceMappingURL=validators.test.js.map