Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ametel01 committed Jan 5, 2024
1 parent c86b931 commit 7aba758
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 11 additions & 5 deletions src/actions/game_actions.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#[starknet::interface]
trait IGameActions<TContractState> {
fn spawn(self: @TContractState, owner: starknet::ContractAddress, price: u128, speed: usize);
fn spawn(
self: @TContractState,
owner: starknet::ContractAddress,
nft_address: starknet::ContractAddress,
price: u128,
speed: usize
);
fn generate_planet(self: @TContractState);
}

Expand Down Expand Up @@ -117,9 +123,9 @@ mod tests {

#[test]
fn test_spawn() {
let (world, actions_system) = setup_world();
let (world, actions_system, nft) = setup_world();

actions_system.spawn(OWNER(), PRICE, GAME_SPEED);
actions_system.spawn(OWNER(), nft, PRICE, GAME_SPEED);
actions_system.generate_planet();

let game_setup = get!(world, constants::GAME_ID, (GameSetup));
Expand All @@ -134,8 +140,8 @@ mod tests {

#[test]
fn test_generate_planet() {
let (world, actions_system) = setup_world();
actions_system.spawn(OWNER(), PRICE, GAME_SPEED);
let (world, actions_system, nft) = setup_world();
actions_system.spawn(OWNER(), nft, PRICE, GAME_SPEED);

set_contract_address(ACCOUNT_1());
actions_system.generate_planet();
Expand Down
4 changes: 2 additions & 2 deletions src/utils/test_utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ fn setup_world() -> (IWorldDispatcher, IGameActionsDispatcher, ContractAddress)
let contract_address = world
.deploy_contract('salt', actions::TEST_CLASS_HASH.try_into().unwrap());
let actions_system = IGameActionsDispatcher { contract_address };
let nft = deploy_nft(array!['NoGame NFT', 'NGPLANET', world.contract_address]);
let nft = deploy_nft(array!['NoGame NFT', 'NGPLANET', world.contract_address.into()]);

(world, actions_system, nft)
}

fn deploy_nft(calldata: Array<felt252>) -> ContractAddress {
let (address, _) = starknet::deploy_syscall(
ERC721::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false
ERC721NoGame::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false
)
.unwrap();
address
Expand Down

0 comments on commit 7aba758

Please sign in to comment.