Skip to content

Commit

Permalink
test: added prove_account_test_success_storage_hash + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ametel01 committed May 16, 2024
1 parent 68cc5e3 commit fdbe06d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
8 changes: 6 additions & 2 deletions starknet/src/fact_registry/contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub mod FactRegistry {
},
OptionsSet::Balance => {
let balance = *result_values.at(1);
println!("balance: {:?}", balance.values);
self
.verified_account_balance
.write((account, block), balance.from_words64());
Expand All @@ -66,7 +65,12 @@ pub mod FactRegistry {
let nonce = *(*result_values.at(0)).values.at(0);
self.verified_account_nonce.write((account, block), nonce);
},
OptionsSet::StorageHash => {},
OptionsSet::StorageHash => {
let storage_hash = *result_values.at(2);
self
.verified_account_storage_hash
.write((account, block), storage_hash.from_words64());
},
};
}
}
Expand Down
33 changes: 32 additions & 1 deletion starknet/tests/test_fact_registry.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,38 @@ fn prove_account_test_success_balance() {

#[test]
fn prove_account_test_success_nonce() {
assert!(true)
let dsp = setup();

let block = testdata::blocks::BLOCK_3();
dsp.store.set_state_root(block.number, block.state_root);

let proof = testdata::proofs::PROOF_1();

dsp
.registry
.prove_account(OptionsSet::Nonce, proof.account, block.number, proof.len_bytes, proof.data);

let nonce = dsp.registry.get_verified_account_nonce(proof.account, block.number);
assert_eq!(nonce, 0x1);
}

#[test]
fn prove_account_test_success_storage_hash() {
let dsp = setup();

let block = testdata::blocks::BLOCK_3();
dsp.store.set_state_root(block.number, block.state_root);

let proof = testdata::proofs::PROOF_1();

dsp
.registry
.prove_account(
OptionsSet::StorageHash, proof.account, block.number, proof.len_bytes, proof.data
);

let storage_hash = dsp.registry.get_verified_account_storage_hash(proof.account, block.number);
assert_eq!(storage_hash, 0x199c2e6b850bcc9beaea25bf1bacc5741a7aad954d28af9b23f4b53f5404937b);
}

#[test]
Expand Down

0 comments on commit fdbe06d

Please sign in to comment.