11//! Basic wallet test module
22
33use 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} ;
611use 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 } ;
918use midenc_expect_test:: expect;
1019
1120use 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
0 commit comments