Skip to content

Commit 1398089

Browse files
committed
added tvk test to test_transition_helpers()
1 parent ce63376 commit 1398089

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

wasm/src/ledger/transition.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ impl Transition {
177177
}
178178

179179
/// Get the transition view key of the transition.
180-
pub fn tvk(&self, view_key: ViewKey) -> Field {
180+
pub fn tvk(&self, view_key: &ViewKey) -> Field {
181181
let tpk = self.tpk();
182-
let tvk = tpk.scalar_multiply(&view_key.to_scalar()).to_x_coordinate();
182+
let tvk = tpk.scalar_multiply(view_key.to_scalar()).to_x_coordinate();
183183
tvk
184184
}
185185

@@ -263,6 +263,10 @@ mod tests {
263263

264264
#[test]
265265
fn test_transition_helpers() {
266+
// Create a random private key and view key.
267+
let private_key = PrivateKey::new();
268+
let view_key = ViewKey::from_private_key(&private_key);
269+
266270
let transition = Transition::from_string(TRANSITION).unwrap();
267271
assert_eq!(transition.program_id(), "token_registry.aleo");
268272
assert_eq!(transition.function_name(), "burn_private");
@@ -281,6 +285,11 @@ mod tests {
281285
Field::from_string("6845182532650964173356391969005331370591444046632036068754797772530920467754field")
282286
.unwrap()
283287
);
288+
assert_eq!(
289+
transition.tvk(&view_key),
290+
Field::from_string("_placeholder_") // Placeholder for the view key, will replace with manually computed value.
291+
.unwrap()
292+
)
284293
}
285294

286295
#[wasm_bindgen_test]

0 commit comments

Comments
 (0)