Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ jobs:
if ! cargo make --version 2>/dev/null; then
cargo install cargo-make --force
fi

# Some integration tests use midenup to compile the example projects
- name: Install midenup
run: |
if ! miden help 2>/dev/null; then
cargo install --git https://github.com/0xMiden/midenup
midenup init
fi
Comment on lines +322 to +327
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, accessing the miden interface requires further intervention by adding some variables to the system's $PATH. This is not ideal for cases like this I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create an issue on midenup to track this: 0xMiden/midenup#165


- name: Test
run: |
cargo make test -E 'package(midenc-integration-network-tests)'
Expand Down
29 changes: 10 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ miden-test-harness-macros = { path = "test-harness/test-harness-macros" }
#miden-processor = { path = "../miden-vm/processor" }
#miden-mast-package = { git = "https://github.com/0xMiden/miden-vm", rev = "614cd7f9b52f45238b0ab59c71ebb49325051e5d" }
#miden-mast-package = { path = "../miden-vm/package" }
miden-protocol = { git = "https://github.com/lambdaclass/miden-base.git", branch = "fabrizioorsi/miden-testing-compiler-backport" }
miden-standards = { git = "https://github.com/lambdaclass/miden-base.git", branch = "fabrizioorsi/miden-testing-compiler-backport" }
miden-testing = { git = "https://github.com/lambdaclass/miden-base.git", branch = "fabrizioorsi/miden-testing-compiler-backport" }
miden-tx = { git = "https://github.com/lambdaclass/miden-base.git", branch = "fabrizioorsi/miden-testing-compiler-backport" }
miden-block-prover = { git = "https://github.com/lambdaclass/miden-base.git", branch = "fabrizioorsi/miden-testing-compiler-backport" }
miden-tx-batch-prover = { git = "https://github.com/lambdaclass/miden-base.git", branch = "fabrizioorsi/miden-testing-compiler-backport" }


[profile.dev]
Expand Down
2 changes: 1 addition & 1 deletion tests/integration-network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition.workspace = true
publish = false

