Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
fmkra committed Jan 4, 2024
1 parent 98bc951 commit aae8e9b
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions src/vector_commitment/tests/test_vector_commitment.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cairo_verifier::vector_commitment::vector_commitment::{
truncated_blake2s, VectorCommitment, VectorCommitmentConfig, VectorCommitmentWitness, vector_commit,
VectorQuery, vector_commitment_decommit, validate_vector_commitment
truncated_blake2s, VectorCommitment, VectorCommitmentConfig, VectorCommitmentWitness,
vector_commit, VectorQuery, vector_commitment_decommit, validate_vector_commitment
};
use cairo_verifier::channel::channel::Channel;
use core::debug::PrintTrait;
Expand Down Expand Up @@ -45,10 +45,7 @@ fn get_invalid_queries() -> Span<VectorQuery> {
};
let q: VectorQuery = *queries[i];
arr.append(if i == 2 {
VectorQuery {
index: q.index + 1,
value: q.value,
}
VectorQuery { index: q.index + 1, value: q.value, }
} else {
q
});
Expand Down Expand Up @@ -334,48 +331,44 @@ fn test_vector_commit() {
counter: 0x1690c7c85c57a4897623c1364852d8df91e4b36675085fddc7d10a7ea946fcbd,
};
let unsent_felt: felt252 = 0x4b774418541bbe409a801463d95e65b16da2be518ae8c7647867dc57911cd3e;
let config = VectorCommitmentConfig {
height: 15,
n_verifier_friendly_commitment_layers: 5,
};
let config = VectorCommitmentConfig { height: 15, n_verifier_friendly_commitment_layers: 5, };

let res = vector_commit(ref channel, unsent_felt, config);

assert(res.config.height == config.height, 'invalid config height');
assert(res.config.n_verifier_friendly_commitment_layers == config.n_verifier_friendly_commitment_layers, 'invalid config n_veri...');
assert(res.commitment_hash == 0x4b774418541bbe409a801463d95e65b16da2be518ae8c7647867dc57911cd3e, 'invalid commitment_hash');
assert(
res
.config
.n_verifier_friendly_commitment_layers == config
.n_verifier_friendly_commitment_layers,
'invalid config n_veri...'
);
assert(
res.commitment_hash == 0x4b774418541bbe409a801463d95e65b16da2be518ae8c7647867dc57911cd3e,
'invalid commitment_hash'
);
}

#[test]
#[available_gas(9999999999)]
fn test_validate_vector_commitment() {
let config = VectorCommitmentConfig {
height: 21,
n_verifier_friendly_commitment_layers: 7,
};
let config = VectorCommitmentConfig { height: 21, n_verifier_friendly_commitment_layers: 7, };
validate_vector_commitment(config, 21, 7);
}

#[test]
#[should_panic]
#[available_gas(9999999999)]
fn test_invalid_validate_vector_commitment_1() {
let config = VectorCommitmentConfig {
height: 21,
n_verifier_friendly_commitment_layers: 7,
};
let config = VectorCommitmentConfig { height: 21, n_verifier_friendly_commitment_layers: 7, };
validate_vector_commitment(config, 21, 8);
}

#[test]
#[should_panic]
#[available_gas(9999999999)]
fn test_invalid_validate_vector_commitment_2() {
let config = VectorCommitmentConfig {
height: 21,
n_verifier_friendly_commitment_layers: 7,
};
let config = VectorCommitmentConfig { height: 21, n_verifier_friendly_commitment_layers: 7, };
validate_vector_commitment(config, 22, 7);
}


0 comments on commit aae8e9b

Please sign in to comment.