konoha icon indicating copy to clipboard operation
konoha copied to clipboard

ODHack: Modular integration tests

Open ondrejsojka opened this issue 1 year ago • 9 comments

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.cairo with the following functions:
    • deploy_governance(classhash, token_recipient): Deploys the governance contract
    • upgrade(gov_address, tokenholders, new_classhash): Upgrades a governance contract to a new classhash
    • healthcheck(gov_address, tokenholders): Runs a series of checks on a deployed governance contract
  • Create a new file tests/integration_test_runner.cairo that 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.

ondrejsojka avatar May 28 '24 15:05 ondrejsojka

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.

Iwueseiter avatar May 28 '24 16:05 Iwueseiter

Yes you can, assigning you @Iwueseiter

ondrejsojka avatar May 28 '24 16:05 ondrejsojka

thank you @tensojka

Iwueseiter avatar May 28 '24 16:05 Iwueseiter

Hi @Iwueseiter any update on this issue ?

ptisserand avatar Jun 04 '24 22:06 ptisserand

@ptisserand I'm working on it. I will create a PR soon.

Iwueseiter avatar Jun 05 '24 04:06 Iwueseiter

Hey @Iwueseiter still on the issue?

od-hunter avatar Jun 18 '24 13:06 od-hunter

@od-hunter yes.

Iwueseiter avatar Jun 18 '24 14:06 Iwueseiter

@ptisserand You are now assigned as @Iwueseiter hasn't posted a draft PR.

ondrejsojka avatar Jun 30 '24 09:06 ondrejsojka

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?

ptisserand avatar Jul 16 '24 22:07 ptisserand