Skip to content
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

[test] Add all tests for FundManager Contract #90

Closed
EmmanuelAR opened this issue Sep 25, 2024 · 18 comments · Fixed by #118
Closed

[test] Add all tests for FundManager Contract #90

EmmanuelAR opened this issue Sep 25, 2024 · 18 comments · Fixed by #118
Assignees
Labels
good first issue Good for newcomers ODHack8 ODHack8.0 issue

Comments

@EmmanuelAR
Copy link
Collaborator

This issue will be part of ODHack8.0, please apply via Onlydust app

  • Add a test file for the FundManager contract. It must test all the methods within the contract, including constructors.
  • It should follow the standard already set by previous tests in the project.
  • The tests should evaluate the success cases of the methods and possible errors in their execution.
  • Knowledge in Cairo and experience with scarb and snforge is recommended.
  • Please read contributors guide before asking for an issue.
@EmmanuelAR EmmanuelAR added good first issue Good for newcomers ODHack8 ODHack8.0 issue labels Sep 25, 2024
@martinvibes
Copy link

hello @dmirgaleev i am a frontend dev and blockchain developer
please can i work on this issue :) and would love to be a contributor

Copy link

onlydustapp bot commented Sep 25, 2024

Hi @martinvibes!
Maintainers during the ODHack # 8.0 will be tracking applications via OnlyDust.
Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

@manlikeHB
Copy link
Contributor

Hi @EmmanuelAR @adrianvrj, I am a cario developer with lots of experience writing test for cairo contract, I would like to work on this.

Copy link

onlydustapp bot commented Sep 25, 2024

Hi @manlikeHB!
Maintainers during the ODHack # 8.0 will be tracking applications via OnlyDust.
Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

@CollinsC1O
Copy link
Contributor

@EmmanuelAR I will love to work on this

Copy link

onlydustapp bot commented Sep 26, 2024

Hi @CollinsC1O!
Maintainers during the ODHack # 8.0 will be tracking applications via OnlyDust.
Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

@CollinsC1O
Copy link
Contributor

hello @EmmanuelAR I'm a frontend and also a blockchain developer.
can I work on this

Copy link

onlydustapp bot commented Sep 26, 2024

Hi @CollinsC1O!
Maintainers during the ODHack # 8.0 will be tracking applications via OnlyDust.
Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

@MPSxDev
Copy link
Contributor

MPSxDev commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello, I am Manuel, a process engineer and web3 developer. I have participated in Starknet Bootcamps and am an Elite winner of Speedrunstark. I have a high capacity to solve problems. I am a member of the DojoCoding community.
I hope this issue is assigned to me. I am available to work immediately to achieve what is required in the shortest time possible.

How I plan on tackling this issue

To address the requirements of the issue, I will proceed with the following:

  • Add a dedicated test file for the FundManager contract.
  • Write comprehensive tests for all the contract's methods, including constructors.
  • Ensure the tests follow the structure and standard set by the existing test suite in the project.
  • Validate both successful method executions and potential error cases.

@jorgezerpa
Copy link
Contributor

jorgezerpa commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi!! I'm a fullstack developer with 4 year of experience building apps, and a couple months into web3 world. Also I'm part of Dojo coding community⛩️

How I plan on tackling this issue

I will create a "test_fund_manager.cairo" file, and following the standards of the existant tests I will:

  1. Create functions to get needed constants like OWNER, ID, and any other constant usefull to setup contracts and test values
  2. Create a setup_fund function the deploy a "Fund" contract to get its hash class, and then use it on setup function to initiate the "FundManager" contract.
  3. Once the basic setup is ready, I will implement the next testing functions:
  • test_constructor
  • test_new_fund
  • test_get_fund
  • test_get_current_id
  • Any other if its requiered

