From e1592d1eef0b175c1d31b0f0573df20c000bca39 Mon Sep 17 00:00:00 2001 From: broody Date: Sun, 17 Sep 2023 14:46:45 -0700 Subject: [PATCH] fix test --- src/components/risks.cairo | 2 +- src/systems/decide.cairo | 4 +--- src/systems/travel.cairo | 2 +- src/tests/travel.cairo | 4 +++- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/risks.cairo b/src/components/risks.cairo index 4ed416c2a..d930833f2 100644 --- a/src/components/risks.cairo +++ b/src/components/risks.cairo @@ -74,7 +74,7 @@ fn test_never_occurs() { fn test_always_occurs() { let seed = pedersen::pedersen(1, 1); let mut risks = Risks { game_id: 0, location_id: 0, travel: 100, capture: 0 }; - let player_status = risks.travel(seed, 1, 1); + let player_status = risks.travel(seed, 1, COPS_DRUG_THRESHOLD); assert(player_status != PlayerStatus::Normal(()), 'event did not occur'); } diff --git a/src/systems/decide.cairo b/src/systems/decide.cairo index 3c222acd7..2e9b91cbb 100644 --- a/src/systems/decide.cairo +++ b/src/systems/decide.cairo @@ -8,9 +8,7 @@ mod decide { use dojo::world::Context; use rollyourown::PlayerStatus; - use rollyourown::constants::{ - GANGS_PAYMENT, COPS_PAYMENT, HEALTH_IMPACT, COPS_DRUG_THRESHOLD - }; + use rollyourown::constants::{GANGS_PAYMENT, COPS_PAYMENT, HEALTH_IMPACT, COPS_DRUG_THRESHOLD}; use rollyourown::components::game::{Game, GameTrait}; use rollyourown::components::risks::{Risks, RisksTrait}; use rollyourown::components::player::{Player, PlayerTrait}; diff --git a/src/systems/travel.cairo b/src/systems/travel.cairo index 5f0db09b2..aa1d432a1 100644 --- a/src/systems/travel.cairo +++ b/src/systems/travel.cairo @@ -4,6 +4,7 @@ mod travel { use box::BoxTrait; use array::ArrayTrait; use starknet::ContractAddress; + use debug::PrintTrait; use dojo::world::{Context}; @@ -52,7 +53,6 @@ mod travel { let mut risks = get!(ctx.world, (game_id, next_location_id).into(), Risks); let seed = starknet::get_tx_info().unbox().transaction_hash; - player.status = risks.travel(seed, player.cash, player.drug_count); if player.status != PlayerStatus::Normal { set!(ctx.world, (player)); diff --git a/src/tests/travel.cairo b/src/tests/travel.cairo index 5bf1e915a..4c217f287 100644 --- a/src/tests/travel.cairo +++ b/src/tests/travel.cairo @@ -14,6 +14,7 @@ use dojo::test_utils::spawn_test_world; use rollyourown::PlayerStatus; use rollyourown::components::player::Player; use rollyourown::tests::create::{spawn_game, spawn_player}; +use rollyourown::constants::{TRAVEL_RISK}; #[test] #[available_gas(110000000)] @@ -26,10 +27,11 @@ fn test_travel_and_decision() { travel_calldata.append(game_id.into()); travel_calldata.append(brooklyn_id); + starknet::testing::set_transaction_hash(TRAVEL_RISK.into()); world.execute('travel', travel_calldata); let player = get!(world, (game_id, player_id).into(), (Player)); - assert(player.status == PlayerStatus::BeingMugged(()), 'incorrect status'); + assert(player.status != PlayerStatus::Normal, 'incorrect status'); assert(player.location_id != brooklyn_id, 'should not have traveled'); let mut decision_calldata = array::ArrayTrait::::new();