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

[FIX] Update E2E test token and related tests #1505

Merged
merged 10 commits into from
Oct 4, 2024

Conversation

aristidesstaffieri
Copy link
Contributor

@aristidesstaffieri aristidesstaffieri commented Oct 3, 2024

What
Updates the E2E test token address for tests that use it.
Adds fetching of token details in history rows that are transfers in all cases.
Makes getArgsForTokenInvocation work with transfers to C addresses.

Why
The address was stale after the testnet reset.
Transfers to C addresses uncovered a few edge cases in history.

@aristidesstaffieri aristidesstaffieri self-assigned this Oct 3, 2024
@@ -22,7 +22,7 @@ export const loginAndFund = async ({ page, extensionId }) => {
});

await page.goto(`chrome-extension://${extensionId}/index.html#/account`);
await page.getByTestId("BlockaidAnnouncement__accept").click();
// await page.getByTestId("BlockaidAnnouncement__accept").click();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't shown right now and also commented out so I assume we will need this again soon.

}));
} else {
const { token, decimals } = balances[tokenKey] as TokenBalance;
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that sending transfers from payments is better supported, it became more obvious that we can't rely on client side cached token details for this path because we more often don't have them(user has a classic balance in Freighter but send to C address through SAC transfer for example). This update just fetches token details for every row that is a transfer inline to avoid the inconsistencies.

to = StrKey.encodeEd25519PublicKey(
args[1].address().accountId().ed25519(),
);
from = addressToString(args[0].address());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that we support transfers to C addresses, I ran into this where from and to are actually not always accountId and can also be contractId.

@aristidesstaffieri aristidesstaffieri changed the title [CHORE] Update e2e test token [FIX] Update E2E test token and related tests Oct 4, 2024

test("Send XLM payment to G address", async ({ page, extensionId }) => {
test.slow();
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a specific reason to drop this? if I recall, it just extends the wait time of a test. I believe I had added this in the event of slow responses from Horizon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just didn't observe that it added any longer of a timeout but no qualms with restoring, will add back.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool - once we stub out external calls, we shouldn't need this anymore

@@ -357,7 +357,9 @@ export const TransactionDetails = ({ goBack }: { goBack: () => void }) => {
url,
networkDetails,
);
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

does this do something the return on ln 388 does not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well I think we could safely drop it but in the case that we scanTx we don't need to manually setLoading(false) because it happens in the hook call. So the bug was that we relied on isLoading but didn't always set it correctly in the case here.
Dropping it should only result in calling that state setter once unnecessarily which is probably fine.

}
setLoading(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to worry about this loading state for classic tx's, as well?

Copy link
Contributor Author

@aristidesstaffieri aristidesstaffieri Oct 4, 2024

Choose a reason for hiding this comment

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

no we don't because we seem to be calling that in every case here. I guess maybe I should ask about the intention of the condition to not scanSorobanTx if submission.submitStatus === ActionStatus.IDLE && transactionSimulation.preparedTransaction? I think that's actually correct since we don't really get anything from re-scanning it in tx details after the tx has been done. Maybe the miss here is that we should also be doing this in scanClassicTx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh wait I wrote that! lol Yeah curious if you think that's right? I think we probably also want to skip the scan for classic in the same condition.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay took me a second to understand what was happening, but I get it now:

This conditional is just to make sure we've finished simming the tx, which is only necessary for Soroban tx's. So it makes sense that we only have the conditional on scanSorobanTx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this in fd2e8dc
I think it makes sense to not scan either tx type in tx details if we are rendering it after the tx has been sent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah maybe I misunderstand this conditional. I think really what we want here is to never scan the tx is we are rendering the details at confirmation so I will just add a prop that we can pass in explicitly at confirmation to make this less brittle.

Copy link
Contributor

Choose a reason for hiding this comment

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

But if we go back to tx details from the Tx Success screen, we'll re-scan a classic tx, but we won't re-scan a soroban tx. And that's kind of a weird discrepancy. We probably shouldn't re-scan in either case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok cool I think we're aligned here, 62cd1a6 is the version that I think handles this best.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice - this lgtm!

@aristidesstaffieri aristidesstaffieri merged commit ad93929 into release/5.23.2 Oct 4, 2024
3 checks passed
@aristidesstaffieri aristidesstaffieri deleted the chore/update-e2e-test-token branch October 4, 2024 17:40
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