Skip to content

Commit

Permalink
tasm-object: Add more tests of size-verification snippet
Browse files Browse the repository at this point in the history
More tests added by declaring more types used in neptune-core.
  • Loading branch information
Sword-Smith committed Sep 5, 2024
1 parent 38ecd04 commit 82cdf29
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tasm-lib/src/neptune/neptune_like_types_for_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,42 @@ pub(crate) struct UpdateWitnessLookalike {
outputs_hash: Digest,
public_announcements_hash: Digest,
}

#[derive(Debug, Clone, BFieldCodec, TasmObject, Arbitrary)]
pub(crate) struct LockScriptAndWitnessLookalike {
nd_memory: Vec<(BFieldElement, BFieldElement)>,
nd_tokens: Vec<BFieldElement>,
nd_digests: Vec<Digest>,
}

#[derive(Debug, Clone, BFieldCodec, TasmObject, Arbitrary)]
struct TypeScriptAndWitnessLookalike {
nd_tokens: Vec<BFieldElement>,
nd_memory: Vec<(BFieldElement, BFieldElement)>,
nd_digests: Vec<Digest>,
}

#[derive(Debug, Clone, BFieldCodec, TasmObject, Arbitrary)]
struct ActiveWindowLookalike {
sbf: Vec<u32>,
}

#[derive(Debug, Clone, BFieldCodec, TasmObject, Arbitrary)]
pub(crate) struct MutatorSetAccumulatorLookalike {
pub aocl: MmrAccumulator,
pub swbf_inactive: MmrAccumulator,
pub swbf_active: ActiveWindowLookalike,

Check failure on line 191 in tasm-lib/src/neptune/neptune_like_types_for_tests.rs

View workflow job for this annotation

GitHub Actions / format, lint, test (ubuntu-latest)

type `neptune::neptune_like_types_for_tests::ActiveWindowLookalike` is more private than the item `neptune::neptune_like_types_for_tests::MutatorSetAccumulatorLookalike::swbf_active`

Check failure on line 191 in tasm-lib/src/neptune/neptune_like_types_for_tests.rs

View workflow job for this annotation

GitHub Actions / format, lint, test (windows-latest)

type `neptune::neptune_like_types_for_tests::ActiveWindowLookalike` is more private than the item `neptune::neptune_like_types_for_tests::MutatorSetAccumulatorLookalike::swbf_active`

Check failure on line 191 in tasm-lib/src/neptune/neptune_like_types_for_tests.rs

View workflow job for this annotation

GitHub Actions / format, lint, test (macos-latest)

type `neptune::neptune_like_types_for_tests::ActiveWindowLookalike` is more private than the item `neptune::neptune_like_types_for_tests::MutatorSetAccumulatorLookalike::swbf_active`
}

#[derive(Debug, Clone, BFieldCodec, TasmObject, Arbitrary)]
pub(crate) struct PrimitiveWitnessLookalike {
pub input_utxos: SaltedUtxosLookalike,
pub input_membership_proofs: Vec<MsMembershipProofLookalike>,
pub lock_scripts_and_witnesses: Vec<LockScriptAndWitnessLookalike>,
pub type_scripts_and_witnesses: Vec<TypeScriptAndWitnessLookalike>,

Check failure on line 199 in tasm-lib/src/neptune/neptune_like_types_for_tests.rs

View workflow job for this annotation

GitHub Actions / format, lint, test (ubuntu-latest)

type `neptune::neptune_like_types_for_tests::TypeScriptAndWitnessLookalike` is more private than the item `neptune::neptune_like_types_for_tests::PrimitiveWitnessLookalike::type_scripts_and_witnesses`

Check failure on line 199 in tasm-lib/src/neptune/neptune_like_types_for_tests.rs

View workflow job for this annotation

GitHub Actions / format, lint, test (windows-latest)

type `neptune::neptune_like_types_for_tests::TypeScriptAndWitnessLookalike` is more private than the item `neptune::neptune_like_types_for_tests::PrimitiveWitnessLookalike::type_scripts_and_witnesses`

Check failure on line 199 in tasm-lib/src/neptune/neptune_like_types_for_tests.rs

View workflow job for this annotation

GitHub Actions / format, lint, test (macos-latest)

type `neptune::neptune_like_types_for_tests::TypeScriptAndWitnessLookalike` is more private than the item `neptune::neptune_like_types_for_tests::PrimitiveWitnessLookalike::type_scripts_and_witnesses`
pub output_utxos: SaltedUtxosLookalike,
pub output_sender_randomnesses: Vec<Digest>,
pub output_receiver_digests: Vec<Digest>,
pub mutator_set_accumulator: MutatorSetAccumulatorLookalike,
pub kernel: TransactionKernelLookalike,
}
24 changes: 24 additions & 0 deletions tasm-lib/src/structure/verify_nd_si_integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,30 @@ mod tests {
ShadowedAccessor::new(snippet).test();
}

#[test]
fn test_lock_script_and_witness_lookalike() {
let snippet: VerifyNdSiIntegrity<LockScriptAndWitnessLookalike> = VerifyNdSiIntegrity {
_phantom_data: PhantomData,
};
ShadowedAccessor::new(snippet).test();
}

#[test]
fn test_mutator_set_accumulator_lookalike() {
let snippet: VerifyNdSiIntegrity<MutatorSetAccumulatorLookalike> = VerifyNdSiIntegrity {
_phantom_data: PhantomData,
};
ShadowedAccessor::new(snippet).test();
}

#[test]
fn test_primitive_witness_lookalike() {
let snippet: VerifyNdSiIntegrity<PrimitiveWitnessLookalike> = VerifyNdSiIntegrity {
_phantom_data: PhantomData,
};
ShadowedAccessor::new(snippet).test();
}

#[test]
fn test_mmr_successor_proof_auto_derived_code() {
// TODO:
Expand Down

0 comments on commit 82cdf29

Please sign in to comment.