[dependencies]
miden-client = { version = "0.13", features = ["std", "tonic", "testing"] }
miden-client = { branch = "fabrizioorsi/miden-testing-compiler-backport", git = "https://github.com/lambdaclass/miden-client.git", features = ["std", "tonic", "testing"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch contains the changes made in this PR, only backported to version 0.13 of the miden client.

miden-core.workspace = true
miden-protocol = { workspace = true, features = ["std"] }
miden-standards = { workspace = true, features = ["std"] }
Expand Down
162 changes: 69 additions & 93 deletions tests/integration-network/src/mockchain/basic_wallet.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//! Basic wallet test module

use miden_client::{
account::component::{BasicWallet, InitStorageData},
asset::FungibleAsset,
crypto::RpoRandomCoin,
note::NoteAssets,
testing::{AccountState, Auth, MockChain},
testing::{Auth, MockChain, NoteBuilder},
transaction::OutputNote,
};
use miden_core::Felt;
use miden_protocol::{account::AccountComponent, asset::Asset};
use midenc_expect_test::expect;

use super::{
cycle_helpers::{note_cycles, prologue_cycles, tx_script_processing_cycles},
helpers::{
NoteCreationConfig, assert_account_has_fungible_asset, build_asset_transfer_tx,
build_existing_basic_wallet_account_builder, build_send_notes_script, compile_rust_package,
create_note_from_package, execute_tx, to_core_felts,
assert_account_has_fungible_asset, build_asset_transfer_tx, build_send_notes_script,
compile_rust_package, execute_tx, to_core_felts,
},
};

Expand All @@ -27,6 +27,9 @@ pub fn test_basic_wallet_p2id() {
let note_package = compile_rust_package("../../examples/p2id-note", true);
let tx_script_package = compile_rust_package("../../examples/basic-wallet-tx-script", true);

let wallet_component =
AccountComponent::from_package(&wallet_package, &InitStorageData::default()).unwrap();

let mut builder = MockChain::builder();
let max_supply = 1_000_000_000u64;
let faucet_account = builder
Expand All @@ -35,20 +38,12 @@ pub fn test_basic_wallet_p2id() {
let faucet_id = faucet_account.id();

let alice_account = builder
.add_account_from_builder(
Auth::BasicAuth,
build_existing_basic_wallet_account_builder(wallet_package.clone(), false, [1_u8; 32]),
AccountState::Exists,
)
.add_existing_account_from_components(Auth::BasicAuth, [wallet_component.clone()])
.unwrap();
let alice_id = alice_account.id();

let bob_account = builder
.add_account_from_builder(
Auth::BasicAuth,
build_existing_basic_wallet_account_builder(wallet_package, false, [2_u8; 32]),
AccountState::Exists,
)
.add_existing_account_from_components(Auth::BasicAuth, [wallet_component])
.unwrap();
let bob_id = bob_account.id();

Expand All @@ -61,16 +56,13 @@ pub fn test_basic_wallet_p2id() {
let mint_asset = FungibleAsset::new(faucet_id, mint_amount).unwrap();

let mut note_rng = RpoRandomCoin::new(note_package.unwrap_program().hash());
let p2id_note_mint = create_note_from_package(
note_package.clone(),
faucet_id,
NoteCreationConfig {
assets: NoteAssets::new(vec![mint_asset.into()]).unwrap(),
inputs: to_core_felts(&alice_id),
..Default::default()
},
&mut note_rng,
);
let p2id_note_mint = NoteBuilder::new(faucet_id, &mut note_rng)
.package((*note_package).clone())
.add_assets([Asset::from(mint_asset)])
.note_inputs(to_core_felts(&alice_id))
.unwrap()
.build()
.unwrap();

let faucet_account = chain.committed_account(faucet_id).unwrap().clone();
let mint_tx_script =
Expand Down Expand Up @@ -136,6 +128,9 @@ pub fn test_basic_wallet_p2ide() {
let p2id_note_package = compile_rust_package("../../examples/p2id-note", true);
let p2ide_note_package = compile_rust_package("../../examples/p2ide-note", true);

let wallet_component =
AccountComponent::from_package(&wallet_package, &InitStorageData::default()).unwrap();

let mut builder = MockChain::builder();
let max_supply = 1_000_000_000u64;
let faucet_account = builder
Expand All @@ -144,20 +139,15 @@ pub fn test_basic_wallet_p2ide() {
let faucet_id = faucet_account.id();

let alice_account = builder
.add_account_from_builder(
.add_existing_account_from_components(
Auth::BasicAuth,
build_existing_basic_wallet_account_builder(wallet_package.clone(), true, [3_u8; 32]),
AccountState::Exists,
[wallet_component.clone(), BasicWallet.into()],
)
.unwrap();
let alice_id = alice_account.id();

let bob_account = builder
.add_account_from_builder(
Auth::BasicAuth,
build_existing_basic_wallet_account_builder(wallet_package, false, [4_u8; 32]),
AccountState::Exists,
)
.add_existing_account_from_components(Auth::BasicAuth, [wallet_component])
.unwrap();
let bob_id = bob_account.id();

Expand All @@ -169,17 +159,14 @@ pub fn test_basic_wallet_p2ide() {
let mint_amount = 100_000u64;
let mint_asset = FungibleAsset::new(faucet_id, mint_amount).unwrap();

let mut p2id_rng = RpoRandomCoin::new(p2id_note_package.unwrap_program().hash());
let p2id_note_mint = create_note_from_package(
p2id_note_package.clone(),
faucet_id,
NoteCreationConfig {
assets: NoteAssets::new(vec![mint_asset.into()]).unwrap(),
inputs: to_core_felts(&alice_id),
..Default::default()
},
&mut p2id_rng,
);
let p2id_rng = RpoRandomCoin::new(p2id_note_package.unwrap_program().hash());
let p2id_note_mint = NoteBuilder::new(faucet_id, p2id_rng)
.package((*p2id_note_package).clone())
.add_assets([Asset::from(mint_asset)])
.note_inputs(to_core_felts(&alice_id))
.unwrap()
.build()
.unwrap();

let faucet_account = chain.committed_account(faucet_id).unwrap().clone();
let mint_tx_script =
Expand All @@ -205,21 +192,18 @@ pub fn test_basic_wallet_p2ide() {
let timelock_height = Felt::new(0);
let reclaim_height = Felt::new(0);

let mut p2ide_rng = RpoRandomCoin::new(p2ide_note_package.unwrap_program().hash());
let p2ide_note = create_note_from_package(
p2ide_note_package,
alice_id,
NoteCreationConfig {
assets: NoteAssets::new(vec![transfer_asset.into()]).unwrap(),
inputs: {
let mut inputs = to_core_felts(&bob_id);
inputs.extend([timelock_height, reclaim_height]);
inputs
},
..Default::default()
},
&mut p2ide_rng,
);
let p2ide_rng = RpoRandomCoin::new(p2ide_note_package.unwrap_program().hash());
let p2ide_note = NoteBuilder::new(alice_id, p2ide_rng)
.package((*p2ide_note_package).clone())
.add_assets([Asset::from(transfer_asset)])
.note_inputs({
let mut inputs = to_core_felts(&bob_id);
inputs.extend([timelock_height, reclaim_height]);
inputs
})
.unwrap()
.build()
.unwrap();

let alice_account = chain.committed_account(alice_id).unwrap().clone();
let transfer_tx_script =
Expand Down Expand Up @@ -266,21 +250,19 @@ pub fn test_basic_wallet_p2ide_reclaim() {
.unwrap();
let faucet_id = faucet_account.id();

let wallet_component =
AccountComponent::from_package(&wallet_package, &InitStorageData::default()).unwrap();

let alice_account = builder
.add_account_from_builder(
.add_existing_account_from_components(
Auth::BasicAuth,
build_existing_basic_wallet_account_builder(wallet_package.clone(), true, [5_u8; 32]),
AccountState::Exists,
[wallet_component.clone(), BasicWallet.into()],
)
.unwrap();
let alice_id = alice_account.id();

let bob_account = builder
.add_account_from_builder(
Auth::BasicAuth,
build_existing_basic_wallet_account_builder(wallet_package, false, [6_u8; 32]),
AccountState::Exists,
)
.add_existing_account_from_components(Auth::BasicAuth, [wallet_component])
.unwrap();
let bob_id = bob_account.id();

Expand All @@ -292,17 +274,14 @@ pub fn test_basic_wallet_p2ide_reclaim() {
let mint_amount = 100_000u64;
let mint_asset = FungibleAsset::new(faucet_id, mint_amount).unwrap();

let mut p2id_rng = RpoRandomCoin::new(p2id_note_package.unwrap_program().hash());
let p2id_note_mint = create_note_from_package(
p2id_note_package.clone(),
faucet_id,
NoteCreationConfig {
assets: NoteAssets::new(vec![mint_asset.into()]).unwrap(),
inputs: to_core_felts(&alice_id),
..Default::default()
},
&mut p2id_rng,
);
let p2id_rng = RpoRandomCoin::new(p2id_note_package.unwrap_program().hash());
let p2id_note_mint = NoteBuilder::new(faucet_id, p2id_rng)
.package((*p2id_note_package).clone())
.add_assets([Asset::from(mint_asset)])
.note_inputs(to_core_felts(&alice_id))
.unwrap()
.build()
.unwrap();

let faucet_account = chain.committed_account(faucet_id).unwrap().clone();
let mint_tx_script =
Expand All @@ -328,21 +307,18 @@ pub fn test_basic_wallet_p2ide_reclaim() {
let timelock_height = Felt::new(0);
let reclaim_height = Felt::new(1000);

let mut p2ide_rng = RpoRandomCoin::new(p2ide_note_package.unwrap_program().hash());
let p2ide_note = create_note_from_package(
p2ide_note_package,
alice_id,
NoteCreationConfig {
assets: NoteAssets::new(vec![transfer_asset.into()]).unwrap(),
inputs: {
let mut inputs = to_core_felts(&bob_id);
inputs.extend([timelock_height, reclaim_height]);
inputs
},
..Default::default()
},
&mut p2ide_rng,
);
let p2ide_rng = RpoRandomCoin::new(p2ide_note_package.unwrap_program().hash());
let p2ide_note = NoteBuilder::new(alice_id, p2ide_rng)
.package((*p2ide_note_package).clone())
.add_assets([Asset::from(transfer_asset)])
.note_inputs({
let mut inputs = to_core_felts(&bob_id);
inputs.extend([timelock_height, reclaim_height]);
inputs
})
.unwrap()
.build()
.unwrap();

let alice_account = chain.committed_account(alice_id).unwrap().clone();
let transfer_tx_script =
Expand Down
Loading