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

Run e2e tests on alfajores #258

Merged
merged 23 commits into from
Oct 21, 2024
Merged

Run e2e tests on alfajores #258

merged 23 commits into from
Oct 21, 2024

Conversation

piersy
Copy link

@piersy piersy commented Oct 16, 2024

Modifies our e2e tests to be able to run on alfajores if the environment variable NETWORK is set to 'alfajores'.
Also adds a CI step to run them against alfajores.

Note that the test_fee_currency... tests are skipped because they require the ability to deploy new fee currencies, which we probably don't want to be doing on a live network as it could cause issues for people, and we also don't want to expose the credentials to do so.

Copy link

socket-security bot commented Oct 16, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] Transitive: environment, network +11 18.3 MB awkweb, jmoxey

🚮 Removed packages: npm/[email protected]

View full report↗︎

@piersy piersy requested a review from karlb October 16, 2024 21:41
Comment on lines 312 to 323
it("send fee currency tx with just high enough gas price mine", async () => {
const rate = await getRate(process.env.FEE_CURRENCY);
const block = await publicClient.getBlock({});
// Actually, the base fee will be a bit lower next block, since our blocks
// are always mostly empty. But the difference will be much less than the
// exchange rate of 2, so the test will still check that we take the fee
// currency into account everywhere.
const maxFeePerGas = block.baseFeePerGas / 2n;
const maxFeePerGas = rate.toFeeCurrency(block.baseFeePerGas)+2n;
const request = await walletClient.prepareTransactionRequest({
account,
to: "0x00000000000000000000000000000000DeaDBeef",
value: 2,
gas: 90000,
feeCurrency: process.env.FEE_CURRENCY2,
maxFeePerGas,
maxPriorityFeePerGas: 1n,
gas: 171000,
feeCurrency: process.env.FEE_CURRENCY,
maxFeePerGas: maxFeePerGas,
maxPriorityFeePerGas: 2n,
Copy link
Author

Choose a reason for hiding this comment

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

Hey @karlb, I'm thinking probably my modifications here don't make sense because it seems that it is important for this test that the fee per gas for the fee currency than the native currency, and I've modified it to use USDC which is the other way around.

Copy link

@ezdac ezdac Oct 17, 2024

Choose a reason for hiding this comment

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

It seems that the main point of this is that the fee should be too low for native currency, but if the node converts it then it is sufficient. But for USDC it should actually be fine, since the exchange rate results in requiring a lower value for the base-fee compared to when it is denominated in Celo.

Copy link
Author

Choose a reason for hiding this comment

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

I will leave as is, with a comment that we may want to change this if the exchange rate changes significantly.

Copy link

@ezdac ezdac left a comment

Choose a reason for hiding this comment

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

I didn't manage to look at everything in detail yet.
But looks very good so far - this feature is much appreciated.

For future changes: I think we should add more fee-currencies registered in the directory and test this for multiple currencies.

e2e_test/js-tests/test_viem_tx.mjs Outdated Show resolved Hide resolved
Comment on lines 312 to 323
it("send fee currency tx with just high enough gas price mine", async () => {
const rate = await getRate(process.env.FEE_CURRENCY);
const block = await publicClient.getBlock({});
// Actually, the base fee will be a bit lower next block, since our blocks
// are always mostly empty. But the difference will be much less than the
// exchange rate of 2, so the test will still check that we take the fee
// currency into account everywhere.
const maxFeePerGas = block.baseFeePerGas / 2n;
const maxFeePerGas = rate.toFeeCurrency(block.baseFeePerGas)+2n;
const request = await walletClient.prepareTransactionRequest({
account,
to: "0x00000000000000000000000000000000DeaDBeef",
value: 2,
gas: 90000,
feeCurrency: process.env.FEE_CURRENCY2,
maxFeePerGas,
maxPriorityFeePerGas: 1n,
gas: 171000,
feeCurrency: process.env.FEE_CURRENCY,
maxFeePerGas: maxFeePerGas,
maxPriorityFeePerGas: 2n,
Copy link

@ezdac ezdac Oct 17, 2024

Choose a reason for hiding this comment

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

It seems that the main point of this is that the fee should be too low for native currency, but if the node converts it then it is sufficient. But for USDC it should actually be fine, since the exchange rate results in requiring a lower value for the base-fee compared to when it is denominated in Celo.

@@ -63,7 +79,8 @@ const testNonceBump = async (
account,
to: "0x00000000000000000000000000000000DeaDBeef",
value: 3,
gas: 90000,
// dynaimcally retrieve intrinsic gas from feeCurrency directory "feeCurrencyConfig"
Copy link

Choose a reason for hiding this comment

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

Do you still plan to implement this for this PR? If not, I would remove the line or add a TODO:, because it doesn't reflect what's happening ;)

Copy link
Author

Choose a reason for hiding this comment

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

Ok removed and I added a ticket for it - #260

e2e_test/debug-fee-currency/lib.sh Outdated Show resolved Hide resolved
e2e_test/js-tests/package.json Outdated Show resolved Hide resolved
e2e_test/run_all_tests.sh Show resolved Hide resolved
Copy link

@karlb karlb left a comment

Choose a reason for hiding this comment

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

Good feature and a bunch of small improvements on top of that!

e2e_test/js-tests/test_viem_tx.mjs Outdated Show resolved Hide resolved
e2e_test/js-tests/test_viem_tx.mjs Show resolved Hide resolved
e2e_test/test_fee_currency_fails_intrinsic.sh Outdated Show resolved Hide resolved
@piersy piersy requested review from karlb and ezdac October 18, 2024 18:08
Not that this test is running on live networks we need to account for
the case where the base fee could increase, we do this by adding a 10%
buffer.

Also ensures that we use FEE_CURRENCY2 when running local tests.

And finally adds a check to fail the test if the value of the fee
currency is not sufficiently greater than the value of celo.
@piersy piersy requested a review from karlb October 21, 2024 10:52
@piersy piersy merged commit de410b1 into celo10 Oct 21, 2024
4 of 6 checks passed
@piersy piersy deleted the piersy/run-e2e-tests-on-alfajores branch October 21, 2024 10:58
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