Skip to content

Commit

Permalink
interactor test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiuosvat committed Aug 21, 2024
1 parent 186cc17 commit de51cb6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
68 changes: 31 additions & 37 deletions contracts/potlock/interact-rs/src/potlock_interactor_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,69 +691,75 @@ impl ContractInteract {
async fn test_deploy() {
let mut interact = ContractInteract::new().await;
interact.deploy().await;
interact.change_fee_for_pots(1).await;
}

#[tokio::test]
async fn test_add_pot() {
let mut interact = ContractInteract::new().await;
interact.deploy().await;
interact.change_fee_for_pots(1).await;
interact.add_pot().await;
}

#[tokio::test]
async fn test_accept_pot() {
let mut interact = ContractInteract::new().await;
interact.deploy().await;
interact.change_fee_for_pots(1).await;
interact.add_pot().await;
interact.accept_pot(1).await;
}

#[tokio::test]
async fn test_view_potlocks() {
let mut interact = ContractInteract::new().await;
interact.add_pot().await;
interact.get_potlocks().await;
}
// #[tokio::test]
// async fn test_view_potlocks() {
// let mut interact = ContractInteract::new().await;
// interact.add_pot().await;
// interact.get_potlocks().await;
// }

#[tokio::test]
async fn test_change_fee_wrong_params() {
async fn test_change_fee_twice() {
let mut interact = ContractInteract::new().await;
interact.deploy().await;
interact.change_fee_for_pots(1).await;
interact.fee_amount().await;
interact.change_fee_for_pots(1).await;
interact.fee_amount().await;

// interact.change_fee_for_pots_params(
// "ALICE",
// FEE_AMOUNT,
// ExpectError(4, "Invalid token provided")
// ).await;
}

#[tokio::test]
async fn test_accept_pot_not_created() {
let mut interact = ContractInteract::new().await;
interact.deploy().await;
let potlock_wanted = 0;
interact.accept_pot_param(potlock_wanted, ExpectError(4, "Potlock doesn't exist!")).await;
}

#[tokio::test]
async fn test_remove_pot_not_created() {
let mut interact = ContractInteract::new().await;
interact.deploy().await;
let potlock_wanted = 0;
interact.remove_pot_param(potlock_wanted, ExpectError(4, "Potlock doesn't exist!")).await;
}

#[tokio::test]
async fn test_accept_application_not_created() {
let mut interact = ContractInteract::new().await;
interact.deploy().await;
let project_wanted = 0;
interact.accept_application_params(project_wanted, ExpectError(4, "Project doesn't exist!")).await;
}

#[tokio::test]
async fn test_reject_donation_params() {
let mut interact = ContractInteract::new().await;
interact.deploy().await;
interact.change_fee_for_pots(1).await;
interact.add_pot().await;
let potlock_wanted = 0;
let wanted_user = Bech32Address::from_bech32_string(("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th").to_string());
let wanted_user_2 = Bech32Address::from_bech32_string(("").to_string());
let wanted_user_2 = Bech32Address::from_bech32_string(("erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8").to_string());
interact.reject_donation_param(potlock_wanted, ExpectError(4, "Potlock doesn't exist!"), wanted_user).await;
interact.reject_donation_param(1, ExpectError(4, "No donation for this user"), wanted_user_2).await;
}
Expand All @@ -762,6 +768,9 @@ async fn test_reject_donation_params() {
async fn test_add_pot_params(){
let mut interact = ContractInteract::new().await;

interact.deploy().await;
interact.change_fee_for_pots(1).await;

let token_id = "ALICE";
interact.add_pot_params(
token_id,
Expand All @@ -780,6 +789,9 @@ async fn test_add_pot_params(){
async fn test_donate_to_project() {
let mut interact = ContractInteract::new().await;

interact.deploy().await;
interact.change_fee_for_pots(1).await;

let wanted_proposer = 1;
let potlock_wanted = 1;
let project_wanted : u32 = 1;
Expand All @@ -804,6 +816,10 @@ async fn test_donate_to_project() {
#[tokio::test]
async fn test_multiple_donations() {
let mut interact = ContractInteract::new().await;
interact.deploy().await;
interact.change_fee_for_pots(1).await;

interact.add_pot().await;

interact.donate_to_pot().await;
interact.pot_donations().await;
Expand All @@ -821,17 +837,6 @@ async fn test_multiple_donations_same_token(){
interact.donate_to_pot().await;
interact.pot_donations().await;
}
#[tokio::test]
async fn test_multiple_accept_project(){
let mut interact = ContractInteract::new().await;
let potlock_wanted = 1;
let project_wanted = 1;
let wanted_proposer = 1;
interact.apply_for_pot(potlock_wanted,wanted_proposer).await;
interact.accept_application(project_wanted).await;
interact.accept_application(project_wanted).await;
interact.accept_application(project_wanted).await;
}

#[tokio::test]
async fn test_different_pot_project_donations(){
Expand Down Expand Up @@ -879,14 +884,3 @@ async fn test_donate_to_project_inactive_then_activate (){
interact.donate_to_project().await;
}

#[tokio::test]
async fn test_change_fee_twice(){
let mut interact = ContractInteract::new().await;
interact.deploy().await;
interact.change_fee_for_pots(1).await;
interact.fee_amount().await;
interact.change_fee_for_pots(2).await;
interact.fee_amount().await;
}


2 changes: 1 addition & 1 deletion contracts/potlock/interact-rs/state.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
contract_address = "erd1qqqqqqqqqqqqqpgqkp8vjrmmztsy2nj4pmrzu4cyh0apksp4d8ss7j6dp8"
contract_address = "erd1qqqqqqqqqqqqqpgqelc76mfxjh4ngjl8l82w223x8asa4q05d8ssks9024"

0 comments on commit de51cb6

Please sign in to comment.