-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
setup_state
::01] Detect and try executing hook (#307)
* add integration tests * find setup_state function * throw an exception if setup state is defined * use state dict in tests
- Loading branch information
1 parent
216514f
commit c793d4f
Showing
7 changed files
with
81 additions
and
6 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,17 @@ | ||
%lang starknet | ||
from starkware.cairo.common.cairo_builtins import HashBuiltin | ||
|
||
@view | ||
func setup_state(): | ||
%{ state["contract"] = deploy_contract("./src/main.cairo") %} | ||
return () | ||
end | ||
|
||
@view | ||
func test_contract_was_deployed_in_setup_state(): | ||
tempvar contract_address | ||
%{ assert state["contract"].contract_address is not None %} | ||
|
||
return () | ||
end |
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,21 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from protostar.commands.test.test_command import TestCommand | ||
from tests.integration.conftest import assert_cairo_test_cases | ||
|
||
|
||
@pytest.mark.skip | ||
@pytest.mark.asyncio | ||
async def test_testing_hooks(mocker): | ||
testing_summary = await TestCommand( | ||
project=mocker.MagicMock(), | ||
protostar_directory=mocker.MagicMock(), | ||
).test(target=Path(__file__).parent / "testing_hooks_test.cairo") | ||
|
||
assert_cairo_test_cases( | ||
testing_summary, | ||
expected_passed_test_cases_names=["test_contract_was_deployed_in_setup_state"], | ||
expected_failed_test_cases_names=[], | ||
) |