Skip to content

Commit

Permalink
Remove slicing where unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
Pasifaee committed May 28, 2024
1 parent e632059 commit 750bc58
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
7 changes: 2 additions & 5 deletions ethereum/oracles/src/noir/oracles/accountOracle.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('accountOracle', () => {
accountProofConfig.maxPrefixedKeyNibbleLen + accountProofConfig.maxValueLen
);
expect(proofInputValuePart).toMatchSnapshot();
const proofInputDepthPart = account[OFFSETS.PROOF_INPUT].slice(
account[OFFSETS.PROOF_INPUT].length - 1,
account[OFFSETS.PROOF_INPUT].length
);
expect(proofInputDepthPart).toStrictEqual(['0x09']);
const proofInputDepthPart = account[OFFSETS.PROOF_INPUT][account[OFFSETS.PROOF_INPUT].length - 1];
expect(proofInputDepthPart).toStrictEqual('0x09');
});
});
16 changes: 6 additions & 10 deletions ethereum/oracles/src/noir/oracles/proofOracle.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@ describe(
expect(stateAndStorageProof[OFFSETS.NONCE]).toStrictEqual('0x01');
expect(stateAndStorageProof[OFFSETS.BALANCE]).toStrictEqual('0x');

const stateProofInputDepthPart = stateAndStorageProof[OFFSETS.STATE_PROOF_INPUT].slice(
stateAndStorageProof[OFFSETS.STATE_PROOF_INPUT].length - 1,
stateAndStorageProof[OFFSETS.STATE_PROOF_INPUT].length
);
expect(stateProofInputDepthPart).toStrictEqual(['0x09']);
const storageProofInputDepthPart = stateAndStorageProof[OFFSETS.STORAGE_PROOF_INPUT].slice(
stateAndStorageProof[OFFSETS.STORAGE_PROOF_INPUT].length - 1,
stateAndStorageProof[OFFSETS.STORAGE_PROOF_INPUT].length
);
expect(storageProofInputDepthPart).toStrictEqual(['0x07']);
const stateProofInputDepthPart =
stateAndStorageProof[OFFSETS.STATE_PROOF_INPUT][stateAndStorageProof[OFFSETS.STATE_PROOF_INPUT].length - 1];
expect(stateProofInputDepthPart).toStrictEqual('0x09');
const storageProofInputDepthPart =
stateAndStorageProof[OFFSETS.STORAGE_PROOF_INPUT][stateAndStorageProof[OFFSETS.STORAGE_PROOF_INPUT].length - 1];
expect(storageProofInputDepthPart).toStrictEqual('0x07');
});
},
{
Expand Down
7 changes: 2 additions & 5 deletions ethereum/oracles/src/noir/oracles/receiptOracle.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,8 @@ describe('getReceiptOracle', () => {
receiptProofConfigM.maxPrefixedKeyNibbleLen + receiptProofConfigM.maxValueLen
);
expect(proofInputValuePart).toMatchSnapshot();
const proofInputDepthPart = receiptWithProof[OFFSETS.PROOF_INPUT].slice(
receiptWithProof[OFFSETS.PROOF_INPUT].length - 1,
receiptWithProof[OFFSETS.PROOF_INPUT].length
);
expect(proofInputDepthPart).toStrictEqual(['0x03']);
const proofInputDepthPart = receiptWithProof[OFFSETS.PROOF_INPUT][receiptWithProof[OFFSETS.PROOF_INPUT].length - 1];
expect(proofInputDepthPart).toStrictEqual('0x03');
});

it('transaction not found', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ describe('getTransactionOracle', () => {
txProofConfigM.maxPrefixedKeyNibbleLen + txProofConfigM.maxValueLen
);
expect(proofInputValuePart).toMatchSnapshot();
const proofInputDepthPart = txWithProof[OFFSETS.PROOF_INPUT].slice(
txWithProof[OFFSETS.PROOF_INPUT].length - 1,
txWithProof[OFFSETS.PROOF_INPUT].length
);
expect(proofInputDepthPart).toStrictEqual(['0x03']);
const proofInputDepthPart = txWithProof[OFFSETS.PROOF_INPUT][txWithProof[OFFSETS.PROOF_INPUT].length - 1];
expect(proofInputDepthPart).toStrictEqual('0x03');
});
});

0 comments on commit 750bc58

Please sign in to comment.