Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Jul 15, 2024
1 parent 6dc7598 commit 7a31314
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
context::{PublicContext, PrivateContext},
context::{PublicContext, PrivateContext, UnconstrainedContext},
state_vars::shared_mutable::{
shared_mutable::SharedMutable, scheduled_value_change::ScheduledValueChange,
scheduled_delay_change::ScheduledDelayChange
Expand Down Expand Up @@ -33,6 +33,10 @@ fn in_private(
SharedMutable::new(&mut env.private_at(historical_block_number), storage_slot)
}

fn in_unconstrained(env: TestEnvironment) -> SharedMutable<Field, TEST_INITIAL_DELAY, UnconstrainedContext> {
SharedMutable::new(env.unkonstrained(), storage_slot)
}

#[test]
fn test_get_current_value_in_public_initial() {
let env = setup();
Expand Down
14 changes: 14 additions & 0 deletions noir-projects/aztec-nr/aztec/src/test/helpers/cheatcodes.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ unconstrained pub fn reset() {
oracle_reset();
}

unconstrained pub fn get_chain_id() -> Field {
oracle_get_chain_id()
}

unconstrained pub fn get_version() -> Field {
oracle_get_version()
}

unconstrained pub fn get_contract_address() -> AztecAddress {
oracle_get_contract_address()
}
Expand Down Expand Up @@ -112,6 +120,12 @@ unconstrained pub fn set_fn_selector(selector: FunctionSelector) {
#[oracle(reset)]
fn oracle_reset() {}

#[oracle(getChainId)]
fn oracle_get_chain_id() -> Field {}

#[oracle(getVersion)]
fn oracle_get_version() -> Field {}

#[oracle(getContractAddress)]
fn oracle_get_contract_address() -> AztecAddress {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use dep::protocol_types::{
use crate::context::inputs::{PublicContextInputs, PrivateContextInputs};
use crate::context::{packed_returns::PackedReturns, call_interfaces::CallInterface};

use crate::context::{PrivateContext, PublicContext, PrivateVoidCallInterface};
use crate::context::{PrivateContext, PublicContext, UnconstrainedContext, PrivateVoidCallInterface};
use crate::test::helpers::{cheatcodes, utils::{apply_side_effects_private, Deployer, TestAccount}, keys};
use crate::keys::constants::{NULLIFIER_INDEX, INCOMING_INDEX, OUTGOING_INDEX, TAGGING_INDEX};
use crate::hash::{hash_args, hash_args_array};
Expand Down Expand Up @@ -56,6 +56,11 @@ impl TestEnvironment {
self.private_at(cheatcodes::get_block_number())
}

// unconstrained is a key word, so we mis-spell purposefully here, like we do with contrakt
fn unkonstrained(self) -> UnconstrainedContext {
UnconstrainedContext::new()
}

fn private_at(&mut self, historical_block_number: u32) -> PrivateContext {
if historical_block_number >= cheatcodes::get_block_number() {
self.advance_block_to(historical_block_number + 1);
Expand Down

0 comments on commit 7a31314

Please sign in to comment.