Skip to content

Commit 7d909e0

Browse files
chore: add txe session (#16546)
This introduces `TXESession`, which handles a session's state (the counterpart to each noir `#[test]`). Combined with #16537, it means we're now in a good place to split the oracle into smaller oracles that get swapped depending on the session state.
2 parents 5a1e4b8 + 9d59be3 commit 7d909e0

File tree

16 files changed

+243
-458
lines changed

16 files changed

+243
-458
lines changed

noir-projects/aztec-nr/aztec/src/context/returns_hash.nr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mod test {
4545

4646
#[test]
4747
unconstrained fn retrieves_preimage() {
48-
let env = TestEnvironment::_new();
48+
let env = TestEnvironment::new();
4949
env.private_context(|_| {
5050
let value = MockStruct::new(4, 7);
5151
let serialized = value.serialize();
@@ -59,7 +59,7 @@ mod test {
5959

6060
#[test]
6161
unconstrained fn retrieves_empty_preimage() {
62-
let env = TestEnvironment::_new();
62+
let env = TestEnvironment::new();
6363
env.private_context(|_| {
6464
let value = ();
6565
let serialized = [];

noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ where
3737

3838
#[test]
3939
unconstrained fn processes_single_note() {
40-
let env = TestEnvironment::_new();
40+
let env = TestEnvironment::new();
4141

4242
env.private_context(|context| {
4343
let mut notes_to_constrain = [Option::none(); _];
@@ -54,7 +54,7 @@ unconstrained fn processes_single_note() {
5454

5555
#[test]
5656
unconstrained fn processes_many_notes() {
57-
let env = TestEnvironment::_new();
57+
let env = TestEnvironment::new();
5858

5959
env.private_context(|context| {
6060
let mut notes_to_constrain = [Option::none(); _];
@@ -72,7 +72,7 @@ unconstrained fn processes_many_notes() {
7272

7373
#[test]
7474
unconstrained fn collapses_notes_at_the_beginning_of_the_array() {
75-
let env = TestEnvironment::_new();
75+
let env = TestEnvironment::new();
7676

7777
env.private_context(|context| {
7878
let mut opt_notes = [Option::none(); _];
@@ -101,7 +101,7 @@ unconstrained fn collapses_notes_at_the_beginning_of_the_array() {
101101

102102
#[test]
103103
unconstrained fn can_return_zero_notes() {
104-
let env = TestEnvironment::_new();
104+
let env = TestEnvironment::new();
105105

106106
env.private_context(|context| {
107107
let opt_notes: [Option<RetrievedNote<MockNote>>; _] = [Option::none(); _];
@@ -115,7 +115,7 @@ unconstrained fn can_return_zero_notes() {
115115

116116
#[test(should_fail_with = "Got more notes than limit.")]
117117
unconstrained fn rejects_mote_notes_than_limit() {
118-
let env = TestEnvironment::_new();
118+
let env = TestEnvironment::new();
119119

120120
env.private_context(|context| {
121121
let mut opt_notes: [Option<RetrievedNote<MockNote>>; _] = [Option::none(); _];
@@ -131,7 +131,7 @@ unconstrained fn rejects_mote_notes_than_limit() {
131131

132132
#[test]
133133
unconstrained fn applies_filter_before_constraining() {
134-
let env = TestEnvironment::_new();
134+
let env = TestEnvironment::new();
135135

136136
env.private_context(|context| {
137137
let mut notes_to_constrain = [Option::none(); _];
@@ -167,7 +167,7 @@ unconstrained fn applies_filter_before_constraining() {
167167

168168
#[test(should_fail_with = "Note contract address mismatch.")]
169169
unconstrained fn rejects_mismatched_address() {
170-
let env = TestEnvironment::_new();
170+
let env = TestEnvironment::new();
171171

172172
env.private_context(|context| {
173173
let note = MockNote::new(1).build_retrieved_note(); // We're not setting the right contract address
@@ -181,7 +181,7 @@ unconstrained fn rejects_mismatched_address() {
181181

182182
#[test(should_fail_with = "Mismatch return note field.")]
183183
unconstrained fn rejects_mismatched_selector() {
184-
let env = TestEnvironment::_new();
184+
let env = TestEnvironment::new();
185185

186186
env.private_context(|context| {
187187
let value = 10;
@@ -203,7 +203,7 @@ unconstrained fn rejects_mismatched_selector() {
203203

204204
#[test(should_fail_with = "Return notes not sorted in descending order.")]
205205
unconstrained fn rejects_mismatched_desc_sort_order() {
206-
let env = TestEnvironment::_new();
206+
let env = TestEnvironment::new();
207207

208208
env.private_context(|context| {
209209
let mut opt_notes = [Option::none(); _];
@@ -220,7 +220,7 @@ unconstrained fn rejects_mismatched_desc_sort_order() {
220220

221221
#[test(should_fail_with = "Return notes not sorted in ascending order.")]
222222
unconstrained fn rejects_mismatched_asc_sort_order() {
223-
let env = TestEnvironment::_new();
223+
let env = TestEnvironment::new();
224224

225225
env.private_context(|context| {
226226
let mut opt_notes = [Option::none(); _];

noir-projects/aztec-nr/aztec/src/oracle/capsules.nr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ mod test {
8585

8686
#[test]
8787
unconstrained fn stores_and_loads() {
88-
let env = TestEnvironment::_new();
88+
let env = TestEnvironment::new();
8989
env.private_context(|context| {
9090
let contract_address = context.this_address();
9191

@@ -98,7 +98,7 @@ mod test {
9898

9999
#[test]
100100
unconstrained fn store_overwrites() {
101-
let env = TestEnvironment::_new();
101+
let env = TestEnvironment::new();
102102
env.private_context(|context| {
103103
let contract_address = context.this_address();
104104

@@ -114,7 +114,7 @@ mod test {
114114

115115
#[test]
116116
unconstrained fn loads_empty_slot() {
117-
let env = TestEnvironment::_new();
117+
let env = TestEnvironment::new();
118118
env.private_context(|context| {
119119
let contract_address = context.this_address();
120120

@@ -125,7 +125,7 @@ mod test {
125125

126126
#[test]
127127
unconstrained fn deletes_stored_value() {
128-
let env = TestEnvironment::_new();
128+
let env = TestEnvironment::new();
129129
env.private_context(|context| {
130130
let contract_address = context.this_address();
131131

@@ -140,7 +140,7 @@ mod test {
140140

141141
#[test]
142142
unconstrained fn deletes_empty_slot() {
143-
let env = TestEnvironment::_new();
143+
let env = TestEnvironment::new();
144144
env.private_context(|context| {
145145
let contract_address = context.this_address();
146146

@@ -152,7 +152,7 @@ mod test {
152152

153153
#[test]
154154
unconstrained fn copies_non_overlapping_values() {
155-
let env = TestEnvironment::_new();
155+
let env = TestEnvironment::new();
156156
env.private_context(|context| {
157157
let contract_address = context.this_address();
158158

@@ -174,7 +174,7 @@ mod test {
174174

175175
#[test]
176176
unconstrained fn copies_overlapping_values_with_src_ahead() {
177-
let env = TestEnvironment::_new();
177+
let env = TestEnvironment::new();
178178
env.private_context(|context| {
179179
let contract_address = context.this_address();
180180

@@ -201,7 +201,7 @@ mod test {
201201

202202
#[test]
203203
unconstrained fn copies_overlapping_values_with_dst_ahead() {
204-
let env = TestEnvironment::_new();
204+
let env = TestEnvironment::new();
205205
env.private_context(|context| {
206206
let contract_address = context.this_address();
207207

@@ -228,7 +228,7 @@ mod test {
228228

229229
#[test(should_fail_with = "copy empty slot")]
230230
unconstrained fn cannot_copy_empty_values() {
231-
let env = TestEnvironment::_new();
231+
let env = TestEnvironment::new();
232232
env.private_context(|context| {
233233
let contract_address = context.this_address();
234234

@@ -238,7 +238,7 @@ mod test {
238238

239239
#[test(should_fail_with = "not allowed to access")]
240240
unconstrained fn cannot_store_other_contract() {
241-
let env = TestEnvironment::_new();
241+
let env = TestEnvironment::new();
242242
env.private_context(|context| {
243243
let contract_address = context.this_address();
244244
let other_contract_address = AztecAddress::from_field(contract_address.to_field() + 1);
@@ -250,7 +250,7 @@ mod test {
250250

251251
#[test(should_fail_with = "not allowed to access")]
252252
unconstrained fn cannot_load_other_contract() {
253-
let env = TestEnvironment::_new();
253+
let env = TestEnvironment::new();
254254
env.private_context(|context| {
255255
let contract_address = context.this_address();
256256
let other_contract_address = AztecAddress::from_field(contract_address.to_field() + 1);
@@ -261,7 +261,7 @@ mod test {
261261

262262
#[test(should_fail_with = "not allowed to access")]
263263
unconstrained fn cannot_delete_other_contract() {
264-
let env = TestEnvironment::_new();
264+
let env = TestEnvironment::new();
265265
env.private_context(|context| {
266266
let contract_address = context.this_address();
267267
let other_contract_address = AztecAddress::from_field(contract_address.to_field() + 1);
@@ -272,7 +272,7 @@ mod test {
272272

273273
#[test(should_fail_with = "not allowed to access")]
274274
unconstrained fn cannot_copy_other_contract() {
275-
let env = TestEnvironment::_new();
275+
let env = TestEnvironment::new();
276276
env.private_context(|context| {
277277
let contract_address = context.this_address();
278278
let other_contract_address = AztecAddress::from_field(contract_address.to_field() + 1);

0 commit comments

Comments
 (0)