Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixups related to tests and features #212

Merged
merged 3 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions taiga_halo2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ num-bigint = "0.4"

rustler = { version = "0.29.1", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
borsh = { version = "1.0.0-alpha.3", features = ["derive"], optional = true }
borsh = { version = "= 1.0.0-alpha.3", features = ["derive"], optional = true }

[dev-dependencies]
criterion = "0.5"
Expand All @@ -46,6 +46,6 @@ name = "tx_examples"

[features]
default = []
nif = ["dep:rustler", "pasta_curves/repr-erlang"]
nif = ["dep:rustler", "borsh", "pasta_curves/repr-erlang"]
serde = ["dep:serde", "pasta_curves/serde"]
borsh = ["dep:borsh"]
7 changes: 3 additions & 4 deletions taiga_halo2/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@
self.shielded_ptx_bundle.encode(env),
self.transparent_ptx_bundle
.try_to_vec()
.unwrap_or(vec![])

Check warning on line 232 in taiga_halo2/src/transaction.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

use of `unwrap_or` to construct default value

warning: use of `unwrap_or` to construct default value --> taiga_halo2/src/transaction.rs:232:18 | 232 | .unwrap_or(vec![]) | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default = note: `-W clippy::unwrap-or-default` implied by `-W clippy::all`

Check warning on line 232 in taiga_halo2/src/transaction.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

use of `unwrap_or` to construct default value

warning: use of `unwrap_or` to construct default value --> taiga_halo2/src/transaction.rs:232:18 | 232 | .unwrap_or(vec![]) | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default = note: `-W clippy::unwrap-or-default` implied by `-W clippy::all`
.encode(env),
self.signature.try_to_vec().unwrap_or(vec![]).encode(env),

Check warning on line 234 in taiga_halo2/src/transaction.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

use of `unwrap_or` to construct default value

warning: use of `unwrap_or` to construct default value --> taiga_halo2/src/transaction.rs:234:41 | 234 | self.signature.try_to_vec().unwrap_or(vec![]).encode(env), | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default

Check warning on line 234 in taiga_halo2/src/transaction.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

use of `unwrap_or` to construct default value

warning: use of `unwrap_or` to construct default value --> taiga_halo2/src/transaction.rs:234:41 | 234 | self.signature.try_to_vec().unwrap_or(vec![]).encode(env), | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
)
.encode(env)
}
Expand Down Expand Up @@ -403,8 +403,7 @@

#[test]
fn test_halo2_transaction() {
use super::Transaction;
use borsh::{BorshDeserialize, BorshSerialize};
use super::*;
use rand::rngs::OsRng;

let rng = OsRng;
Expand All @@ -418,14 +417,14 @@
transparent_ptx_bundle,
r_vec,
);
let (shielded_ret, _) = tx.execute().unwrap();
let (_shielded_ret, _) = tx.execute().unwrap();

#[cfg(feature = "borsh")]
{
let borsh = tx.try_to_vec().unwrap();
let de_tx: Transaction = BorshDeserialize::deserialize(&mut borsh.as_ref()).unwrap();
let (de_shielded_ret, _) = de_tx.execute().unwrap();
assert_eq!(shielded_ret, de_shielded_ret);
assert_eq!(_shielded_ret, de_shielded_ret);
}
}
}
Loading