ODHack: Modular integration tests
We need to add modular integration tests for Konoha that can be used to test deployed instances. This will make it easier for the protocols using it to verify Konoha is working correctly and to gain confidence upgrading it.
Tasks
- Create a new file
tests/integration_tests.cairowith the following functions:deploy_governance(classhash, token_recipient): Deploys the governance contractupgrade(gov_address, tokenholders, new_classhash): Upgrades a governance contract to a new classhashhealthcheck(gov_address, tokenholders): Runs a series of checks on a deployed governance contract
- Create a new file
tests/integration_test_runner.cairothat uses the above functions to test upgrading the current Konoha Sepolia deployment to the latest master
Pseudocode
tests/integration_tests.cairo:
fn deploy_governance(classhash, token_recipient):
Deploy governance contract with given classhash and token recipient – use functions from setup.cairo here
Return deployed contract address
fn upgrade(gov_address, tokenholders: Span<ContractAddress>, new_classhash):
For each tokenholder:
Vote to upgrade governance contract to new_classhash
Assert that proposal passes, then:
Apply the upgrade
fn healthcheck(gov_address, tokenholders):
Submit new signal proposal
Check proposal appears in get_live_proposals
Verify get_proposal_details is correct
For each tokenholder:
Vote on the proposal
Check get_vote_counts updates correctly
Warp time and check that the proposal has passed
tests/integration_test_runner.cairo:
#[test]
#[fork("SEPOLIA")]
fn test_upgrade_sepolia_konoha():
current_gov_address = 0x056dfcfa3c33c7a6852479f241f0cbbd2405791164754f16c0dcd90de13da059
tokenholders = Array of Sepolia Konoha tokenholders – copy from https://sepolia.starkscan.co/token/0x02b91dd683bc4bcae7a9c5d0cbeba0e8d62fa657742e4640f1e8163dc10e9bd7#holders
healthcheck(current_gov_address, tokenholders)
new_classhash = declare current Governance.cairo
upgrade(current_gov_address, tokenholders, new_classhash)
healthcheck(current_gov_address, tokenholders)
See the Contributor Guidelines for how to get started working on this issue.
Hi @tensojka can I work on this? Using this steps you have already mentioned, I would quickly execute the test within a time frame of 3 days.
Yes you can, assigning you @Iwueseiter
thank you @tensojka
Hi @Iwueseiter any update on this issue ?
@ptisserand I'm working on it. I will create a PR soon.
Hey @Iwueseiter still on the issue?
@od-hunter yes.
@ptisserand You are now assigned as @Iwueseiter hasn't posted a draft PR.
Hi @tensojka sorry I didn't have time before to work on this issue before.
I have look at setup.cairo implementation and I think in tests/integration_tests.cairo the prototype for deploy_governance should be:
fn deploy_governance(classhash: ClassHash, voting_token_class: ClassHash, floating_token_class: ClassHash, token_recipient: ContractAddress) -> ContractAddress;
instead of
fn deploy_governance(classhash: ClassHash, token_recipient: ContractAddress) -> ContractAddress;
Are you agree?