Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧪 mock get transaction receipt #231

Merged
merged 3 commits into from
May 19, 2023

Conversation

jtfirek
Copy link
Collaborator

@jtfirek jtfirek commented May 11, 2023

@dawsbot Here is another one.

I used destructuring here to remove an element from the copy which I thought was pretty sick 🧼
https://github.com/jtfirek/essential-eth/blob/5840d0255a5383f2d69a29131f6d2a25e3b34d15/src/providers/test/json-rpc-provider/get-transaction-receipt.test.ts#L64

effectiveGasPrice: tinyBig(mockReceiptResponse.effectiveGasPrice),
gasUsed: tinyBig(mockReceiptResponse.gasUsed),
status: Number(hexToDecimal(mockReceiptResponse.status)),
logs: mockReceiptResponse.logs.map(({ removed, ...log }) => ({
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sleek and interesting, but I have no idea what this does.

Probably too tricky to throw into a JSON object like this. Perhaps we can name this a helpful const like "mockLogsWithoutWhatever" above the mockReceipt initialization then use it inside here?

My main misunderstanding is why we need to remove anything from the logs using this restructuring and a well-named variable above might be helpful

Copy link
Collaborator Author

@jtfirek jtfirek May 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to clean the log without using the cleanLog function, but I see how this confusing. I will just use the helper and add cleanLog to the list of helpers to test #228.

(log) => omit(log, ['id', 'removed'] as any) as any,
);
const mockBlocksBetween = 10;
const mockReceiptResponse = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WOW, this will be so helpful to get merged. Big objects 🙌

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍👍

@dawsbot dawsbot merged commit a37d464 into dawsbot:master May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants