-
Notifications
You must be signed in to change notification settings - Fork 146
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
Inconsistent block height output #1653
Comments
We were able to work this out for now by extracting the block height from the print event, but it would still be nice to have guidance on how to handle block height in relation to |
Hey @whoabuddy export default defineConfig({
test: {
environment: "clarinet", // use vitest-environment-clarinet
pool: "forks",
poolOptions: {
forks: { singleFork: true },
},
setupFiles: [
vitestSetupFilePath,
// custom setup files can be added here
],
environmentOptions: {
clarinet: {
...getClarinetVitestsArgv(),
// add or override options
},
},
},
}); The pool option was And More details in the docs: https://vitest.dev/config/#pooloptions. |
This should work. I'd be interested in seeing a minimal reproducible example for that |
This is what I have now for the config, iirc we added export default defineConfig({
test: {
environment: "clarinet", // use vitest-environment-clarinet
singleThread: true,
setupFiles: [
vitestSetupFilePath,
// custom setup files can be added here
],
environmentOptions: {
clarinet: {
...getClarinetVitestsArgv(),
retryCount: 0,
// add or override options
},
},
},
});
Updating to the provided vitest config format runs a bit faster and I get less blockheight console output:
I also pushed the next commit with an example of what happens when we update to The code checks fine with Clarinet but when I run the tests there are several 1009 / 3009 errors which equate to |
This was the Vitest v0.x config schema (
It could be a bug in Clarinet. I'll have to spend more time on it this week or next one. |
Great, happy to use that config instead! I've started a lot of different projects at different times it's really hard to tell when everything is "up to date" and/or configured correctly. Sometimes it's easier to copy an old project then scaffold a whole new one which complicates the issue. (e.g. this repo is on "dependencies": {
"@hirosystems/clarinet-sdk": "^2.12.0",
"@stacks/transactions": "^6.17.0",
"chokidar-cli": "^3.0.0",
"typescript": "^5.7.3",
"vite": "^5.4.11",
"vitest": "^1.6.0",
"vitest-environment-clarinet": "^2.1.0"
}
Happy to help if any questions or if I have time I'll make a minimal example.
Another thing I've noticed is we do not explicitly initSimnet() but use a globally available variable, do we have to? And we have some methods as "helpers" that perform a few actions, e.g. send 3 votes on a proposal then conclude it and return the receipt. Would love to figure out the best practices here for this and other projects! |
The clarinet-sdk works with
Yes thats good. That's thanks to
I think this repo looks good already.
Thanks 🙏 |
Excellent, good to know! What about using the init functions for simnet? So far I'm just using the global and noticed it did the cleanup before each run. That's definitely useful for unit tests, and in Deno we fought so much with
Part of the way there, scaffolded and still need to add some more test cases. |
Describe the bug
We have a few contracts that create proposals and use
at-block
to get snapshot balances.For one contract in particular, it tracks the last block height a proposal was created at:
However in the tests we cannot get the block heights to line up, relevant testing code for
get-last-proposal-created
:https://github.com/aibtcdev/aibtcdev-contracts/blob/ec3dcac45a5e251fe021b22ac0071abfa043d48e/tests/dao/extensions/aibtc-action-proposals-v2.test.ts#L1091-L1198
The test fails because the block height doesn't match, but after console logging it doesn't make sense to me why the numbers are off following the progression:
And what we see in the console logs of the test (left them in since this one still fails):
To Reproduce
Steps to reproduce the behavior:
git clone [email protected]:aibtcdev/aibtcdev-contracts
git checkout feat/proposals-v2
npm i && npm run test
Expected behavior
I expected the block heights captured from simnet would match what's recorded in the contract for the public function call.
Environment (please complete the following information):
Additional context
We also tried switching all contracts to clarity_version 3 and using
stacks-block-height
withget-stacks-block-info?
but this caused every attempt at getting the block hash in the contracts to fail. Needs more investigation and documentation isn't clear on when that goes into effect.We also noted that the clarity_version 2 defaults above will deploy, so sticking with them for now unless we need to update. Is there any ETA on this?
The text was updated successfully, but these errors were encountered: