Skip to content

Commit

Permalink
Compare blobs as buffer not as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Apr 9, 2024
1 parent c323546 commit d7b3d9b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const sentBlobs: string[] = [];
export function createBlobsAssertion(
nodes: NodePair[],
{sendBlobsAtSlot, validateBlobsAt}: {sendBlobsAtSlot: number; validateBlobsAt: number}
): SimulationAssertion<string, string[]> {
): SimulationAssertion<string, Uint8Array[]> {
return {
id: `blobs-${nodes.map((n) => n.id).join("-")}`,
match: ({slot}) => {
Expand Down Expand Up @@ -52,13 +52,13 @@ export function createBlobsAssertion(
const blobSideCars = await node.beacon.api.beacon.getBlobSidecars(slot);
ApiError.assert(blobSideCars);

return blobSideCars.response.data.map((b) => toHex(b.blob));
return blobSideCars.response.data.map((b) => b.blob);
},

assert: async ({store}) => {
const errors: AssertionResult[] = [];

const blobs: string[] = [];
const blobs: Uint8Array[] = [];

for (let slot = sendBlobsAtSlot; slot <= validateBlobsAt; slot++) {
blobs.push(...(store[slot] ?? []));
Expand All @@ -75,7 +75,7 @@ export function createBlobsAssertion(
}

for (let i = 0; i < blobs.length; i++) {
if (blobs[i] !== sentBlobs[i]) {
if (!Buffer.from(blobs[i]).equals(Buffer.from(sentBlobs[i]))) {
errors.push([
"Node does not have the right blobs",
{
Expand Down

0 comments on commit d7b3d9b

Please sign in to comment.