Skip to content

Commit

Permalink
Update more calls to use POST variant
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Sep 18, 2024
1 parent 580bd72 commit 37bcdcb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions packages/cli/test/sim/endpoints.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ await env.start({runTimeoutMs: estimatedTimeoutMs});
const node = env.nodes[0].beacon;
await waitForSlot("Wait for 2 slots before checking endpoints", {env, slot: 2});

const validators = (await node.api.beacon.getStateValidators({stateId: "head"})).value();
const validators = (await node.api.beacon.postStateValidators({stateId: "head"})).value();

await env.tracker.assert("should have correct validators count called without filters", async () => {
assert.equal(validators.length, validatorCount);
Expand All @@ -55,12 +55,12 @@ await env.tracker.assert("should have correct validator index for second validat
});

await env.tracker.assert(
"should return correct number of filtered validators when getStateValidators called with filters",
"should return correct number of filtered validators when postStateValidators called with filters",
async () => {
const filterPubKey =
"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c";

const res = await node.api.beacon.getStateValidators({stateId: "head", validatorIds: [filterPubKey]});
const res = await node.api.beacon.postStateValidators({stateId: "head", validatorIds: [filterPubKey]});

assert.equal(res.value().length, 1);

Expand All @@ -71,12 +71,12 @@ await env.tracker.assert(
);

await env.tracker.assert(
"should return correct filtered validators when getStateValidators called with filters",
"should return correct filtered validators when postStateValidators called with filters",
async () => {
const filterPubKey =
"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c";

const res = await node.api.beacon.getStateValidators({stateId: "head", validatorIds: [filterPubKey]});
const res = await node.api.beacon.postStateValidators({stateId: "head", validatorIds: [filterPubKey]});

assert.equal(toHexString(res.value()[0].validator.pubkey), filterPubKey);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/validator/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ export class Validator {
* Create a signed voluntary exit message for the given validator by its key.
*/
async signVoluntaryExit(publicKey: string, exitEpoch?: number): Promise<phase0.SignedVoluntaryExit> {
const validators = (await this.api.beacon.getStateValidators({stateId: "head", validatorIds: [publicKey]})).value();
const validators = (
await this.api.beacon.postStateValidators({stateId: "head", validatorIds: [publicKey]})
).value();

const validator = validators[0];
if (validator === undefined) {
Expand Down

0 comments on commit 37bcdcb

Please sign in to comment.