Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Dec 19, 2024
1 parent 2307ae5 commit 0dcbc1d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/oracle/pxe_store.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
unconstrained fn store_oracle<let N: u32>(key: Field, values: [Field; N]) -> Field {}

/// Store an array of values in local PXE database. The data is scoped to the current contract.
pub unconstrained fn store<let N: u32>(key: Field, values: [Field; N]) -> Field {
store_oracle(key, values)
pub unconstrained fn store<let N: u32>(key: Field, values: [Field; N]) {
let _ = store_oracle(key, values);
}

#[oracle(load)]
Expand Down
15 changes: 9 additions & 6 deletions noir-projects/noir-contracts/contracts/test_contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract Test {
note_getter::{get_notes, view_notes},
note_getter_options::NoteStatus,
},
oracle::random::random,
oracle::pxe_store::{load, store},
utils::comparison::Comparator,
};
use dep::token_portal_content_hash_lib::{
Expand Down Expand Up @@ -458,16 +458,19 @@ contract Test {
constant.value
}

unconstrained fn store_in_pxe_store(key: Field, values: [Field; 3]) {
store(key, values);
}

unconstrained fn load_from_pxe_store(key: Field) -> pub [Field; 3] {
load(key)
}

#[private]
fn test_nullifier_key_freshness(address: AztecAddress, public_nullifying_key: Point) {
assert_eq(get_public_keys(address).npk_m.inner, public_nullifying_key);
}

// Purely exists for testing
unconstrained fn get_random(kinda_seed: Field) -> pub Field {
kinda_seed * random()
}

pub struct DummyNote {
amount: Field,
secret_hash: Field,
Expand Down
35 changes: 35 additions & 0 deletions yarn-project/end-to-end/src/e2e_pxe_store.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
type Wallet
} from '@aztec/aztec.js';
import { TestContract } from '@aztec/noir-contracts.js/Test';

import { jest } from '@jest/globals';

import { setup } from './fixtures/utils.js';

const TIMEOUT = 120_000;

// TODO(#10724): Nuke this once the linked issue is implemented. Made this ugly test to check it works when first
// implementing this.
describe('Keys', () => {
jest.setTimeout(TIMEOUT);

let teardown: () => Promise<void>;

let testContract: TestContract;

beforeAll(async () => {
let wallet: Wallet;
({ teardown, wallet } = await setup(1));
testContract = await TestContract.deploy(wallet).send().deployed();
});

afterAll(() => teardown());

describe('using nsk_app to detect nullification', async () => {
const key = 6n;
const value = [268n, 862n, 268n ];
await testContract.methods.store_in_pxe_store(key, value).simulate();
expect(await testContract.methods.load_from_pxe_store(key).simulate()).toEqual(value);
});
});

0 comments on commit 0dcbc1d

Please sign in to comment.