forked from Scaffold-Stark/scaffold-stark-2
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b037fe4
commit 66a02bd
Showing
5 changed files
with
1 addition
and
136 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
mod YourContract; | ||
#[cfg(test)] | ||
mod test { | ||
mod TestContract; | ||
|
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 |
---|---|---|
@@ -1,28 +1 @@ | ||
use contracts::YourContract::{IYourContractDispatcher, IYourContractDispatcherTrait}; | ||
use openzeppelin::utils::serde::SerializedAppend; | ||
use snforge_std::{declare, ContractClassTrait}; | ||
use starknet::ContractAddress; | ||
|
||
fn deploy_contract(name: ByteArray) -> ContractAddress { | ||
let contract = declare(name).unwrap(); | ||
let mut calldata = array![]; | ||
calldata.append_serde(0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca); | ||
let (contract_address, _) = contract.deploy(@calldata).unwrap(); | ||
contract_address | ||
} | ||
|
||
#[test] | ||
fn test_deployment_values() { | ||
let contract_address = deploy_contract("YourContract"); | ||
|
||
let dispatcher = IYourContractDispatcher { contract_address }; | ||
|
||
let current_gretting = dispatcher.gretting(); | ||
let expected_gretting: ByteArray = "Building Unstoppable Apps!!!"; | ||
assert_eq!(current_gretting, expected_gretting, "Should have the right message on deploy"); | ||
|
||
let new_greeting: ByteArray = "Learn Scaffold-Stark 2! :)"; | ||
dispatcher.set_gretting(new_greeting.clone(), 0); // we transfer 0 eth | ||
|
||
assert_eq!(dispatcher.gretting(), new_greeting, "Should allow setting a new message"); | ||
} |