fix: getEpochInfo RPC endpoint now includes the current block height
This commit is contained in:
parent
a5dd848702
commit
3b87780f21
|
@ -183,6 +183,7 @@ declare module '@solana/web3.js' {
|
||||||
slotIndex: number;
|
slotIndex: number;
|
||||||
slotsInEpoch: number;
|
slotsInEpoch: number;
|
||||||
absoluteSlot: number;
|
absoluteSlot: number;
|
||||||
|
blockHeight?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type EpochSchedule = {
|
export type EpochSchedule = {
|
||||||
|
|
|
@ -208,6 +208,7 @@ declare module '@solana/web3.js' {
|
||||||
slotIndex: number,
|
slotIndex: number,
|
||||||
slotsInEpoch: number,
|
slotsInEpoch: number,
|
||||||
absoluteSlot: number,
|
absoluteSlot: number,
|
||||||
|
blockHeight: ?number,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare export type LeaderSchedule = {
|
declare export type LeaderSchedule = {
|
||||||
|
|
|
@ -246,12 +246,14 @@ const GetInflationGovernorResult = struct({
|
||||||
* @property {number} slotIndex
|
* @property {number} slotIndex
|
||||||
* @property {number} slotsInEpoch
|
* @property {number} slotsInEpoch
|
||||||
* @property {number} absoluteSlot
|
* @property {number} absoluteSlot
|
||||||
|
* @property {number} blockHeight
|
||||||
*/
|
*/
|
||||||
type EpochInfo = {
|
type EpochInfo = {
|
||||||
epoch: number,
|
epoch: number,
|
||||||
slotIndex: number,
|
slotIndex: number,
|
||||||
slotsInEpoch: number,
|
slotsInEpoch: number,
|
||||||
absoluteSlot: number,
|
absoluteSlot: number,
|
||||||
|
blockHeight: number | null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const GetEpochInfoResult = struct({
|
const GetEpochInfoResult = struct({
|
||||||
|
@ -259,6 +261,7 @@ const GetEpochInfoResult = struct({
|
||||||
slotIndex: 'number',
|
slotIndex: 'number',
|
||||||
slotsInEpoch: 'number',
|
slotsInEpoch: 'number',
|
||||||
absoluteSlot: 'number',
|
absoluteSlot: 'number',
|
||||||
|
blockHeight: 'number?',
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -442,9 +445,7 @@ const GetEpochScheduleRpcResult = struct({
|
||||||
/**
|
/**
|
||||||
* Expected JSON RPC response for the "getLeaderSchedule" message
|
* Expected JSON RPC response for the "getLeaderSchedule" message
|
||||||
*/
|
*/
|
||||||
const GetLeaderScheduleRpcResult = jsonRpcResult(
|
const GetLeaderScheduleRpcResult = jsonRpcResult(GetLeaderScheduleResult);
|
||||||
GetLeaderScheduleResult,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected JSON RPC response for the "getBalance" message
|
* Expected JSON RPC response for the "getBalance" message
|
||||||
|
|
|
@ -394,13 +394,19 @@ test('get epoch info', async () => {
|
||||||
slotIndex: 1,
|
slotIndex: 1,
|
||||||
slotsInEpoch: 8192,
|
slotsInEpoch: 8192,
|
||||||
absoluteSlot: 1,
|
absoluteSlot: 1,
|
||||||
|
blockHeight: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const epochInfo = await connection.getEpochInfo();
|
const epochInfo = await connection.getEpochInfo();
|
||||||
|
|
||||||
for (const key of ['epoch', 'slotIndex', 'slotsInEpoch', 'absoluteSlot']) {
|
for (const key of [
|
||||||
|
'epoch',
|
||||||
|
'slotIndex',
|
||||||
|
'slotsInEpoch',
|
||||||
|
'absoluteSlot' /*, 'blockHeight'*/, // Uncomment blockHeight after 1.1.20 ships
|
||||||
|
]) {
|
||||||
expect(epochInfo).toHaveProperty(key);
|
expect(epochInfo).toHaveProperty(key);
|
||||||
expect(epochInfo[key]).toBeGreaterThanOrEqual(0);
|
expect(epochInfo[key]).toBeGreaterThanOrEqual(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue