Skip to content

Commit

Permalink
fix ci (#1591)
Browse files Browse the repository at this point in the history
* fix ci

* fix tests

* fix tests
  • Loading branch information
credence0x authored Sep 15, 2024
1 parent 704c6c1 commit 0beffff
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 16 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ jobs:
- name: Run Dojo Test for ${{ matrix.test }}
run: |
cd contracts && sozo test -f ${{ matrix.test }} --print-resource-usage
continue-on-error: true
test-scarb-fmt:
needs: [setup-environment]
Expand Down
3 changes: 0 additions & 3 deletions contracts/src/systems/combat/contracts.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,6 @@ mod combat_systems {

// leave battle
let mut battle: Battle = get!(world, battle_id, Battle);

InternalCombatImpl::leave_battle(world, ref battle, ref caller_army);

battle.update_state();
let battle_was_active = (battle.has_started() && !battle.has_ended());
InternalCombatImpl::leave_battle(world, ref battle, ref caller_army);
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/systems/combat/tests/army_buy_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn setup() -> (IWorldDispatcher, ICombatContractDispatcher, ID, ID) {
starknet::testing::set_account_contract_address(contract_address_const::<REALMS_OWNER>());

let realm_id = realm_system_dispatcher
.create(1, 1, 1, 1, 1, 1, 1, 1, 1, Position { entity_id: 0, x: REALM_COORD_X, y: REALM_COORD_Y });
.create('Mysticora', 1, 1, 1, 1, 1, 1, 1, 1, 1, Position { entity_id: 0, x: REALM_COORD_X, y: REALM_COORD_Y });
mint(
world,
realm_id,
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/systems/combat/tests/army_create_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn setup() -> (IWorldDispatcher, ICombatContractDispatcher, ID,) {
starknet::testing::set_account_contract_address(contract_address_const::<REALMS_OWNER>());

let realm_id = realm_system_dispatcher
.create(1, 1, 1, 1, 1, 1, 1, 1, 1, Position { entity_id: 0, x: REALM_COORD_X, y: REALM_COORD_Y });
.create('Mysticora', 1, 1, 1, 1, 1, 1, 1, 1, 1, Position { entity_id: 0, x: REALM_COORD_X, y: REALM_COORD_Y });
mint(
world,
realm_id,
Expand Down
36 changes: 33 additions & 3 deletions contracts/src/systems/combat/tests/battle_leave_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,17 @@ fn setup() -> (IWorldDispatcher, ICombatContractDispatcher, ID, ID, ID, ID, ID,
starknet::testing::set_account_contract_address(contract_address_const::<PLAYER_1_REALM_OWNER>());
let player_1_realm_id = realm_system_dispatcher
.create(
1, 1, 1, 1, 1, 1, 1, 1, 1, Position { entity_id: 0, x: PLAYER_1_REALM_COORD_X, y: PLAYER_1_REALM_COORD_Y }
'Mysticora',
1,
1,
1,
1,
1,
1,
1,
1,
1,
Position { entity_id: 0, x: PLAYER_1_REALM_COORD_X, y: PLAYER_1_REALM_COORD_Y }
);
mint(
world,
Expand Down Expand Up @@ -129,7 +139,17 @@ fn setup() -> (IWorldDispatcher, ICombatContractDispatcher, ID, ID, ID, ID, ID,
starknet::testing::set_account_contract_address(contract_address_const::<PLAYER_2_REALM_OWNER>());
let player_2_realm_id = realm_system_dispatcher
.create(
1, 1, 1, 1, 1, 1, 1, 1, 1, Position { entity_id: 0, x: PLAYER_2_REALM_COORD_X, y: PLAYER_2_REALM_COORD_Y }
'Mysticora',
1,
1,
1,
1,
1,
1,
1,
1,
1,
Position { entity_id: 0, x: PLAYER_2_REALM_COORD_X, y: PLAYER_2_REALM_COORD_Y }
);
mint(
world,
Expand Down Expand Up @@ -159,7 +179,17 @@ fn setup() -> (IWorldDispatcher, ICombatContractDispatcher, ID, ID, ID, ID, ID,
starknet::testing::set_account_contract_address(contract_address_const::<PLAYER_3_REALM_OWNER>());
let player_3_realm_id = realm_system_dispatcher
.create(
1, 1, 1, 1, 1, 1, 1, 1, 1, Position { entity_id: 0, x: PLAYER_3_REALM_COORD_X, y: PLAYER_3_REALM_COORD_Y }
'Mysticora',
1,
1,
1,
1,
1,
1,
1,
1,
1,
Position { entity_id: 0, x: PLAYER_3_REALM_COORD_X, y: PLAYER_3_REALM_COORD_Y }
);
mint(
world,
Expand Down
36 changes: 33 additions & 3 deletions contracts/src/systems/combat/tests/battle_start_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,17 @@ fn setup() -> (IWorldDispatcher, ICombatContractDispatcher, ID, ID, ID, ID, ID,
starknet::testing::set_contract_address(contract_address_const::<PLAYER_1_REALM_OWNER>());
let player_1_realm_id = realm_system_dispatcher
.create(
1, 1, 1, 1, 1, 1, 1, 1, 1, Position { entity_id: 0, x: PLAYER_1_REALM_COORD_X, y: PLAYER_1_REALM_COORD_Y }
'Mysticora1',
1,
1,
1,
1,
1,
1,
1,
1,
1,
Position { entity_id: 0, x: PLAYER_1_REALM_COORD_X, y: PLAYER_1_REALM_COORD_Y }
);
mint(
world,
Expand Down Expand Up @@ -132,7 +142,17 @@ fn setup() -> (IWorldDispatcher, ICombatContractDispatcher, ID, ID, ID, ID, ID,
starknet::testing::set_contract_address(contract_address_const::<PLAYER_2_REALM_OWNER>());
let player_2_realm_id = realm_system_dispatcher
.create(
1, 1, 1, 1, 1, 1, 1, 1, 1, Position { entity_id: 0, x: PLAYER_2_REALM_COORD_X, y: PLAYER_2_REALM_COORD_Y }
'Mysticora2',
1,
1,
1,
1,
1,
1,
1,
1,
1,
Position { entity_id: 0, x: PLAYER_2_REALM_COORD_X, y: PLAYER_2_REALM_COORD_Y }
);
mint(
world,
Expand Down Expand Up @@ -161,7 +181,17 @@ fn setup() -> (IWorldDispatcher, ICombatContractDispatcher, ID, ID, ID, ID, ID,
starknet::testing::set_contract_address(contract_address_const::<PLAYER_3_REALM_OWNER>());
let player_3_realm_id = realm_system_dispatcher
.create(
1, 1, 1, 1, 1, 1, 1, 1, 1, Position { entity_id: 0, x: PLAYER_3_REALM_COORD_X, y: PLAYER_3_REALM_COORD_Y }
'Mysticora3',
1,
1,
1,
1,
1,
1,
1,
1,
1,
Position { entity_id: 0, x: PLAYER_3_REALM_COORD_X, y: PLAYER_3_REALM_COORD_Y }
);
mint(
world,
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/systems/map/tests.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ use eternum::utils::testing::{

use starknet::contract_address_const;

const INITIAL_WHEAT_BALANCE: u128 = 1_000_000;
const INITIAL_FISH_BALANCE: u128 = 1_000_000;
const INITIAL_KNIGHT_BALANCE: u128 = 10_000;
const INITIAL_WHEAT_BALANCE: u128 = 10_000_000;
const INITIAL_FISH_BALANCE: u128 = 10_000_000;
const INITIAL_KNIGHT_BALANCE: u128 = 10_000_000;

const TIMESTAMP: u64 = 10_000;

Expand Down
1 change: 1 addition & 0 deletions contracts/src/systems/realm/tests.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ fn test_realm_create() {

let realm_entity_id = realm_systems_dispatcher
.create(
'Mysticora',
realm_id,
resource_types_packed,
resource_types_count,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ fn test_caller_not_taker() {
#[available_gas(3000000000000)]
#[should_panic(
expected: (
"not enough resources, Resource (entity id: 3, resource type: DONKEY, balance: 0). deduction: 1000",
"not enough resources, Resource (entity id: 4, resource type: DONKEY, balance: 0). deduction: 1000",
'ENTRYPOINT_FAILED'
)
)]
Expand Down
1 change: 1 addition & 0 deletions contracts/src/utils/testing/general.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use eternum::utils::map::biomes::Biome;
fn spawn_realm(world: IWorldDispatcher, realm_systems_dispatcher: IRealmSystemsDispatcher, position: Position) -> ID {
let realm_entity_id = realm_systems_dispatcher
.create(
'Mysticora',
1, // realm id
0x20309, // resource_types_packed // 2,3,9 // stone, coal, gold
3, // resource_types_count
Expand Down

0 comments on commit 0beffff

Please sign in to comment.