Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
broody committed Sep 17, 2023
1 parent 3276aaa commit e1592d1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/risks.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
4 changes: 1 addition & 3 deletions src/systems/decide.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/systems/travel.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod travel {
use box::BoxTrait;
use array::ArrayTrait;
use starknet::ContractAddress;
use debug::PrintTrait;

use dojo::world::{Context};

Expand Down Expand Up @@ -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));
Expand Down
4 changes: 3 additions & 1 deletion src/tests/travel.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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::<felt252>::new();
Expand Down

0 comments on commit e1592d1

Please sign in to comment.