-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move core tests to avoid running them in dojo projects (#275)
- Loading branch information
Showing
15 changed files
with
327 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
We implement tests as a separate crate due to a tooling limitation where including core contracts in a dojo project also includes their tests cases. This way, dojo projects don't need to inadvertantly run core tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "dojo_core_tests" | ||
version = "0.1.0" | ||
description = "Tests for Dojo Core" | ||
|
||
[dependencies] | ||
dojo_core = { path = "../" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use core::traits::Into; | ||
use core::result::ResultTrait; | ||
use array::ArrayTrait; | ||
use option::OptionTrait; | ||
use traits::TryInto; | ||
|
||
use starknet::syscalls::deploy_syscall; | ||
use starknet::class_hash::Felt252TryIntoClassHash; | ||
use dojo_core::interfaces::IExecutorDispatcher; | ||
use dojo_core::interfaces::IExecutorDispatcherTrait; | ||
use dojo_core::executor::Executor; | ||
|
||
#[derive(Component)] | ||
struct Foo { | ||
a: felt252, | ||
b: u128, | ||
} | ||
|
||
#[system] | ||
mod Bar { | ||
use super::Foo; | ||
|
||
fn execute(foo: Foo) -> Foo { | ||
foo | ||
} | ||
} | ||
|
||
#[test] | ||
#[available_gas(30000000)] | ||
fn test_executor() { | ||
let constructor_calldata = array::ArrayTrait::<felt252>::new(); | ||
let (executor_address, _) = deploy_syscall( | ||
Executor::TEST_CLASS_HASH.try_into().unwrap(), 0, constructor_calldata.span(), false | ||
).unwrap(); | ||
|
||
let executor = IExecutorDispatcher { contract_address: executor_address }; | ||
|
||
let mut system_calldata = ArrayTrait::new(); | ||
system_calldata.append(42); | ||
system_calldata.append(53); | ||
let res = executor.execute(BarSystem::TEST_CLASS_HASH.try_into().unwrap(), system_calldata.span()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mod executor; | ||
mod storage; | ||
mod world; | ||
mod world_factory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod index; | ||
mod query; |
Oops, something went wrong.