Quick Example (it's just a quick blueprint, to show you how it will looks like):

// *************************
//                              FUND MANAGER TEST
// *************************
use starknet::{ContractAddress, contract_address_const, };

use snforge_std::{declare, ContractClassTrait, CheatTarget, get_class_hash};

use openzeppelin::utils::serde::SerializedAppend;

use gostarkme::fund::IFundDispatcher;
use gostarkme::fund::IFundDispatcherTrait;
use gostarkme::fundManager::IFundManagerDispatcher;
use gostarkme::fundManager::IFundManagerDispatcherTrait;

use starknet::class_hash::ClassHash;


fn ID() -> u128 {
    1
}
fn OWNER() -> ContractAddress {
    contract_address_const::<'OWNER'>()
}
fn OTHER_USER() -> ContractAddress {
    contract_address_const::<'USER'>()
}
fn NAME() -> felt252 {
    'NAME_FUND_TEST'
}
fn REASON() -> ByteArray {
    "Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum"
}
fn GOAL() -> u64 {
    1000
}

fn _setup_fund_() -> ContractAddress {
    let contract = declare("Fund");
    let mut calldata: Array<felt252> = array![];
    calldata.append_serde(ID());
    calldata.append_serde(OWNER());
    calldata.append_serde(NAME());
    calldata.append_serde(GOAL());
    contract.deploy(@calldata).unwrap() 
}

fn _setup_() -> ContractAddress {
    let fund_contract_address = _setup_fund_();
    let fund_class_hash = get_class_hash(fund_contract_address);
    let contract = declare("FundManager");
    let mut calldata: Array<felt252> = array![];
    calldata.append_serde(fund_class_hash);
    contract.deploy(@calldata).unwrap() 
}
// *************************
//                              TEST
// *************************
#[test]
fn test_constructor() {
    let contract_address = _setup_();
    let dispatcher = IFundManagerDispatcher { contract_address };
    let current_id = dispatcher.getCurrentId();
    assert(current_id == 0, 'Invalid id');
}

#[test]
fn test_new_fund(){}

#[test]
fn test_get_fund(){}

#[test]
fn test_get_current_id(){}

Stimated completion time 2-3 days

⛩️I'll be happy to contribute, I'm attentive.⛩️

@mubarak23
Copy link

mubarak23 commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi, I'm MUBARAK and I'll be working on issue #87.

I am a Experience Cairo smart contract developer with experience working on projects such as Just Art Peace, Dojo, Kart, TBA, and Shinigami. Before transitioning to Cairo development, I was a backend developer specializing in Rust.

My recent work with cairo starknet

My recent work with rust

How I plan on tackling this issue

This is how I would tackle this issue:

  • Follow the existing setup for the test
    • Test for successful case such as
      • Contract owner is set
      • donator_class_hash is set
      • newDonator is added
    • Test for fail case such as
      • Reading for donor that does not exist
      • Test for the wrong owner
      • Test for the wrong donator_class_hash

ETH: 24HRS

@manlikeHB
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi, I am Cairo dev with lots of experience contributing to Cairo projects, my OD profile is a witness to this.

How I plan on tackling this issue

would go through the code base and understand the functionality of the FundManager contract, after that I would write a robust test ensuring all test cases are covered and the contract behaves as expected.

@jimenezz22
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am an active member of the Dojo Coding community in Costa Rica, with experience in Cairo, having built onchain games like ByteBeasts and contributed to open-source projects such as CairoLint, where I implemented tests for Cairo lints. Additionally, I taught Cairo during the Starknet Bootcamp for Dojo Coding. I also have experience with TypeScript, contributing to Starknet Quest by developing components like ComboBoxes, among others.

How I plan on tackling this issue

To tackle this issue, my approach would be:

  1. Review Existing Tests: I will first review the test files already present in the repository to ensure that the new tests I write follow the project's standard structure and style.
  2. Understand the FundManager Contract: I will thoroughly review the FundManager contract, focusing on its methods and constructors, to ensure I fully understand the functionality and potential edge cases.
  3. Write Success Case Tests: For each method, I will write tests that verify the expected behavior when inputs are valid and conditions are met. This includes constructors and any important business logic within the contract.
  4. Write Error Case Tests: I will also write tests that simulate possible failures, such as invalid inputs or edge cases, ensuring the contract handles these gracefully.
  5. Ensure Compatibility: I will use tools like Scarb and Snforge to run the tests, ensuring they all pass without any errors and are compatible with the CI setup.

Estimated Time to Completion: 3-4 days

@diegoTech14
Copy link
Contributor

diegoTech14 commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello @EmmanuelAR,

I'm a software engineer from Costa Rica and a member of Dojo Coding. I have worked with backend technologies such as Node.js, PhP, Java, C#, Cairo, and also I've created some tests in Cairo. I'd love the opportunity to help with this issue and contribute to your project.

How I plan on tackling this issue

My first step will be to thoroughly understand the codebase and get the necessary context. This will involve familiarizing myself with the architecture, dependencies, and existing documentation, allowing me to make informed decisions moving forward.

To tackle this issue, my roadmap would be:

1. Analyze the FundManager smart contract to gain a deep understanding of its functionality.
2. Thoroughly test each method of the contract, adhering to the existing test structure and best practices.
3. Develop comprehensive test cases to cover various scenarios and edge cases.
4. Update and enhance any relevant documentation to reflect the changes and ensure clarity for future reference.

For this issue I will use all needed dependencies with the correct version.

I estimate it can take around 3 days.

Looking forward to hearing from you!

Best regards.

@Shoetan
Copy link

Shoetan commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi, I'm Emmanuel and I'll be working on issue:

I estimate this will take 2 days to finish
Past contributor to Carbonable where I contributed by writing tests. PR Link carbonable-labs/carbon-protocol-v3#82

How I plan on tackling this issue

This is how I will tackle this issue:
Understand what the donator manager contract does and how it does it.
Create the test file [test-fundManager.cairo] in the test folder.
Get dispatcher and dispatcherTrait from the contract to access contract functions in the test file.
Write the test following already laid down structure and format.
Make sure I run scarb fmt to format the code properly.
Run the test by running scarb run test as defined in the scarb.toml file.
Response promptly to comments from maintainers.
I will make revision and adjustments based on maintainers' feedback

@No-bodyq
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a full stack and block chain dev with experience in writing test for smart contracts in cairo via only dust. Here is my profile: https://app.onlydust.com/u/No-bodyq

How I plan on tackling this issue

I'll begin by reviewing the contributor guide and current test patterns to ensure that the test structure remains consistent. Next, I'll thoroughly examine the FundManager contract, listing all its methods and constructors to identify potential success cases as well as possible error conditions. After that, I'll write comprehensive tests for each method, ensuring both successful scenarios and edge cases are properly addressed. Finally, I'll validate the tests using scarb and snforge to ensure they adhere to the project's standards and execute as expected.

@saimeunt
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have multiple experience in Cairo contracts development and testing with snforge:
https://github.com/carbonable-labs/cairo-erc-7498
https://github.com/carbonable-labs/cairo-erc-7496
NethermindEth/StarknetByExample@e287afa

How I plan on tackling this issue

I will carefully add tests to the FundManager contract making sure every possible route is taken (aiming for 100% coverage) by asserting that we get the expected results, errors and events emitted along the way.

@melnikga
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

My background and how it can be leveraged
Can I take this? I’ve participated in almost every ODHack. I have extensive experience in frontend development. I can handle this task.

How I plan on tackling this issue

In all the projects I worked on during ODHacks, I used Next.js, so implementing this page will be easy for me.

My profile on OD: https://app.onlydust.com/u/melnikga

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers ODHack8 ODHack8.0 issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.