-
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
base: main
Are you sure you want to change the base?
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 |
This is in order to use the deployed npm version with types available
ts-node was not running due to module vs commonjs issues
because it's deprecated and the pull command throws an error
There was a breaking change in a minor version bump so we set these to specific versions see polkadot-js/api@ca48023#diff-6c3c68a16db206b507cabe5612726492ebaf4c9f3d4717e10d2a75b3d6dcd4f1R172
|
||
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? |
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: