Skip to content

Commit 97ec82a

Browse files
chore: update imports
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
1 parent 36cb561 commit 97ec82a

8 files changed

Lines changed: 80 additions & 114 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,6 @@ jobs:
318318
cargo install cargo-make --force
319319
fi
320320
321-
# Some integration tests use midenup to compile the example projects
322-
- name: Install midenup
323-
run: |
324-
if ! miden help 2>/dev/null; then
325-
cargo install --git https://github.com/0xMiden/midenup
326-
midenup init
327-
fi
328-
329321
- name: Test
330322
run: |
331323
cargo make test -E 'package(midenc-integration-network-tests)'

Cargo.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration-network/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ publish = false
1313

1414
[dependencies]
1515
# miden-client = { version = "0.14", features = ["std", "tonic", "testing"] }
16-
miden-client = { git = "https://github.com/0xMiden/miden-client", branch = "release/v0.14.0-beta" }
16+
miden-client = { git = "https://github.com/0xMiden/miden-client", branch = "release/v0.14.0-beta", features = ["std", "testing"] }
1717
miden-core.workspace = true
1818
miden-protocol = { workspace = true, features = ["std", "testing"] }
1919
miden-standards = { workspace = true, features = ["std"] }

tests/integration-network/src/mockchain/basic_wallet.rs

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
//! Basic wallet test module
22
33
use miden_client::{
4-
asset::FungibleAsset, crypto::RandomCoin, note::NoteAssets, transaction::RawOutputNote,
4+
account::{
5+
component::{BasicWallet, InitStorageData},
6+
AccountComponent,
7+
},
8+
asset::{Asset, FungibleAsset},
9+
transaction::RawOutputNote,
510
};
611
use miden_core::Felt;
7-
use miden_protocol::account::{auth::AuthScheme, AccountId};
8-
use miden_testing::{AccountState, Auth, MockChain};
12+
use miden_protocol::{
13+
account::auth::AuthScheme,
14+
crypto::rand::RandomCoin,
15+
};
16+
use miden_standards::testing::note::NoteBuilder;
17+
use miden_testing::{Auth, MockChain};
918
use midenc_expect_test::expect;
1019

1120
use super::{
1221
cycle_helpers::{note_cycles, prologue_cycles, tx_script_processing_cycles},
1322
helpers::{
14-
assert_account_has_fungible_asset, build_asset_transfer_tx,
15-
build_existing_basic_wallet_account_builder, build_send_notes_script, compile_rust_package,
16-
create_note_from_package, execute_tx, to_core_felts, NoteCreationConfig,
23+
assert_account_has_fungible_asset, build_asset_transfer_tx, build_send_notes_script,
24+
compile_rust_package, execute_tx, to_core_felts,
1725
},
1826
};
19-
use crate::mockchain::helpers::compile_rust_package;
20-
21-
/// Converts the P2IDE note payload into protocol storage order for the basic-wallet tests.
22-
fn to_p2ide_storage_felts(
23-
target: &AccountId,
24-
reclaim_height: Felt,
25-
timelock_height: Felt,
26-
) -> Vec<Felt> {
27-
vec![target.suffix(), target.prefix().as_felt(), reclaim_height, timelock_height]
28-
}
2927

3028
/// Tests the basic-wallet contract deployment and p2id note consumption workflow on a mock chain.
3129
#[test]
@@ -65,7 +63,7 @@ pub fn test_basic_wallet_p2id() {
6563
let bob_account = builder
6664
.add_existing_account_from_components(
6765
Auth::BasicAuth {
68-
auth_sceme: AuthScheme::Falcon512Poseidon2,
66+
auth_scheme: AuthScheme::Falcon512Poseidon2,
6967
},
7068
[wallet_component],
7169
)
@@ -80,11 +78,11 @@ pub fn test_basic_wallet_p2id() {
8078
let mint_amount = 100_000u64; // 100,000 tokens
8179
let mint_asset = FungibleAsset::new(faucet_id, mint_amount).unwrap();
8280

83-
let mut note_rng = RpoRandomCoin::new(note_package.unwrap_program().hash());
81+
let mut note_rng = RandomCoin::new(note_package.unwrap_program().hash());
8482
let p2id_note_mint = NoteBuilder::new(faucet_id, &mut note_rng)
8583
.package((*note_package).clone())
8684
.add_assets([Asset::from(mint_asset)])
87-
.note_inputs(to_core_felts(&alice_id))
85+
.note_storage(to_core_felts(&alice_id))
8886
.unwrap()
8987
.build()
9088
.unwrap();
@@ -173,7 +171,7 @@ pub fn test_basic_wallet_p2ide() {
173171
let alice_account = builder
174172
.add_existing_account_from_components(
175173
Auth::BasicAuth {
176-
auth_sceme: AuthScheme::Falcon512Poseidon2,
174+
auth_scheme: AuthScheme::Falcon512Poseidon2,
177175
},
178176
[wallet_component.clone(), BasicWallet.into()],
179177
)
@@ -183,7 +181,7 @@ pub fn test_basic_wallet_p2ide() {
183181
let bob_account = builder
184182
.add_existing_account_from_components(
185183
Auth::BasicAuth {
186-
auth_sceme: AuthScheme::Falcon512Poseidon2,
184+
auth_scheme: AuthScheme::Falcon512Poseidon2,
187185
},
188186
[wallet_component],
189187
)
@@ -198,11 +196,11 @@ pub fn test_basic_wallet_p2ide() {
198196
let mint_amount = 100_000u64;
199197
let mint_asset = FungibleAsset::new(faucet_id, mint_amount).unwrap();
200198

201-
let p2id_rng = RpoRandomCoin::new(p2id_note_package.unwrap_program().hash());
199+
let p2id_rng = RandomCoin::new(p2id_note_package.unwrap_program().hash());
202200
let p2id_note_mint = NoteBuilder::new(faucet_id, p2id_rng)
203201
.package((*p2id_note_package).clone())
204202
.add_assets([Asset::from(mint_asset)])
205-
.note_inputs(to_core_felts(&alice_id))
203+
.note_storage(to_core_felts(&alice_id))
206204
.unwrap()
207205
.build()
208206
.unwrap();
@@ -231,11 +229,11 @@ pub fn test_basic_wallet_p2ide() {
231229
let timelock_height = Felt::new(0);
232230
let reclaim_height = Felt::new(0);
233231

234-
let p2ide_rng = RpoRandomCoin::new(p2ide_note_package.unwrap_program().hash());
232+
let p2ide_rng = RandomCoin::new(p2ide_note_package.unwrap_program().hash());
235233
let p2ide_note = NoteBuilder::new(alice_id, p2ide_rng)
236234
.package((*p2ide_note_package).clone())
237235
.add_assets([Asset::from(transfer_asset)])
238-
.note_inputs({
236+
.note_storage({
239237
let mut inputs = to_core_felts(&bob_id);
240238
inputs.extend([timelock_height, reclaim_height]);
241239
inputs
@@ -302,7 +300,7 @@ pub fn test_basic_wallet_p2ide_reclaim() {
302300
let alice_account = builder
303301
.add_existing_account_from_components(
304302
Auth::BasicAuth {
305-
auth_sceme: AuthScheme::Falcon512Poseidon2,
303+
auth_scheme: AuthScheme::Falcon512Poseidon2,
306304
},
307305
[wallet_component.clone(), BasicWallet.into()],
308306
)
@@ -312,7 +310,7 @@ pub fn test_basic_wallet_p2ide_reclaim() {
312310
let bob_account = builder
313311
.add_existing_account_from_components(
314312
Auth::BasicAuth {
315-
auth_sceme: AuthScheme::Falcon512Poseidon2,
313+
auth_scheme: AuthScheme::Falcon512Poseidon2,
316314
},
317315
[wallet_component],
318316
)
@@ -327,11 +325,11 @@ pub fn test_basic_wallet_p2ide_reclaim() {
327325
let mint_amount = 100_000u64;
328326
let mint_asset = FungibleAsset::new(faucet_id, mint_amount).unwrap();
329327

330-
let p2id_rng = RpoRandomCoin::new(p2id_note_package.unwrap_program().hash());
328+
let p2id_rng = RandomCoin::new(p2id_note_package.unwrap_program().hash());
331329
let p2id_note_mint = NoteBuilder::new(faucet_id, p2id_rng)
332330
.package((*p2id_note_package).clone())
333331
.add_assets([Asset::from(mint_asset)])
334-
.note_inputs(to_core_felts(&alice_id))
332+
.note_storage(to_core_felts(&alice_id))
335333
.unwrap()
336334
.build()
337335
.unwrap();
@@ -360,11 +358,11 @@ pub fn test_basic_wallet_p2ide_reclaim() {
360358
let timelock_height = Felt::new(0);
361359
let reclaim_height = Felt::new(1);
362360

363-
let p2ide_rng = RpoRandomCoin::new(p2ide_note_package.unwrap_program().hash());
361+
let p2ide_rng = RandomCoin::new(p2ide_note_package.unwrap_program().hash());
364362
let p2ide_note = NoteBuilder::new(alice_id, p2ide_rng)
365363
.package((*p2ide_note_package).clone())
366364
.add_assets([Asset::from(transfer_asset)])
367-
.note_inputs({
365+
.note_storage({
368366
let mut inputs = to_core_felts(&bob_id);
369367
inputs.extend([timelock_height, reclaim_height]);
370368
inputs

tests/integration-network/src/mockchain/counter_contract.rs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
//! Counter contract test module
22
33
use miden_client::{
4-
account::component::BasicWallet,
5-
crypto::{RandomCoin, RpoRandomCoin},
6-
note::NoteTag,
4+
account::{component::InitStorageData, AccountComponent},
75
transaction::RawOutputNote,
86
Word,
97
};
108
use miden_core::Felt;
11-
use miden_protocol::account::{
12-
auth::AuthScheme, AccountBuilder, AccountStorageMode, AccountType, StorageMap, StorageMapKey,
13-
StorageSlot, StorageSlotName,
9+
use miden_protocol::{
10+
account::{auth::AuthScheme, StorageSlotName},
11+
crypto::rand::RandomCoin,
1412
};
15-
use miden_testing::{AccountState, Auth, MockChain};
13+
use miden_standards::testing::note::NoteBuilder;
14+
use miden_testing::{Auth, MockChain};
1615
use midenc_expect_test::expect;
1716

1817
use super::{
1918
cycle_helpers::note_cycles,
2019
helpers::{
21-
account_component_from_package, assert_counter_storage, compile_rust_package,
22-
create_note_from_package, execute_tx, NoteCreationConfig,
20+
assert_counter_storage, compile_rust_package, execute_tx, COUNTER_CONTRACT_STORAGE_KEY,
2321
},
2422
};
25-
use crate::mockchain::helpers::COUNTER_CONTRACT_STORAGE_KEY;
2623

2724
/// Tests the counter contract deployment and note consumption workflow on a mock chain.
2825
#[test]
@@ -34,33 +31,30 @@ pub fn test_counter_contract() {
3431
let value = Word::from([Felt::ZERO, Felt::ZERO, Felt::ZERO, Felt::ONE]);
3532
let counter_storage_slot =
3633
StorageSlotName::new("miden::component::miden_counter_contract::count_map").unwrap();
37-
let storage_slots = vec![StorageSlot::with_map(
38-
counter_storage_slot.clone(),
39-
StorageMap::with_entries([(StorageMapKey::new(COUNTER_CONTRACT_STORAGE_KEY), value)])
40-
.unwrap(),
41-
)];
4234

4335
let mut init_storage_data = InitStorageData::default();
4436
init_storage_data
45-
.insert_map_entry(counter_storage_slot.clone(), key, value)
37+
.insert_map_entry(counter_storage_slot.clone(), COUNTER_CONTRACT_STORAGE_KEY, value)
4638
.unwrap();
47-
let contract_package = AccountComponent::from_package(&contract_package, &init_storage_data)
39+
let contract_component = AccountComponent::from_package(&contract_package, &init_storage_data)
4840
.expect("Failed to build account component from counter project");
4941

5042
let mut builder = MockChain::builder();
5143
let counter_account = builder
5244
.add_existing_account_from_components(
53-
Auth::BasicAuth,
54-
[BasicWallet.into(), contract_package],
45+
Auth::BasicAuth {
46+
auth_scheme: AuthScheme::Falcon512Poseidon2,
47+
},
48+
[contract_component],
5549
)
5650
.unwrap();
5751

58-
let mut rng = RpoRandomCoin::new(note_package.clone().unwrap_program().hash());
52+
let mut rng = RandomCoin::new(note_package.clone().unwrap_program().hash());
5953
let counter_note = NoteBuilder::new(counter_account.id(), &mut rng)
6054
.package((*note_package).clone())
6155
.build()
6256
.unwrap();
63-
builder.add_output_note(OutputNote::Full(counter_note.clone()));
57+
builder.add_output_note(RawOutputNote::Full(counter_note.clone()));
6458

6559
let mut chain = builder.build().expect("failed to build mock chain");
6660
chain.prove_next_block().unwrap();

tests/integration-network/src/mockchain/counter_contract_no_auth.rs

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
//! Counter contract test with no-auth authentication component
22
33
use miden_client::{
4-
account::component::BasicWallet, crypto::RandomCoin, note::NoteTag, transaction::RawOutputNote,
4+
account::{component::InitStorageData, AccountComponent},
5+
note::NoteTag,
6+
transaction::RawOutputNote,
57
Word,
68
};
7-
use miden_core::{Felt, FieldElement};
8-
use miden_protocol::account::{
9-
auth::AuthScheme, AccountBuilder, AccountStorageMode, AccountType, StorageMap, StorageMapKey,
10-
StorageSlot, StorageSlotName,
9+
use miden_core::Felt;
10+
use miden_protocol::{
11+
account::{auth::AuthScheme, AccountBuilder, AccountStorageMode, AccountType, StorageSlotName},
12+
crypto::rand::RandomCoin,
1113
};
14+
use miden_standards::testing::note::NoteBuilder;
1215
use miden_testing::{AccountState, Auth, MockChain};
1316
use midenc_expect_test::expect;
1417

1518
use super::{
16-
crypto::RpoRandomCoin,
1719
cycle_helpers::{auth_procedure_cycles, note_cycles},
1820
helpers::{
1921
assert_counter_storage, build_existing_counter_account_builder_with_auth_package,
20-
compile_rust_package, create_note_from_package, execute_tx, NoteCreationConfig,
22+
compile_rust_package, execute_tx, COUNTER_CONTRACT_STORAGE_KEY,
2123
},
22-
note::NoteTag,
23-
testing::{AccountState, Auth, MockChain, NoteBuilder},
24-
transaction::OutputNote,
25-
Word,
2624
};
27-
use crate::mockchain::helpers::compile_rust_package;
2825

2926
/// Tests the counter contract with a "no-auth" authentication component.
3027
///
@@ -44,26 +41,16 @@ pub fn test_counter_contract_no_auth() {
4441
let value = Word::from([Felt::ZERO, Felt::ZERO, Felt::ZERO, Felt::ONE]);
4542
let counter_storage_slot =
4643
StorageSlotName::new("miden::component::miden_counter_contract::count_map").unwrap();
47-
let counter_storage_slots = vec![StorageSlot::with_map(
48-
counter_storage_slot.clone(),
49-
StorageMap::with_entries([(StorageMapKey::new(COUNTER_CONTRACT_STORAGE_KEY), value)])
50-
.unwrap(),
51-
)];
5244

53-
let mut builder = MockChain::builder();
5445
let counter_component = {
5546
let mut init_storage_data = InitStorageData::default();
5647
init_storage_data
57-
.insert_map_entry(counter_storage_slot.clone(), key, value)
48+
.insert_map_entry(counter_storage_slot.clone(), COUNTER_CONTRACT_STORAGE_KEY, value)
5849
.unwrap();
5950
AccountComponent::from_package(&counter_package, &init_storage_data).unwrap()
6051
};
6152

62-
let mut counter_init_storage_data = InitStorageData::default();
63-
counter_init_storage_data
64-
.insert_map_entry(counter_storage_slot.clone(), key, value)
65-
.expect("failed to insert counter map entry");
66-
53+
let mut builder = MockChain::builder();
6754
let counter_account = build_existing_counter_account_builder_with_auth_package(
6855
counter_component,
6956
no_auth_auth_component,
@@ -82,7 +69,7 @@ pub fn test_counter_contract_no_auth() {
8269
let sender_builder = AccountBuilder::new(seed)
8370
.account_type(AccountType::RegularAccountUpdatableCode)
8471
.storage_mode(AccountStorageMode::Public)
85-
.with_component(BasicWallet);
72+
.with_component(miden_client::account::component::BasicWallet);
8673
let sender_account = builder
8774
.add_account_from_builder(
8875
Auth::BasicAuth {
@@ -95,7 +82,7 @@ pub fn test_counter_contract_no_auth() {
9582
eprintln!("Sender account ID: {:?}", sender_account.id().to_hex());
9683

9784
// Sender creates the counter note (note script increments counter's storage on consumption)
98-
let rng = RpoRandomCoin::new(note_package.unwrap_program().hash());
85+
let rng = RandomCoin::new(note_package.unwrap_program().hash());
9986
let counter_note = NoteBuilder::new(sender_account.id(), rng)
10087
.package((*note_package).clone())
10188
.tag(NoteTag::with_account_target(counter_account.id()).into())

0 commit comments

Comments
 (0)