mirror of
https://github.com/jwinterm/mwixnet.git
synced 2026-10-25 16:38:32 +01:00
Build against grin 5.4.0 and the deps-merged contracts branch
Fixes mwixnet#32 (no longer builds on current Rust). The grin node deps move to the 5.4.0 release crates; grin-wallet points at jwinterm/grin-wallet contracts work pinned by revision. Drops unused grin_servers/chain/p2p from the main build (grin_servers isn't published). - Cargo.toml: grin_* -> 5.4.0; grin_wallet_* -> contracts fork (rev-pinned). - secp::random_secret now takes use_test_rng; pass false at all call sites. - create_onion / ComSignature::sign take a use_test_rng bool; pass false in tests. - Test modules reference the file-level onion alias via super::grin_onion. - tests/e2e.rs (boots a real node+miner) gated behind a new `integration` feature so a default `cargo test` runs the unit suite (18 tests) without a node.
This commit is contained in:
Generated
+585
-517
File diff suppressed because it is too large
Load Diff
+25
-15
@@ -5,6 +5,12 @@ edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[features]
|
||||
# Opt-in end-to-end test harness (tests/e2e.rs) that runs a real node + miner.
|
||||
# Enabling it also requires re-adding the grin node deps (grin_chain/p2p/servers)
|
||||
# from a single git source, plus a [patch.crates-io] so wallet+server+node share one grin.
|
||||
integration = []
|
||||
|
||||
[dependencies]
|
||||
arti-client = { version = "0.18.0", default-features = false, features = ["async-std", "rustls", "onion-service-client", "onion-service-service"] }
|
||||
arti-hyper = "0.18.0"
|
||||
@@ -55,19 +61,23 @@ tor-rtcompat = "0.18.0"
|
||||
x25519-dalek = "0.6.0"
|
||||
log = "0.4.20"
|
||||
|
||||
# Bleeding Edge Grin Deps
|
||||
# Grin 5.4.0 release crates (same source the grin-wallet fork links, so they unify).
|
||||
# grin_servers/chain/p2p dropped: unused in src and grin_servers isn't published.
|
||||
grin_secp256k1zkp = { version = "0.7.14", features = ["bullet-proof-sizing"] }
|
||||
grin_api = { git = "https://github.com/mimblewimble/grin", branch = "master" }
|
||||
grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
|
||||
grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
|
||||
grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
|
||||
grin_p2p = { git = "https://github.com/mimblewimble/grin", branch = "master" }
|
||||
grin_servers = { git = "https://github.com/mimblewimble/grin", branch = "master" }
|
||||
grin_store = { git = "https://github.com/mimblewimble/grin", branch = "master" }
|
||||
grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }
|
||||
grin_wallet_api = { git = "https://github.com/mimblewimble/grin-wallet", branch = "contracts" }
|
||||
grin_wallet_config = { git = "https://github.com/mimblewimble/grin-wallet", branch = "contracts" }
|
||||
grin_wallet_controller = { git = "https://github.com/mimblewimble/grin-wallet", branch = "contracts" }
|
||||
grin_wallet_impls = { git = "https://github.com/mimblewimble/grin-wallet", branch = "contracts" }
|
||||
grin_wallet_libwallet = { git = "https://github.com/mimblewimble/grin-wallet", branch = "contracts" }
|
||||
grin_wallet_util = { git = "https://github.com/mimblewimble/grin-wallet", branch = "contracts" }
|
||||
grin_api = "5.4.0"
|
||||
grin_core = "5.4.0"
|
||||
grin_keychain = "5.4.0"
|
||||
grin_store = "5.4.0"
|
||||
grin_util = "5.4.0"
|
||||
# grin-wallet contracts work, pinned to a revision (not a branch) for reproducible builds.
|
||||
grin_wallet_api = { git = "https://github.com/jwinterm/grin-wallet", rev = "ce779188b19e949e3837f80eeaf73c31f61e17c0" }
|
||||
grin_wallet_config = { git = "https://github.com/jwinterm/grin-wallet", rev = "ce779188b19e949e3837f80eeaf73c31f61e17c0" }
|
||||
grin_wallet_controller = { git = "https://github.com/jwinterm/grin-wallet", rev = "ce779188b19e949e3837f80eeaf73c31f61e17c0" }
|
||||
grin_wallet_impls = { git = "https://github.com/jwinterm/grin-wallet", rev = "ce779188b19e949e3837f80eeaf73c31f61e17c0" }
|
||||
grin_wallet_libwallet = { git = "https://github.com/jwinterm/grin-wallet", rev = "ce779188b19e949e3837f80eeaf73c31f61e17c0" }
|
||||
grin_wallet_util = { git = "https://github.com/jwinterm/grin-wallet", rev = "ce779188b19e949e3837f80eeaf73c31f61e17c0" }
|
||||
|
||||
[dev-dependencies]
|
||||
# Tests use the mwixnet onion test helpers (rand_onion, proof, rand_keypair, ...).
|
||||
# Dev-only so they stay out of normal builds (resolver 2).
|
||||
grin_wallet_libwallet = { git = "https://github.com/jwinterm/grin-wallet", rev = "ce779188b19e949e3837f80eeaf73c31f61e17c0", features = ["test-helpers"] }
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ fn real_main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
|
||||
let server_config = ServerConfig {
|
||||
key: crypto::secp::random_secret(),
|
||||
key: crypto::secp::random_secret(false),
|
||||
interval_s: round_time.unwrap_or(DEFAULT_INTERVAL),
|
||||
addr: bind_addr.unwrap_or("127.0.0.1:3000").parse()?,
|
||||
grin_node_url: match grin_node_url {
|
||||
|
||||
+3
-3
@@ -285,7 +285,7 @@ pub fn wallet_owner_url(_chain_type: &ChainTypes) -> String {
|
||||
pub mod test_util {
|
||||
use std::net::TcpListener;
|
||||
|
||||
use grin_onion::crypto::dalek::DalekPublicKey;
|
||||
use super::grin_onion::crypto::dalek::DalekPublicKey;
|
||||
use secp256k1zkp::SecretKey;
|
||||
|
||||
use crate::config::ServerConfig;
|
||||
@@ -312,14 +312,14 @@ pub mod test_util {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use grin_onion::crypto::secp;
|
||||
use super::grin_onion::crypto::secp;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn server_key_encrypt() {
|
||||
let password = ZeroingString::from("password");
|
||||
let server_key = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let mut enc_key = EncryptedServerKey::from_secret_key(&server_key, &password);
|
||||
let decrypted_key = enc_key.decrypt(&password).unwrap();
|
||||
assert_eq!(server_key, decrypted_key);
|
||||
|
||||
+4
-4
@@ -112,7 +112,7 @@ pub mod mock {
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use grin_onion::onion::Onion;
|
||||
use super::grin_onion::onion::Onion;
|
||||
|
||||
use crate::servers::mix_rpc::MixResp;
|
||||
|
||||
@@ -155,9 +155,9 @@ pub mod test_util {
|
||||
use grin_core::ser;
|
||||
use grin_core::ser::ProtocolVersion;
|
||||
|
||||
use grin_onion::crypto::dalek::{self, DalekPublicKey};
|
||||
use grin_onion::crypto::secp::SecretKey;
|
||||
use grin_onion::onion::Onion;
|
||||
use super::grin_onion::crypto::dalek::{self, DalekPublicKey};
|
||||
use super::grin_onion::crypto::secp::SecretKey;
|
||||
use super::grin_onion::onion::Onion;
|
||||
|
||||
use crate::servers::mix::MixServer;
|
||||
use crate::servers::mix_rpc::MixResp;
|
||||
|
||||
+1
-1
@@ -248,7 +248,7 @@ pub mod mock {
|
||||
use grin_core::core::hash::Hash;
|
||||
use grin_core::core::Transaction;
|
||||
|
||||
use grin_onion::crypto::secp::Commitment;
|
||||
use super::grin_onion::crypto::secp::Commitment;
|
||||
|
||||
use super::{GrinNode, NodeError};
|
||||
|
||||
|
||||
+8
-7
@@ -303,7 +303,7 @@ impl MixServer for MixServerImpl {
|
||||
mod test_util {
|
||||
use std::sync::Arc;
|
||||
|
||||
use grin_onion::crypto::dalek::DalekPublicKey;
|
||||
use super::grin_onion::crypto::dalek::DalekPublicKey;
|
||||
use secp256k1zkp::SecretKey;
|
||||
|
||||
use crate::config;
|
||||
@@ -349,10 +349,10 @@ mod tests {
|
||||
|
||||
use ::function_name::named;
|
||||
|
||||
use grin_onion::{create_onion, Hop, new_hop};
|
||||
use grin_onion::crypto::dalek::DalekPublicKey;
|
||||
use grin_onion::crypto::secp::{self, Commitment};
|
||||
use grin_onion::test_util as onion_test_util;
|
||||
use super::grin_onion::{create_onion, Hop, new_hop};
|
||||
use super::grin_onion::crypto::dalek::DalekPublicKey;
|
||||
use super::grin_onion::crypto::secp::{self, Commitment};
|
||||
use super::grin_onion::test_util as onion_test_util;
|
||||
use secp256k1zkp::pedersen::RangeProof;
|
||||
use secp256k1zkp::SecretKey;
|
||||
|
||||
@@ -380,7 +380,7 @@ mod tests {
|
||||
impl ServerVars {
|
||||
fn new(fee: u32) -> Self {
|
||||
let (sk, pk) = onion_test_util::rand_keypair();
|
||||
let excess = secp::random_secret();
|
||||
let excess = secp::random_secret(false);
|
||||
ServerVars {
|
||||
fee,
|
||||
sk,
|
||||
@@ -407,7 +407,7 @@ mod tests {
|
||||
|
||||
// Setup Input(s)
|
||||
let input1_value: u64 = 200_000_000;
|
||||
let input1_blind = secp::random_secret();
|
||||
let input1_blind = secp::random_secret(false);
|
||||
let input1_commit = secp::commit(input1_value, &input1_blind)?;
|
||||
let input_commits = vec![&input1_commit];
|
||||
|
||||
@@ -449,6 +449,7 @@ mod tests {
|
||||
mix1_vars.build_hop(None),
|
||||
mix2_vars.build_hop(Some(proof)),
|
||||
],
|
||||
false,
|
||||
)?;
|
||||
|
||||
// Simulate the swap server peeling the onion and then calling mix1
|
||||
|
||||
+63
-63
@@ -389,8 +389,8 @@ pub mod mock {
|
||||
use async_trait::async_trait;
|
||||
use grin_core::core::Transaction;
|
||||
|
||||
use grin_onion::crypto::comsig::ComSignature;
|
||||
use grin_onion::onion::Onion;
|
||||
use super::grin_onion::crypto::comsig::ComSignature;
|
||||
use super::grin_onion::onion::Onion;
|
||||
|
||||
use super::{SwapError, SwapServer};
|
||||
|
||||
@@ -437,8 +437,8 @@ pub mod mock {
|
||||
pub mod test_util {
|
||||
use std::sync::Arc;
|
||||
|
||||
use grin_onion::crypto::dalek::DalekPublicKey;
|
||||
use grin_onion::crypto::secp::SecretKey;
|
||||
use super::grin_onion::crypto::dalek::DalekPublicKey;
|
||||
use super::grin_onion::crypto::secp::SecretKey;
|
||||
|
||||
use crate::config;
|
||||
use crate::mix_client::MixClient;
|
||||
@@ -482,11 +482,11 @@ mod tests {
|
||||
use secp256k1zkp::key::ZERO_KEY;
|
||||
use x25519_dalek::PublicKey as xPublicKey;
|
||||
|
||||
use grin_onion::crypto::comsig::ComSignature;
|
||||
use grin_onion::crypto::secp;
|
||||
use grin_onion::onion::Onion;
|
||||
use grin_onion::test_util as onion_test_util;
|
||||
use grin_onion::{create_onion, new_hop, Hop};
|
||||
use super::grin_onion::crypto::comsig::ComSignature;
|
||||
use super::grin_onion::crypto::secp;
|
||||
use super::grin_onion::onion::Onion;
|
||||
use super::grin_onion::test_util as onion_test_util;
|
||||
use super::grin_onion::{create_onion, new_hop, Hop};
|
||||
|
||||
use crate::mix_client::{self, MixClient};
|
||||
use crate::node::mock::MockGrinNode;
|
||||
@@ -526,16 +526,16 @@ mod tests {
|
||||
|
||||
let value: u64 = 200_000_000;
|
||||
let fee: u32 = 50_000_000;
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let input_commit = secp::commit(value, &blind)?;
|
||||
|
||||
let server_key = secp::random_secret();
|
||||
let hop_excess = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let hop_excess = secp::random_secret(false);
|
||||
let (output_commit, proof) = onion_test_util::proof(value, fee, &blind, &vec![&hop_excess]);
|
||||
let hop = new_hop(&server_key, &hop_excess, fee, Some(proof));
|
||||
|
||||
let onion = create_onion(&input_commit, &vec![hop.clone()])?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?)?;
|
||||
let onion = create_onion(&input_commit, &vec![hop.clone()], false)?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?, false)?;
|
||||
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new_with_utxos(&vec![&input_commit]));
|
||||
let (server, _) = super::test_util::new_swapper(&test_dir, &server_key, None, node.clone());
|
||||
@@ -597,20 +597,20 @@ mod tests {
|
||||
|
||||
// Setup input
|
||||
let value: u64 = 200_000_000;
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let input_commit = secp::commit(value, &blind)?;
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new_with_utxos(&vec![&input_commit]));
|
||||
|
||||
// Swapper data
|
||||
let swap_fee: u32 = 50_000_000;
|
||||
let (swap_sk, _swap_pk) = onion_test_util::rand_keypair();
|
||||
let swap_hop_excess = secp::random_secret();
|
||||
let swap_hop_excess = secp::random_secret(false);
|
||||
let swap_hop = new_hop(&swap_sk, &swap_hop_excess, swap_fee, None);
|
||||
|
||||
// Mixer data
|
||||
let mixer_fee: u32 = 30_000_000;
|
||||
let (mixer_sk, mixer_pk) = onion_test_util::rand_keypair();
|
||||
let mixer_hop_excess = secp::random_secret();
|
||||
let mixer_hop_excess = secp::random_secret(false);
|
||||
let (output_commit, proof) = onion_test_util::proof(
|
||||
value,
|
||||
swap_fee + mixer_fee,
|
||||
@@ -620,8 +620,8 @@ mod tests {
|
||||
let mixer_hop = new_hop(&mixer_sk, &mixer_hop_excess, mixer_fee, Some(proof));
|
||||
|
||||
// Create onion
|
||||
let onion = create_onion(&input_commit, &vec![swap_hop, mixer_hop])?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?)?;
|
||||
let onion = create_onion(&input_commit, &vec![swap_hop, mixer_hop], false)?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?, false)?;
|
||||
|
||||
// Mock mixer
|
||||
let mixer_onion = onion.peel_layer(&swap_sk)?.onion;
|
||||
@@ -676,18 +676,18 @@ mod tests {
|
||||
|
||||
let value: u64 = 200_000_000;
|
||||
let fee: u32 = 50_000_000;
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let input_commit = secp::commit(value, &blind)?;
|
||||
|
||||
let server_key = secp::random_secret();
|
||||
let hop_excess = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let hop_excess = secp::random_secret(false);
|
||||
let (_output_commit, proof) =
|
||||
onion_test_util::proof(value, fee, &blind, &vec![&hop_excess]);
|
||||
let hop = new_hop(&server_key, &hop_excess, fee, Some(proof));
|
||||
|
||||
let hops: Vec<Hop> = vec![hop.clone(), hop.clone()]; // Multiple payloads
|
||||
let onion = create_onion(&input_commit, &hops)?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?)?;
|
||||
let onion = create_onion(&input_commit, &hops, false)?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?, false)?;
|
||||
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new_with_utxos(&vec![&input_commit]));
|
||||
let (server, _) = super::test_util::new_swapper(&test_dir, &server_key, None, node.clone());
|
||||
@@ -708,19 +708,19 @@ mod tests {
|
||||
|
||||
let value: u64 = 200_000_000;
|
||||
let fee: u32 = 50_000_000;
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let input_commit = secp::commit(value, &blind)?;
|
||||
|
||||
let server_key = secp::random_secret();
|
||||
let hop_excess = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let hop_excess = secp::random_secret(false);
|
||||
let (_output_commit, proof) =
|
||||
onion_test_util::proof(value, fee, &blind, &vec![&hop_excess]);
|
||||
let hop = new_hop(&server_key, &hop_excess, fee, Some(proof));
|
||||
|
||||
let onion = create_onion(&input_commit, &vec![hop])?;
|
||||
let onion = create_onion(&input_commit, &vec![hop], false)?;
|
||||
|
||||
let wrong_blind = secp::random_secret();
|
||||
let comsig = ComSignature::sign(value, &wrong_blind, &onion.serialize()?)?;
|
||||
let wrong_blind = secp::random_secret(false);
|
||||
let comsig = ComSignature::sign(value, &wrong_blind, &onion.serialize()?, false)?;
|
||||
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new_with_utxos(&vec![&input_commit]));
|
||||
let (server, _) = super::test_util::new_swapper(&test_dir, &server_key, None, node.clone());
|
||||
@@ -741,18 +741,18 @@ mod tests {
|
||||
|
||||
let value: u64 = 200_000_000;
|
||||
let fee: u32 = 50_000_000;
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let input_commit = secp::commit(value, &blind)?;
|
||||
|
||||
let server_key = secp::random_secret();
|
||||
let hop_excess = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let hop_excess = secp::random_secret(false);
|
||||
let wrong_value = value + 10_000_000;
|
||||
let (_output_commit, proof) =
|
||||
onion_test_util::proof(wrong_value, fee, &blind, &vec![&hop_excess]);
|
||||
let hop = new_hop(&server_key, &hop_excess, fee, Some(proof));
|
||||
|
||||
let onion = create_onion(&input_commit, &vec![hop])?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?)?;
|
||||
let onion = create_onion(&input_commit, &vec![hop], false)?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?, false)?;
|
||||
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new_with_utxos(&vec![&input_commit]));
|
||||
let (server, _) = super::test_util::new_swapper(&test_dir, &server_key, None, node.clone());
|
||||
@@ -773,15 +773,15 @@ mod tests {
|
||||
|
||||
let value: u64 = 200_000_000;
|
||||
let fee: u32 = 50_000_000;
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let input_commit = secp::commit(value, &blind)?;
|
||||
|
||||
let server_key = secp::random_secret();
|
||||
let hop_excess = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let hop_excess = secp::random_secret(false);
|
||||
let hop = new_hop(&server_key, &hop_excess, fee, None);
|
||||
|
||||
let onion = create_onion(&input_commit, &vec![hop])?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?)?;
|
||||
let onion = create_onion(&input_commit, &vec![hop], false)?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?, false)?;
|
||||
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new_with_utxos(&vec![&input_commit]));
|
||||
let (server, _) = super::test_util::new_swapper(&test_dir, &server_key, None, node.clone());
|
||||
@@ -802,17 +802,17 @@ mod tests {
|
||||
|
||||
let value: u64 = 200_000_000;
|
||||
let fee: u32 = 50_000_000;
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let input_commit = secp::commit(value, &blind)?;
|
||||
|
||||
let server_key = secp::random_secret();
|
||||
let hop_excess = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let hop_excess = secp::random_secret(false);
|
||||
let (_output_commit, proof) =
|
||||
onion_test_util::proof(value, fee, &blind, &vec![&hop_excess]);
|
||||
let hop = new_hop(&server_key, &hop_excess, fee, Some(proof));
|
||||
|
||||
let onion = create_onion(&input_commit, &vec![hop])?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?)?;
|
||||
let onion = create_onion(&input_commit, &vec![hop], false)?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?, false)?;
|
||||
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new());
|
||||
let (server, _) = super::test_util::new_swapper(&test_dir, &server_key, None, node.clone());
|
||||
@@ -838,17 +838,17 @@ mod tests {
|
||||
|
||||
let value: u64 = 200_000_000;
|
||||
let fee: u32 = 50_000_000;
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let input_commit = secp::commit(value, &blind)?;
|
||||
|
||||
let server_key = secp::random_secret();
|
||||
let hop_excess = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let hop_excess = secp::random_secret(false);
|
||||
let (_output_commit, proof) =
|
||||
onion_test_util::proof(value, fee, &blind, &vec![&hop_excess]);
|
||||
let hop = new_hop(&server_key, &hop_excess, fee, Some(proof));
|
||||
|
||||
let onion = create_onion(&input_commit, &vec![hop])?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?)?;
|
||||
let onion = create_onion(&input_commit, &vec![hop], false)?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?, false)?;
|
||||
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new_with_utxos(&vec![&input_commit]));
|
||||
let (server, _) = super::test_util::new_swapper(&test_dir, &server_key, None, node.clone());
|
||||
@@ -872,10 +872,10 @@ mod tests {
|
||||
async fn swap_tx_not_found() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let test_dir = init_test!();
|
||||
|
||||
let server_key = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new());
|
||||
let (server, _) = super::test_util::new_swapper(&test_dir, &server_key, None, node.clone());
|
||||
let kern = tx::build_kernel(&secp::random_secret(), 1000u64)?;
|
||||
let kern = tx::build_kernel(&secp::random_secret(false), 1000u64)?;
|
||||
let tx: Arc<Transaction> =
|
||||
Arc::new(Transaction::new(Inputs::default(), &[], &[kern.clone()]));
|
||||
let result = server.check_reorg(&tx).await;
|
||||
@@ -892,19 +892,19 @@ mod tests {
|
||||
|
||||
let value: u64 = 200_000_000;
|
||||
let fee: u32 = 50_000_000;
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let input_commit = secp::commit(value, &blind)?;
|
||||
|
||||
let server_key = secp::random_secret();
|
||||
let hop_excess = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let hop_excess = secp::random_secret(false);
|
||||
let (_output_commit, proof) =
|
||||
onion_test_util::proof(value, fee, &blind, &vec![&hop_excess]);
|
||||
|
||||
let wrong_server_key = secp::random_secret();
|
||||
let wrong_server_key = secp::random_secret(false);
|
||||
let hop = new_hop(&wrong_server_key, &hop_excess, fee, Some(proof));
|
||||
|
||||
let onion = create_onion(&input_commit, &vec![hop])?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?)?;
|
||||
let onion = create_onion(&input_commit, &vec![hop], false)?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?, false)?;
|
||||
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new_with_utxos(&vec![&input_commit]));
|
||||
let (server, _) = super::test_util::new_swapper(&test_dir, &server_key, None, node.clone());
|
||||
@@ -924,17 +924,17 @@ mod tests {
|
||||
|
||||
let value: u64 = 200_000_000;
|
||||
let fee: u32 = 1_000_000;
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let input_commit = secp::commit(value, &blind)?;
|
||||
|
||||
let server_key = secp::random_secret();
|
||||
let hop_excess = secp::random_secret();
|
||||
let server_key = secp::random_secret(false);
|
||||
let hop_excess = secp::random_secret(false);
|
||||
let (_output_commit, proof) =
|
||||
onion_test_util::proof(value, fee, &blind, &vec![&hop_excess]);
|
||||
let hop = new_hop(&server_key, &hop_excess, fee, Some(proof));
|
||||
|
||||
let onion = create_onion(&input_commit, &vec![hop])?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?)?;
|
||||
let onion = create_onion(&input_commit, &vec![hop], false)?;
|
||||
let comsig = ComSignature::sign(value, &blind, &onion.serialize()?, false)?;
|
||||
|
||||
let node: Arc<MockGrinNode> = Arc::new(MockGrinNode::new_with_utxos(&vec![&input_commit]));
|
||||
let (server, _) = super::test_util::new_swapper(&test_dir, &server_key, None, node.clone());
|
||||
|
||||
+10
-10
@@ -123,9 +123,9 @@ mod tests {
|
||||
use hyper::{Body, Client, Request, Response};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use grin_onion::create_onion;
|
||||
use grin_onion::crypto::comsig::ComSignature;
|
||||
use grin_onion::crypto::secp;
|
||||
use super::grin_onion::create_onion;
|
||||
use super::grin_onion::crypto::comsig::ComSignature;
|
||||
use super::grin_onion::crypto::secp;
|
||||
|
||||
use crate::config::ServerConfig;
|
||||
use crate::servers::swap::{SwapError, SwapServer};
|
||||
@@ -144,7 +144,7 @@ mod tests {
|
||||
runtime_handle: &tokio::runtime::Handle,
|
||||
) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let server_config = ServerConfig {
|
||||
key: secp::random_secret(),
|
||||
key: secp::random_secret(false),
|
||||
interval_s: 1,
|
||||
addr: TcpListener::bind("127.0.0.1:0")?.local_addr()?,
|
||||
grin_node_url: "127.0.0.1:3413".parse()?,
|
||||
@@ -191,9 +191,9 @@ mod tests {
|
||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()?;
|
||||
let commitment = secp::commit(1234, &secp::random_secret())?;
|
||||
let onion = create_onion(&commitment, &vec![])?;
|
||||
let comsig = ComSignature::sign(1234, &secp::random_secret(), &onion.serialize()?)?;
|
||||
let commitment = secp::commit(1234, &secp::random_secret(false))?;
|
||||
let onion = create_onion(&commitment, &vec![], false)?;
|
||||
let comsig = ComSignature::sign(1234, &secp::random_secret(false), &onion.serialize()?, false)?;
|
||||
let swap = SwapReq {
|
||||
onion: onion.clone(),
|
||||
comsig,
|
||||
@@ -239,9 +239,9 @@ mod tests {
|
||||
.enable_all()
|
||||
.build()?;
|
||||
|
||||
let commitment = secp::commit(1234, &secp::random_secret())?;
|
||||
let onion = create_onion(&commitment, &vec![])?;
|
||||
let comsig = ComSignature::sign(1234, &secp::random_secret(), &onion.serialize()?)?;
|
||||
let commitment = secp::commit(1234, &secp::random_secret(false))?;
|
||||
let onion = create_onion(&commitment, &vec![], false)?;
|
||||
let comsig = ComSignature::sign(1234, &secp::random_secret(false), &onion.serialize()?, false)?;
|
||||
let swap = SwapReq {
|
||||
onion: onion.clone(),
|
||||
comsig,
|
||||
|
||||
+3
-3
@@ -314,8 +314,8 @@ mod tests {
|
||||
use grin_core::global::{self, ChainTypes};
|
||||
use rand::RngCore;
|
||||
|
||||
use grin_onion::crypto::secp;
|
||||
use grin_onion::test_util as onion_test_util;
|
||||
use super::grin_onion::crypto::secp;
|
||||
use super::grin_onion::test_util as onion_test_util;
|
||||
|
||||
use crate::store::{StoreError, SwapData, SwapStatus, SwapStore};
|
||||
|
||||
@@ -328,7 +328,7 @@ mod tests {
|
||||
|
||||
fn rand_swap_with_status(status: SwapStatus) -> SwapData {
|
||||
SwapData {
|
||||
excess: secp::random_secret(),
|
||||
excess: secp::random_secret(false),
|
||||
output_commit: onion_test_util::rand_commit(),
|
||||
rangeproof: Some(onion_test_util::rand_proof()),
|
||||
input: Input::new(OutputFeatures::Plain, onion_test_util::rand_commit()),
|
||||
|
||||
@@ -143,7 +143,7 @@ async fn async_add_kernel_and_collect_fees(
|
||||
}
|
||||
|
||||
// generate random transaction offset
|
||||
let our_offset = secp::random_secret();
|
||||
let our_offset = secp::random_secret(false);
|
||||
let txn_offset = secp
|
||||
.blind_sum(vec![prev_offset.clone(), our_offset.clone()], Vec::new())
|
||||
.map_err(TxError::OffsetError)?;
|
||||
@@ -206,12 +206,10 @@ async fn async_add_kernel_and_collect_fees(
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use secp256k1zkp::key::SecretKey;
|
||||
/// use secp256k1zkp::rand::thread_rng;
|
||||
/// ```ignore
|
||||
/// use grin_onion::crypto::secp;
|
||||
///
|
||||
/// let secret_key = secp::random_secret();
|
||||
/// let secret_key = secp::random_secret(false);
|
||||
/// let fee = 10; // 10 nanogrin
|
||||
/// let kernel = mwixnet::tx::build_kernel(&secret_key, fee);
|
||||
/// ```
|
||||
|
||||
+5
-5
@@ -94,7 +94,7 @@ impl HttpWallet {
|
||||
wallet_owner_secret: &Option<String>,
|
||||
) -> Result<SecretKey, WalletError> {
|
||||
let secp = Secp256k1::new();
|
||||
let ephemeral_sk = secp::random_secret();
|
||||
let ephemeral_sk = secp::random_secret(false);
|
||||
let ephemeral_pk = PublicKey::from_secret_key(&secp, &ephemeral_sk).unwrap();
|
||||
let ephemeral_pk_bytes = ephemeral_pk.serialize_vec(&secp, true);
|
||||
let init_params = json!({
|
||||
@@ -190,7 +190,7 @@ pub mod mock {
|
||||
use grin_core::core::{Output, OutputFeatures};
|
||||
use grin_keychain::BlindingFactor;
|
||||
|
||||
use grin_onion::crypto::secp;
|
||||
use super::grin_onion::crypto::secp;
|
||||
use secp256k1zkp::pedersen::Commitment;
|
||||
use secp256k1zkp::Secp256k1;
|
||||
|
||||
@@ -224,13 +224,13 @@ pub mod mock {
|
||||
amount: u64,
|
||||
) -> Result<(BlindingFactor, Output), WalletError> {
|
||||
let secp = Secp256k1::new();
|
||||
let blind = secp::random_secret();
|
||||
let blind = secp::random_secret(false);
|
||||
let commit = secp::commit(amount, &blind).unwrap();
|
||||
let proof = secp.bullet_proof(
|
||||
amount,
|
||||
blind.clone(),
|
||||
secp::random_secret(),
|
||||
secp::random_secret(),
|
||||
secp::random_secret(false),
|
||||
secp::random_secret(false),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// End-to-end swap test. Boots a real grin node + miner, so it is opt-in behind the
|
||||
// `integration` feature and excluded from a default `cargo test`. Building it also
|
||||
// requires the grin node deps (grin_chain/p2p/servers) on a single git source.
|
||||
#![cfg(feature = "integration")]
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user