-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): adding JS tests to the CI (#284)
Co-authored-by: mohiiit <[email protected]>
- Loading branch information
Showing
18 changed files
with
499 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Task - Build Madara | ||
on: | ||
workflow_dispatch: | ||
workflow_call: | ||
jobs: | ||
build: | ||
permissions: | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
- uses: Swatinem/rust-cache@v2 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: 1.78.0 | ||
- name: Setup build deps | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y clang llvm libudev-dev protobuf-compiler | ||
- uses: rui314/setup-mold@v1 | ||
- uses: software-mansion/setup-scarb@v1 | ||
with: | ||
scarb-version: "2.8.2" | ||
- uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
- name: Build | ||
run: | | ||
cargo build --release --bin madara | ||
- name: Cache Madara binary | ||
uses: actions/cache@v3 | ||
with: | ||
path: target/release/madara | ||
key: ${{ runner.os }}-madara-${{ hashFiles('Cargo.lock') }} | ||
- name: Cache Cairo build artifacts | ||
uses: actions/cache@v3 | ||
with: | ||
path: cairo/target | ||
key: ${{ runner.os }}-madara-${{ hashFiles('Scarb.lock') }} |
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,32 @@ | ||
name: Starknet-js Compatibility Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
jobs: | ||
js-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Restore Madara binary | ||
uses: actions/cache@v3 | ||
with: | ||
path: target/release/madara | ||
key: ${{ runner.os }}-madara-${{ hashFiles('Cargo.lock') }} | ||
fail-on-cache-miss: true | ||
- name: Restore Cairo build artifacts | ||
uses: actions/cache@v3 | ||
with: | ||
path: cairo/target | ||
key: ${{ runner.os }}-madara-${{ hashFiles('Scarb.lock') }} | ||
fail-on-cache-miss: true | ||
- name: Setup dev chain and run tests | ||
run: | | ||
./target/release/madara --name madara --base-path ../madara_db --telemetry-disabled --rpc-port 9944 --rpc-cors "*" --rpc-external --devnet --preset devnet & | ||
MADARA_PID=$! | ||
while ! echo exit | nc localhost 9944; do sleep 1; done | ||
cd tests/js_tests | ||
npm install | ||
npm test | ||
kill $MADARA_PID |
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,4 @@ | ||
.env | ||
.env* | ||
|
||
# Generated by Cargo | ||
# will have compiled files and executables | ||
|
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,25 @@ | ||
#[starknet::interface] | ||
pub trait IHelloStarknet<TContractState> { | ||
fn increase_balance(ref self: TContractState, amount: felt252); | ||
fn get_balance(self: @TContractState) -> felt252; | ||
} | ||
|
||
#[starknet::contract] | ||
mod HelloStarknet { | ||
#[storage] | ||
struct Storage { | ||
balance: felt252, | ||
} | ||
|
||
#[abi(embed_v0)] | ||
impl HelloStarknetImpl of super::IHelloStarknet<ContractState> { | ||
fn increase_balance(ref self: ContractState, amount: felt252) { | ||
assert(amount != 0, 'Amount cannot be 0'); | ||
self.balance.write(self.balance.read() + amount); | ||
} | ||
|
||
fn get_balance(self: @ContractState) -> felt252 { | ||
self.balance.read() | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ pub mod erc20; | |
pub mod udc; | ||
pub mod account; | ||
pub mod test_account; | ||
pub mod hello; |
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,3 @@ | ||
lib | ||
package-lock.json | ||
node_modules |
Oops, something went wrong.