Skip to content

Commit

Permalink
Stablize lightclient e2e tests (#5241)
Browse files Browse the repository at this point in the history
* Stablize lightclient e2e tests

* Remove .only
  • Loading branch information
twoeths authored Mar 7, 2023
1 parent a88c5b2 commit eb4b43d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/beacon-node/src/chain/lightClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ export class LightClientServer {
this.logger.debug("sync committee below required MIN_SYNC_COMMITTEE_PARTICIPANTS", {
syncPeriod,
attestedPeriod,
syncAggregateParticipation,
});
this.metrics?.lightclientServer.onSyncAggregate.inc({event: "ignore_sync_committee_low"});
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,31 @@ describe("lightclient api", function () {
}
});

it("getUpdates()", async function () {
const waitForBestUpdate = async (): Promise<void> => {
// should see this event in 5 slots
await waitForEvent(
bn.chain.emitter,
routes.events.EventType.lightClientOptimisticUpdate,
5 * SECONDS_PER_SLOT * 1000
);
// wait for 1 slot to persist the best update
await sleep(2 * SECONDS_PER_SLOT * 1000);
};

it("getUpdates()", async function () {
const client = getClient({baseUrl: `http://127.0.0.1:${restPort}`}, {config}).lightclient;
await waitForBestUpdate();
const res = await client.getUpdates(0, 1);
ApiError.assert(res);
const updates = res.response;
const slot = bn.chain.clock.currentSlot;
expect(updates.length).to.be.equal(1);
// at slot 2 we got attestedHeader for slot 1
expect(updates[0].data.attestedHeader.beacon.slot).to.be.equal(slot - 1);
// best update could be any slots
// version is set
expect(updates[0].version).to.be.equal(ForkName.altair);
});

it("getOptimisticUpdate()", async function () {
await sleep(2 * SECONDS_PER_SLOT * 1000);
await waitForBestUpdate();
const client = getClient({baseUrl: `http://127.0.0.1:${restPort}`}, {config}).lightclient;
const res = await client.getOptimisticUpdate();
ApiError.assert(res);
Expand All @@ -109,8 +118,7 @@ describe("lightclient api", function () {
});

it("getCommitteeRoot() for the 1st period", async function () {
// call this right away causes "No partialUpdate available for period 0"
await sleep(2 * SECONDS_PER_SLOT * 1000);
await waitForBestUpdate();

const lightclient = getClient({baseUrl: `http://127.0.0.1:${restPort}`}, {config}).lightclient;
const committeeRes = await lightclient.getCommitteeRoot(0, 1);
Expand Down

0 comments on commit eb4b43d

Please sign in to comment.