-
Notifications
You must be signed in to change notification settings - Fork 1
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
39 implement tests for nabla indexer #40
Conversation
@@ -63,6 +63,44 @@ export default async function (environment: TestSuiteEnvironment) { | |||
await genericTestOnlyOwnerCanSetPoolCap(pool, environment); | |||
}, | |||
|
|||
async test_maxCoverageRatioForSwapIn_CheckDefaultValue() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are additional tests from this PR in the Nabla repo: https://github.com/0xamberhq/contracts/pull/76/files#diff-ef61283d9b153c522945399fe4fa316c48029036ca90a2648efa5d5794d5c5ee
d71f798
to
007ec75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good 👍! I only have minor questions, not on the logic of the test itself. That so far seems sound.
I still haven't run the code locally.
(routers) => | ||
routers | ||
.find((router) => router.id === address(instance.router)) | ||
?.swapPools.find((swapPool) => swapPool.id === address(replacementPool)) !== undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also check that the replaced swapPool
does not exist anymore (not registered with the router)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think this is happening here already the verifyIndexer
that comes up next checks whether there are only two swap pools. Since the first swap pool's reserve changed from 11000000000000
to 20000000000000
and there are only two pools, then this would mean that the indexer does not report the replaced swap pool anymore.
|
||
verifyIndexer(indexerRouters, instance, [ | ||
{ | ||
reserve: "12997193504712", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an "easy" way to calculate these values without having to use the full equation of the curve? (or at least an approximation to do a sanity check)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, among others, the root of a quadratic equation. That's why this number looks so random. I think that does not count as "easy" anymore.
}, | ||
]); | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check to see if the balances were modified to reflect the swap? Or is it too much coupling on the same test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What balances do you refer to? The pool token balance(s) and/or the LP token balance(s)? As these are not reported by the indexer and, e.g., the Nabla UI reads them directly from the smart contract, I don't actually consider this a necessity of this test suite. Is that what you are referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I was referring to the tester
balance before and after the swap. What I don't remember is why I thought this could be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it fine if we leave that out?
cbf80ac
to
7e2d214
Compare
I added and adapted the tests in order to incorporate the new changes on this branch: https://github.com/0xamberhq/contracts/pull/111 |
|
||
Clone the solang repository and build it: | ||
|
||
```shell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the path to the solang binary used here should be absolute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we make it absolute then every developer definitely needs to touch that path. If we keep it relative we just have to make sure that the directory is put into the conventional place.
I had to add some changes to make the indexer tests run again: this requires an older version of our wrapper contracts because foucoco-standalone is currently incompatible with the latest main branch of the wrapper contracts (they now assume that there are multiple chain extensions in place – as is the case for our our normal runtimes). I changed the dependency on the wrapper contracts to refer to an older commit. Furthermore, the tests require a version of foucoco-standalone that includes PR pendulum-chain/foucoco-standalone#10. |
@TorstenStueber I wanted to test this again, this time using our custom Foucoco version that we added to the pendulum repo. That runtime uses the latest chain extensions and thus has to be called with the chain extension ID + function ID as is done by the latest Pendulum solidity wrapper contracts. So I run the Foucoco testchain with
Then I spin up the indexer with
but when I do
and when I do `` I get
Do we need to touch the tests again or am I doing something wrong? |
@ebma Yes, Foucoco Standalone is not working anymore with the This is meant to be temporary. Either we change foucoco-standalone to also use multiple chain extensions or we wait for everything in this comment being completed. I prefer the latter. |
I read your comment more thoroughly now. Your comment was about the test run of the For the |
@TorstenStueber but you investigated this problem already and identified that this is due to some breaking changes in one of the dependencies, right? How should we proceed with this PR? |
4a236aa
to
48bf572
Compare
Create nabla-indexer project Remove unnecessary contracts Allow to override metadata message names Allow to override argument names of messages in metadata Include new tests from Nabla main repo Update README Use different token decimals for Nabla testnet deployment Update names in deployment script Add deployment for five swap pools Adapt tests for new changes Implement test from Alpha Testnet Add tests for swap pool quote functions Implement tests to change treasury Add missing calls to Nabla deployment Remove `api-solang` from workspaces This is in order to use the deployed npm version with types available Replace ts-node with tsx ts-node was not running due to module vs commonjs issues Remove `--ignore-engines` because it's deprecated and the pull command throws an error Change `init` for 'nablaCurve' repo to "npm" Set polkadot dependencies to fixed version There was a breaking change in a minor version bump so we set these to specific versions see polkadot-js/api@ca48023#diff-6c3c68a16db206b507cabe5612726492ebaf4c9f3d4717e10d2a75b3d6dcd4f1R172 Rename commands in package.json Add info to README.md Add fixes to make nabla indexer tests successful again Change token names and symbols in testnet deployment Create debug snapshot Simplify Nabla project
48bf572
to
18133a2
Compare
@pendulum-chain/devs I added a lot of updates to this PR and updated the description of this PR. Additionally I rebased it so that it is not in conflict with master anymore. Since this PR has been open and had many changes over many months, I recommend the following course of actions:
|
I approved so we can continue with that plan. I believe we also ice boxed the standalone issue right? |
I would need to check in the next weeks what the latest version in our discussion about the standalone issue was and whether there is any chance to continue. I don't consider this high priority right now as long as we don't change the Nabla code. |
This now ballooned into one big PR that contains many different changes implemented over months.
Updated deployment instructions
We deployed a number of various Nabla instances in the past: different instances on Pendulum (used for Vortex and public deployments) and instances on Foucoco (used for the testnet campaign and for different validations and testing scenarios).
There was only one definition of the deployment scripts and when changing to a new deployment I had to adapt all files locally. This had a couple of issues:
Instead, I now changed the deployment scripts to use declarative deployments (see the folder
nabla/deployments
). That way editing is less error prone and we can easily keep a history of deployments.For that reason there is no need for separate
nabla
andnabla-pendulum
projects anymore. There is now just apendulum
project.Updated Tests
Closes #39
Closes #44
Closes #43 (fixed by this)
This PR adds a new test suite to test the Nabla indexer (called
nabla-indexer
).These tests are implemented for this indexer PR: pendulum-chain/pendulum-squids#52.
The main file is
nabla-indexer/test/indexer_tests.ts
.Additionally this ticket also updates the version of the Nabla contracts that had some minor changes in the mean time and some new tests have been implemented.
This is temporary work. The intention is to move these tests to our subsquid indexer repository and to move the Nabla tests to the Nabla contracts repository. However, this requires that wasm-deploy becomes a standalone tool that can be used in other npm projects (see #10).
Additionally, this PR adds some small new features to wasm-deploy that were necessary to implement this test suite:
Other Changes
tsx
a dev dependency instead of a normal dependencylint:ts
script