Skip to content

Commit

Permalink
flip async and sync chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Apr 28, 2022
1 parent 66f1c3f commit 23b0882
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("network / reqresp / sszSnappy / encode", () => {
const testCases = [sszSnappyPing, sszSnappyStatus, sszSnappySignedBeaconBlockPhase0];

for (const testCase of testCases) {
const {id, type, syncChunks} = testCase;
const {id, type, chunks} = testCase;
it(id, async () => {
const body =
type === ssz.phase0.SignedBeaconBlock
Expand All @@ -36,7 +36,7 @@ describe("network / reqresp / sszSnappy / encode", () => {
),
all
);
expectEqualByteChunks(encodedChunks, syncChunks);
expectEqualByteChunks(encodedChunks, chunks);
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ export interface ISszSnappyTestData<T extends RequestOrIncomingResponseBody> {
type: RequestOrResponseType;
body: T;
/** chunks expected in an async compress version of snappy stream */
chunks: Buffer[];
asyncChunks: Buffer[];
/** chunks expected in a sync compress version of snappy stream */
syncChunks: Buffer[];
chunks: Buffer[];
}

export const sszSnappyPing: ISszSnappyTestData<phase0.Ping> = {
id: "Ping type",
type: ssz.phase0.Ping,
body: BigInt(1),
chunks: [
asyncChunks: [
"0x08", // length prefix
"0xff060000734e61507059", // snappy frames header
"0x010c00000175de410100000000000000", // snappy frames content
].map(fromHexString) as Buffer[],
syncChunks: ["0x08", "0xff060000734e61507059010c00000175de410100000000000000"].map(fromHexString) as Buffer[],
chunks: ["0x08", "0xff060000734e61507059010c00000175de410100000000000000"].map(fromHexString) as Buffer[],
};

export const sszSnappyStatus: ISszSnappyTestData<phase0.Status> = {
Expand All @@ -37,12 +37,12 @@ export const sszSnappyStatus: ISszSnappyTestData<phase0.Status> = {
headRoot: Buffer.alloc(32, 0xda),
headSlot: 9,
},
chunks: [
asyncChunks: [
"0x54", // length prefix
"0xff060000734e61507059", // snappy frames header
"0x001b0000097802c15400da8a010004090009017e2b001c0900000000000000",
].map(fromHexString) as Buffer[],
syncChunks: ["0x54", "0xff060000734e61507059001b0000097802c15400da8a010004090009017e2b001c0900000000000000"].map(
chunks: ["0x54", "0xff060000734e61507059001b0000097802c15400da8a010004090009017e2b001c0900000000000000"].map(
fromHexString
) as Buffer[],
};
Expand Down Expand Up @@ -73,12 +73,12 @@ export const sszSnappySignedBeaconBlockPhase0: ISszSnappyTestData<phase0.SignedB
},
signature: Buffer.alloc(96, 0xda),
},
chunks: [
asyncChunks: [
"0x9403",
"0xff060000734e61507059",
"0x00340000fff3b3f594031064000000dafe01007a010004090009011108fe6f000054feb4008ab4007e0100fecc0011cc0cdc0000003e0400",
].map(fromHexString) as Buffer[],
syncChunks: [
chunks: [
"0x9403",
"0xff060000734e6150705900340000fff3b3f594031064000000dafe01007a010004090009011108fe6f000054feb4008ab4007e0100fecc0011cc0cdc0000003e0400",
].map(fromHexString) as Buffer[],
Expand All @@ -98,12 +98,12 @@ export const sszSnappySignedBeaconBlockAltair: ISszSnappyTestData<altair.SignedB
},
},
},
chunks: [
asyncChunks: [
"0xf803", // length prefix
"0xff060000734e61507059", // snappy frames header
"0x003f0000ee14ab0df8031064000000dafe01007a01000c995f0100010100090105ee70000d700054ee44000d44fe0100fecc0011cc0c400100003e0400fe01008e0100",
].map(fromHexString) as Buffer[],
syncChunks: [
chunks: [
"0xf803",
"0xff060000734e61507059003f0000ee14ab0df8031064000000dafe01007a01000c995f0100010100090105ee70000d700054ee44000d44fe0100fecc0011cc0c400100003e0400fe01008e0100",
].map(fromHexString) as Buffer[],
Expand Down

0 comments on commit 23b0882

Please sign in to comment.