Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kroist committed Feb 16, 2024
1 parent 16e3b4f commit b380570
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,5 @@ jobs:
- name: Run checks for `shielder/contract`
run: cd shielder/ && make check-shielder

- name: Build shielder contract
run: cd shielder/ && make build-shielder

- name: Run tests for `shielder/contract`
run: cd shielder/ && make tests
5 changes: 3 additions & 2 deletions shielder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ help: # Show help for each of the Makefile recipes.
.PHONY: check-shielder
check-shielder: ## Run cargo checks on shielder contract.
@echo "Checking shielder contract" ; \
cargo clippy --manifest-path contract/Cargo.toml -- -D warnings ; \
cargo fmt --quiet --all --check --manifest-path contract/Cargo.toml ; \


Expand All @@ -22,12 +23,12 @@ build-shielder: ## Builds shielder contracts.
cargo contract build --quiet --manifest-path contract/Cargo.toml --release ; \

.PHONY: setup-tests
setup-tests: build-psp22 ## Builds contracts and generates wrappers.
setup-tests: build-psp22 build-shielder ## Builds contracts and generates wrappers.

.PHONY: tests
tests: setup-tests ## Runs tests for contract.
@echo "Running drink tests" ; \
cargo test --quiet --manifest-path contract/Cargo.toml --release -- --nocapture ; \

.PHONY:
all: check-shielder tests build-shielder ## Runs all tests.
all: check-shielder tests
6 changes: 3 additions & 3 deletions shielder/contract/drink_tests/utils/psp22.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn get_psp22_balance(
let res = session.call_with_address(
token.clone(),
"PSP22::balance_of",
&[&address.to_string()],
&[address.to_string()],
NO_ENDOWMENT,
)??;
Ok(res)
Expand All @@ -52,7 +52,7 @@ pub fn get_psp22_allowance(
let res = session.call_with_address(
token.clone(),
"PSP22::allowance",
&[&from.to_string(), &to.to_string()],
&[from.to_string(), to.to_string()],
NO_ENDOWMENT,
)??;
Ok(res)
Expand All @@ -68,7 +68,7 @@ pub fn psp22_approve(
session.call_with_address(
token.clone(),
"PSP22::approve",
&[&*to.to_string(), formatted_amount.as_str()],
&[to.to_string(), formatted_amount],
NO_ENDOWMENT,
)??;
Ok(())
Expand Down
4 changes: 4 additions & 0 deletions shielder/contract/mocked_zk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ use crate::types::Scalar;

pub const TOKENS_NUMBER: usize = 10;
pub const MOCKED_TOKEN: Scalar = Scalar::from_bytes([228_u8; 32]);

pub fn mocked_user() -> Scalar {
1_u128.into()
}
10 changes: 5 additions & 5 deletions shielder/contract/mocked_zk/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::{
use crate::{
contract::OpPub,
errors::ShielderError,
mocked_zk::{MOCKED_TOKEN, TOKENS_NUMBER},
mocked_zk::{mocked_user, MOCKED_TOKEN, TOKENS_NUMBER},
test_utils::merkle::MerkleTree,
types::Scalar,
};
Expand All @@ -24,7 +24,7 @@ fn create_empty_note_proof(id: Scalar, nullifier: Scalar, trapdoor: Scalar) -> (
trapdoor,
nullifier,
OpPriv {
user: 1_u128.into(),
user: mocked_user(),
},
acc_new,
);
Expand All @@ -40,7 +40,7 @@ fn update_account(
merkle_proof_leaf_id: u32,
) -> (Scalar, ZkProof) {
let op_priv = OpPriv {
user: 1_u128.into(),
user: mocked_user(),
};
let operation = Operation::combine(op_pub, op_priv).unwrap();
proof
Expand Down Expand Up @@ -98,7 +98,7 @@ fn test_update_note() -> Result<(), ShielderError> {
let op_pub = crate::contract::OpPub::Deposit {
amount: 10,
token: MOCKED_TOKEN,
user: 1_u128.into(),
user: mocked_user(),
};

let (h_new_note, proof) =
Expand Down Expand Up @@ -128,7 +128,7 @@ fn test_update_note_fail_op_priv() -> Result<(), ShielderError> {
let op_pub = crate::contract::OpPub::Deposit {
amount: 10,
token: MOCKED_TOKEN,
user: 1_u128.into(),
user: mocked_user(),
};
let op_pub_fake = crate::contract::OpPub::Deposit {
amount: 10,
Expand Down

0 comments on commit b380570

Please sign in to comment.