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

tests: approvals tests #628

Merged
merged 3 commits into from
Feb 28, 2024
Merged

tests: approvals tests #628

merged 3 commits into from
Feb 28, 2024

Conversation

mateuszjasiuk
Copy link
Collaborator

No description provided.

Copy link
Contributor

github-actions bot commented Feb 12, 2024

@github-actions github-actions bot temporarily deployed to pull request February 12, 2024 14:12 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 14, 2024 13:52 Inactive
@mateuszjasiuk mateuszjasiuk force-pushed the tests/approvals-handlers-test branch from 1763941 to 9524070 Compare February 19, 2024 15:17
@mateuszjasiuk mateuszjasiuk marked this pull request as ready for review February 19, 2024 15:18
@github-actions github-actions bot temporarily deployed to pull request February 19, 2024 15:22 Inactive
Copy link
Contributor

@emccorson emccorson left a comment

Choose a reason for hiding this comment

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

Looks good to me!


// TODO: can tabId be 0?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think potentially yes. At least, on MDN I didn't find anything that said it can't be 0:

id Optional
integer. The tab's ID. Tab IDs are unique within a browser session. The tab ID may also be set to tabs.TAB_ID_NONE for browser windows that don't host content tabs (for example, devtools windows).

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/Tab#id

@@ -100,6 +100,7 @@ export class ApprovalsService {
if (!data) {
throw new Error(`Signing data for ${msgId} not found!`);
}
//TODO: Shouldn't we _clearPendingSignature when throwing?
Copy link
Contributor

Choose a reason for hiding this comment

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

@jurevans can say for sure 😄

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably? I don't think it would do anything for Signing data for ${msgId} not found!, but on the other errors, it should probably be there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will resolve those todos later ;)

@@ -127,13 +127,17 @@ export class ConnectInterfaceResponseMsg extends Message<void> {
}

validate(): void {
if (!this.interfaceTabId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There seem to be a few instances of these falsy checks that typecheck even when they're slightly wrong. I'm wondering if it might be worth adding a linting rule in the future to prevent that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah either that or we can just use io-ts also for those checks

const signer = "signer";
const signaturePromise = service.approveSignature(signer, "data");

await new Promise((resolve) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

What does waiting here do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So the reason is approveSignature is async but it does not resolve the promise by itself.
Because of that I did not add await in front of the call as that would make test hang.
Instead we have to wait a "tick" so resolverMap will be filled and submitSignature will be able to resolve successfully 😅 It's a bit confusing.

source: "source",
target: "target",
token: "token",
amount: BigNumber(100),
Copy link
Contributor

@emccorson emccorson Feb 27, 2024

Choose a reason for hiding this comment

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

That's cool - I didn't know new was optional for BigNumber 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Me neither :D

Copy link
Collaborator

@jurevans jurevans left a comment

Choose a reason for hiding this comment

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

LGTM!

@mateuszjasiuk mateuszjasiuk merged commit 120f9e6 into main Feb 28, 2024
8 checks passed
seleniumforest pushed a commit to seleniumforest/namada-interface that referenced this pull request Apr 11, 2024
* test: approvals handler test

* test: approvals messages and service tests

* test: approvals service test cd
@mateuszjasiuk mateuszjasiuk deleted the tests/approvals-handlers-test branch September 13, 2024 09:36
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.

3 participants