mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 07:11:36 +02:00
clean up contract tests
This commit is contained in:
@@ -97,6 +97,40 @@ pub fn contract_selection_args() -> libwallet::contract::types::OutputSelectionA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn contract_setup_args(
|
||||||
|
net_change: Option<i64>,
|
||||||
|
) -> libwallet::contract::types::ContractSetupArgsAPI {
|
||||||
|
libwallet::contract::types::ContractSetupArgsAPI {
|
||||||
|
selection_args: contract_selection_args(),
|
||||||
|
net_change,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn contract_new_args(net_change: i64) -> libwallet::contract::types::ContractNewArgsAPI {
|
||||||
|
libwallet::contract::types::ContractNewArgsAPI {
|
||||||
|
setup_args: contract_setup_args(Some(net_change)),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn roundtrip_slate(
|
||||||
|
slate: &libwallet::Slate,
|
||||||
|
version: u16,
|
||||||
|
) -> Result<libwallet::Slate, libwallet::Error> {
|
||||||
|
let packer = libwallet::Slatepacker::new(libwallet::SlatepackerArgs {
|
||||||
|
sender: None,
|
||||||
|
recipients: vec![],
|
||||||
|
dec_key: None,
|
||||||
|
});
|
||||||
|
let slate = packer.get_slate(&packer.create_slatepack(slate)?)?;
|
||||||
|
assert_eq!(slate.version_info.version, version);
|
||||||
|
Ok(slate)
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub struct ExpectedContractSlate {
|
pub struct ExpectedContractSlate {
|
||||||
pub amount: u64,
|
pub amount: u64,
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ fn contract_accounts_switch_impl(test_dir: &'static str) -> Result<(), libwallet
|
|||||||
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
|
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
|
||||||
assert!(wallet1_refreshed);
|
assert!(wallet1_refreshed);
|
||||||
assert_eq!(wallet1_info.last_confirmed_height, 10);
|
assert_eq!(wallet1_info.last_confirmed_height, 10);
|
||||||
assert_eq!(wallet1_info.total, 1 * reward);
|
assert_eq!(wallet1_info.total, reward);
|
||||||
assert_eq!(wallet1_info.amount_currently_spendable, 1 * reward);
|
assert_eq!(wallet1_info.amount_currently_spendable, reward);
|
||||||
let (_, txs) = api.retrieve_txs(m, true, None, None, None)?;
|
let (_, txs) = api.retrieve_txs(m, true, None, None, None)?;
|
||||||
assert_eq!(txs.len(), 1);
|
assert_eq!(txs.len(), 1);
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -116,7 +116,6 @@ fn contract_accounts_switch_impl(test_dir: &'static str) -> Result<(), libwallet
|
|||||||
net_change: Some(-5_000_000_000),
|
net_change: Some(-5_000_000_000),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
..Default::default()
|
|
||||||
};
|
};
|
||||||
slate = api.contract_new(m, args)?;
|
slate = api.contract_new(m, args)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -227,7 +226,7 @@ fn contract_accounts_switch_impl(test_dir: &'static str) -> Result<(), libwallet
|
|||||||
assert_eq!(wallet1_info.last_confirmed_height, 11);
|
assert_eq!(wallet1_info.last_confirmed_height, 11);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
wallet1_info.total,
|
wallet1_info.total,
|
||||||
1 * reward - 5_000_000_000 - my_fee_contribution(1, 1, 1, 2)?.fee() // we subtract also our fee contribution
|
reward - 5_000_000_000 - my_fee_contribution(1, 1, 1, 2)?.fee() // we subtract also our fee contribution
|
||||||
);
|
);
|
||||||
let (_, txs) = api.retrieve_txs(m, true, None, None, None)?;
|
let (_, txs) = api.retrieve_txs(m, true, None, None, None)?;
|
||||||
assert_eq!(txs.len(), 2);
|
assert_eq!(txs.len(), 2);
|
||||||
|
|||||||
@@ -27,10 +27,8 @@ use grin_wallet_libwallet as libwallet;
|
|||||||
use grin_util::secp::{Secp256k1, Signature};
|
use grin_util::secp::{Secp256k1, Signature};
|
||||||
use impls::test_framework::{self};
|
use impls::test_framework::{self};
|
||||||
use libwallet::contract::my_fee_contribution;
|
use libwallet::contract::my_fee_contribution;
|
||||||
use libwallet::contract::types::{
|
use libwallet::contract::types::{PaymentMemo, ProofType};
|
||||||
ContractNewArgsAPI, ContractSetupArgsAPI, PaymentMemo, ProofType,
|
use libwallet::{Slate, SlateState, TxLogEntryType};
|
||||||
};
|
|
||||||
use libwallet::{Slate, SlateState, Slatepacker, SlatepackerArgs, TxLogEntryType};
|
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -40,17 +38,6 @@ mod common;
|
|||||||
use common::{clean_output_dir, create_wallets, setup};
|
use common::{clean_output_dir, create_wallets, setup};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn roundtrip_slate(slate: &Slate, version: u16) -> Result<Slate, libwallet::Error> {
|
|
||||||
let packer = Slatepacker::new(SlatepackerArgs {
|
|
||||||
sender: None,
|
|
||||||
recipients: vec![],
|
|
||||||
dec_key: None,
|
|
||||||
});
|
|
||||||
let slate = packer.get_slate(&packer.create_slatepack(slate)?)?;
|
|
||||||
assert_eq!(slate.version_info.version, version);
|
|
||||||
Ok(slate)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Development + Tests of early payment proof functionality - RSR workflow
|
/// Development + Tests of early payment proof functionality - RSR workflow
|
||||||
fn contract_early_proofs_rsr_test_impl(
|
fn contract_early_proofs_rsr_test_impl(
|
||||||
test_dir: &'static str,
|
test_dir: &'static str,
|
||||||
@@ -85,14 +72,7 @@ fn contract_early_proofs_rsr_test_impl(
|
|||||||
PathBuf::from(test_dir),
|
PathBuf::from(test_dir),
|
||||||
|api, m| {
|
|api, m| {
|
||||||
// Receive wallet (invoice) calls --receive=5
|
// Receive wallet (invoice) calls --receive=5
|
||||||
let args = &mut ContractNewArgsAPI {
|
let args = &mut common::contract_new_args(5_000_000_000);
|
||||||
setup_args: ContractSetupArgsAPI {
|
|
||||||
selection_args: common::contract_selection_args(),
|
|
||||||
net_change: Some(5_000_000_000),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
// Proofs are opt-in; enable and supply the sender address.
|
// Proofs are opt-in; enable and supply the sender address.
|
||||||
args.setup_args.proof_args.suppress_proof = false;
|
args.setup_args.proof_args.suppress_proof = false;
|
||||||
args.setup_args.proof_args.proof_type = proof_type;
|
args.setup_args.proof_args.proof_type = proof_type;
|
||||||
@@ -105,7 +85,7 @@ fn contract_early_proofs_rsr_test_impl(
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_eq!(slate.state, SlateState::Invoice1);
|
assert_eq!(slate.state, SlateState::Invoice1);
|
||||||
slate = roundtrip_slate(&slate, 5)?;
|
slate = common::roundtrip_slate(&slate, 5)?;
|
||||||
|
|
||||||
wallet::controller::owner_single_use(
|
wallet::controller::owner_single_use(
|
||||||
send_wallet.clone(),
|
send_wallet.clone(),
|
||||||
@@ -113,18 +93,14 @@ fn contract_early_proofs_rsr_test_impl(
|
|||||||
PathBuf::from(test_dir),
|
PathBuf::from(test_dir),
|
||||||
|api, m| {
|
|api, m| {
|
||||||
// Sending wallet (invoice) signs
|
// Sending wallet (invoice) signs
|
||||||
let args = &ContractSetupArgsAPI {
|
let args = &common::contract_setup_args(Some(-5_000_000_000));
|
||||||
selection_args: common::contract_selection_args(),
|
|
||||||
net_change: Some(-5_000_000_000),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
slate = api.contract_sign(m, &slate, args)?;
|
slate = api.contract_sign(m, &slate, args)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_eq!(slate.state, SlateState::Invoice2);
|
assert_eq!(slate.state, SlateState::Invoice2);
|
||||||
slate = roundtrip_slate(&slate, 5)?;
|
slate = common::roundtrip_slate(&slate, 5)?;
|
||||||
|
|
||||||
// Send wallet finalizes and posts
|
// Send wallet finalizes and posts
|
||||||
wallet::controller::owner_single_use(
|
wallet::controller::owner_single_use(
|
||||||
@@ -132,16 +108,13 @@ fn contract_early_proofs_rsr_test_impl(
|
|||||||
recv_mask,
|
recv_mask,
|
||||||
PathBuf::from(test_dir),
|
PathBuf::from(test_dir),
|
||||||
|api, m| {
|
|api, m| {
|
||||||
let args = &ContractSetupArgsAPI {
|
let args = &common::contract_setup_args(None);
|
||||||
selection_args: common::contract_selection_args(),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
slate = api.contract_sign(m, &slate, args)?;
|
slate = api.contract_sign(m, &slate, args)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
assert_eq!(slate.state, SlateState::Invoice3);
|
assert_eq!(slate.state, SlateState::Invoice3);
|
||||||
slate = roundtrip_slate(&slate, 5)?;
|
slate = common::roundtrip_slate(&slate, 5)?;
|
||||||
|
|
||||||
wallet::controller::owner_single_use(
|
wallet::controller::owner_single_use(
|
||||||
send_wallet.clone(),
|
send_wallet.clone(),
|
||||||
@@ -175,11 +148,11 @@ fn contract_early_proofs_rsr_test_impl(
|
|||||||
assert_eq!(tx_log.amount_debited, 0);
|
assert_eq!(tx_log.amount_debited, 0);
|
||||||
assert_eq!(tx_log.num_inputs, 1);
|
assert_eq!(tx_log.num_inputs, 1);
|
||||||
assert_eq!(tx_log.num_outputs, 1);
|
assert_eq!(tx_log.num_outputs, 1);
|
||||||
let expected_fees_paid = Some(my_fee_contribution(1, 1, 1, 2)?);
|
let expected_fees_paid = my_fee_contribution(1, 1, 1, 2)?;
|
||||||
assert_eq!(tx_log.fee, expected_fees_paid);
|
assert_eq!(tx_log.fee, Some(expected_fees_paid));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
wallet_info.amount_currently_spendable,
|
wallet_info.amount_currently_spendable,
|
||||||
4 * 60_000_000_000 + 5_000_000_000 - expected_fees_paid.unwrap().fee() // we expect the balance of 4 mined blocks + 5 Grin - fees paid
|
4 * 60_000_000_000 + 5_000_000_000 - expected_fees_paid.fee() // we expect the balance of 4 mined blocks + 5 Grin - fees paid
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ use grin_wallet_libwallet as libwallet;
|
|||||||
|
|
||||||
use impls::test_framework::{self};
|
use impls::test_framework::{self};
|
||||||
use libwallet::contract::my_fee_contribution;
|
use libwallet::contract::my_fee_contribution;
|
||||||
use libwallet::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI, PaymentMemo};
|
use libwallet::contract::types::PaymentMemo;
|
||||||
use libwallet::{NodeVersionInfo, Slate, SlateState, Slatepacker, SlatepackerArgs, TxLogEntryType};
|
use libwallet::{NodeVersionInfo, Slate, SlateState, TxLogEntryType};
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -52,17 +52,6 @@ fn reject_proof_verification(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn roundtrip_slate(slate: &Slate, version: u16) -> Result<Slate, libwallet::Error> {
|
|
||||||
let packer = Slatepacker::new(SlatepackerArgs {
|
|
||||||
sender: None,
|
|
||||||
recipients: vec![],
|
|
||||||
dec_key: None,
|
|
||||||
});
|
|
||||||
let slate = packer.get_slate(&packer.create_slatepack(slate)?)?;
|
|
||||||
assert_eq!(slate.version_info.version, version);
|
|
||||||
Ok(slate)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Development + Tests of early payment proof functionality
|
/// Development + Tests of early payment proof functionality
|
||||||
fn contract_early_proofs_srs_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
fn contract_early_proofs_srs_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
||||||
// create two wallets and mine 4 blocks in each (we want both to have balance to get a payjoin)
|
// create two wallets and mine 4 blocks in each (we want both to have balance to get a payjoin)
|
||||||
@@ -82,21 +71,14 @@ fn contract_early_proofs_srs_test_impl(test_dir: &'static str) -> Result<(), lib
|
|||||||
PathBuf::from(test_dir),
|
PathBuf::from(test_dir),
|
||||||
|api, m| {
|
|api, m| {
|
||||||
// Send wallet inititates a standard transaction with --send=5
|
// Send wallet inititates a standard transaction with --send=5
|
||||||
let args = &ContractNewArgsAPI {
|
let args = &common::contract_new_args(-5_000_000_000);
|
||||||
setup_args: ContractSetupArgsAPI {
|
|
||||||
selection_args: common::contract_selection_args(),
|
|
||||||
net_change: Some(-5_000_000_000),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
slate = api.contract_new(m, args)?;
|
slate = api.contract_new(m, args)?;
|
||||||
sender_address = Some(api.get_slatepack_address(send_mask, 0)?.pub_key);
|
sender_address = Some(api.get_slatepack_address(send_mask, 0)?.pub_key);
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
assert_eq!(slate.state, SlateState::Standard1);
|
assert_eq!(slate.state, SlateState::Standard1);
|
||||||
slate = roundtrip_slate(&slate, 4)?;
|
slate = common::roundtrip_slate(&slate, 4)?;
|
||||||
|
|
||||||
let mut recipient_address = None;
|
let mut recipient_address = None;
|
||||||
wallet::controller::owner_single_use(
|
wallet::controller::owner_single_use(
|
||||||
@@ -105,11 +87,7 @@ fn contract_early_proofs_srs_test_impl(test_dir: &'static str) -> Result<(), lib
|
|||||||
PathBuf::from(test_dir),
|
PathBuf::from(test_dir),
|
||||||
|api, m| {
|
|api, m| {
|
||||||
// Receive wallet calls --receive=5
|
// Receive wallet calls --receive=5
|
||||||
let args = &mut ContractSetupArgsAPI {
|
let args = &mut common::contract_setup_args(Some(5_000_000_000));
|
||||||
selection_args: common::contract_selection_args(),
|
|
||||||
net_change: Some(5_000_000_000),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
// Proofs are opt-in; enable and supply the sender address.
|
// Proofs are opt-in; enable and supply the sender address.
|
||||||
args.proof_args.suppress_proof = false;
|
args.proof_args.suppress_proof = false;
|
||||||
args.proof_args.memo = Some(PaymentMemo::new("SRS payment".into())?);
|
args.proof_args.memo = Some(PaymentMemo::new("SRS payment".into())?);
|
||||||
@@ -120,7 +98,7 @@ fn contract_early_proofs_srs_test_impl(test_dir: &'static str) -> Result<(), lib
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
assert_eq!(slate.state, SlateState::Standard2);
|
assert_eq!(slate.state, SlateState::Standard2);
|
||||||
slate = roundtrip_slate(&slate, 5)?;
|
slate = common::roundtrip_slate(&slate, 5)?;
|
||||||
|
|
||||||
// Send wallet finalizes and posts
|
// Send wallet finalizes and posts
|
||||||
//let mut sender_part_sig = None;
|
//let mut sender_part_sig = None;
|
||||||
@@ -129,10 +107,7 @@ fn contract_early_proofs_srs_test_impl(test_dir: &'static str) -> Result<(), lib
|
|||||||
send_mask,
|
send_mask,
|
||||||
PathBuf::from(test_dir),
|
PathBuf::from(test_dir),
|
||||||
|api, m| {
|
|api, m| {
|
||||||
let args = &ContractSetupArgsAPI {
|
let args = &common::contract_setup_args(None);
|
||||||
selection_args: common::contract_selection_args(),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let mut tampered = slate.clone();
|
let mut tampered = slate.clone();
|
||||||
let proof = tampered.payment_proof.as_mut().unwrap();
|
let proof = tampered.payment_proof.as_mut().unwrap();
|
||||||
*proof.timestamp.as_mut().unwrap() += Duration::from_secs(1);
|
*proof.timestamp.as_mut().unwrap() += Duration::from_secs(1);
|
||||||
@@ -143,7 +118,7 @@ fn contract_early_proofs_srs_test_impl(test_dir: &'static str) -> Result<(), lib
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
assert_eq!(slate.state, SlateState::Standard3);
|
assert_eq!(slate.state, SlateState::Standard3);
|
||||||
slate = roundtrip_slate(&slate, 5)?;
|
slate = common::roundtrip_slate(&slate, 5)?;
|
||||||
|
|
||||||
wallet::controller::owner_single_use(
|
wallet::controller::owner_single_use(
|
||||||
send_wallet.clone(),
|
send_wallet.clone(),
|
||||||
@@ -177,11 +152,11 @@ fn contract_early_proofs_srs_test_impl(test_dir: &'static str) -> Result<(), lib
|
|||||||
assert_eq!(tx_log.amount_debited, 0);
|
assert_eq!(tx_log.amount_debited, 0);
|
||||||
assert_eq!(tx_log.num_inputs, 1);
|
assert_eq!(tx_log.num_inputs, 1);
|
||||||
assert_eq!(tx_log.num_outputs, 1);
|
assert_eq!(tx_log.num_outputs, 1);
|
||||||
let expected_fees_paid = Some(my_fee_contribution(1, 1, 1, 2)?);
|
let expected_fees_paid = my_fee_contribution(1, 1, 1, 2)?;
|
||||||
assert_eq!(tx_log.fee, expected_fees_paid);
|
assert_eq!(tx_log.fee, Some(expected_fees_paid));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
wallet_info.amount_currently_spendable,
|
wallet_info.amount_currently_spendable,
|
||||||
4 * 60_000_000_000 + 5_000_000_000 - expected_fees_paid.unwrap().fee() // we expect the balance of 4 mined blocks + 5 Grin - fees paid
|
4 * 60_000_000_000 + 5_000_000_000 - expected_fees_paid.fee() // we expect the balance of 4 mined blocks + 5 Grin - fees paid
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -228,11 +228,11 @@ fn contract_rsr_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
|
|||||||
assert_eq!(tx_log.amount_debited, 0);
|
assert_eq!(tx_log.amount_debited, 0);
|
||||||
assert_eq!(tx_log.num_inputs, 1);
|
assert_eq!(tx_log.num_inputs, 1);
|
||||||
assert_eq!(tx_log.num_outputs, 1);
|
assert_eq!(tx_log.num_outputs, 1);
|
||||||
let expected_fees_paid = Some(my_fee_contribution(1, 1, 1, 2)?);
|
let expected_fees_paid = my_fee_contribution(1, 1, 1, 2)?;
|
||||||
assert_eq!(tx_log.fee, expected_fees_paid);
|
assert_eq!(tx_log.fee, Some(expected_fees_paid));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
wallet_info.amount_currently_spendable,
|
wallet_info.amount_currently_spendable,
|
||||||
4 * 60_000_000_000 + 5_000_000_000 - expected_fees_paid.unwrap().fee() // we expect the balance of 4 mined blocks + 5 Grin - fees paid
|
4 * 60_000_000_000 + 5_000_000_000 - expected_fees_paid.fee() // we expect the balance of 4 mined blocks + 5 Grin - fees paid
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ fn contract_srs_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
|
|||||||
net_change: Some(-5_000_000_000),
|
net_change: Some(-5_000_000_000),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
..Default::default()
|
|
||||||
};
|
};
|
||||||
let progress = common::wallet_progress(api, m)?;
|
let progress = common::wallet_progress(api, m)?;
|
||||||
for count in [0, 3] {
|
for count in [0, 3] {
|
||||||
|
|||||||
@@ -274,15 +274,16 @@ pub mod tests {
|
|||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut coms = vec![];
|
let coms = vec![
|
||||||
coms.push(CommitsV5 {
|
CommitsV5 {
|
||||||
f: OutputFeatures::Coinbase.into(),
|
f: OutputFeatures::Coinbase.into(),
|
||||||
c: Commitment::from_vec([5u8; 1].to_vec()),
|
c: Commitment::from_vec([5u8; 1].to_vec()),
|
||||||
p: None,
|
p: None,
|
||||||
});
|
},
|
||||||
coms.push(com1.clone());
|
com1,
|
||||||
coms.push(com1.clone());
|
com1,
|
||||||
coms.push(com2);
|
com2,
|
||||||
|
];
|
||||||
|
|
||||||
v5.coms = Some(coms);
|
v5.coms = Some(coms);
|
||||||
|
|
||||||
@@ -311,9 +312,9 @@ pub mod tests {
|
|||||||
let psig = DalekSignature::from_bytes(&[11u8; 64]);
|
let psig = DalekSignature::from_bytes(&[11u8; 64]);
|
||||||
slate_internal.payment_proof = Some(PaymentInfo {
|
slate_internal.payment_proof = Some(PaymentInfo {
|
||||||
proof_type: PaymentProofType::Invoice,
|
proof_type: PaymentProofType::Invoice,
|
||||||
sender_address: Some(d_pkey.clone()),
|
sender_address: Some(d_pkey),
|
||||||
receiver_address: d_pkey.clone(),
|
receiver_address: d_pkey,
|
||||||
timestamp: Some(ts.clone()),
|
timestamp: Some(ts),
|
||||||
promise_signature: Some(psig),
|
promise_signature: Some(psig),
|
||||||
memo: Some(pm),
|
memo: Some(pm),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -405,11 +405,7 @@ fn slate_v5_serialize_deserialize() {
|
|||||||
c: Commitment::from_vec([4u8; 1].to_vec()),
|
c: Commitment::from_vec([4u8; 1].to_vec()),
|
||||||
p: Some(RangeProof::zero()),
|
p: Some(RangeProof::zero()),
|
||||||
};
|
};
|
||||||
let mut coms = vec![];
|
let coms = vec![com1, com1, com1, com2];
|
||||||
coms.push(com1.clone());
|
|
||||||
coms.push(com1.clone());
|
|
||||||
coms.push(com1.clone());
|
|
||||||
coms.push(com2);
|
|
||||||
|
|
||||||
v5.coms = Some(coms);
|
v5.coms = Some(coms);
|
||||||
v5.amt = 234324899824;
|
v5.amt = 234324899824;
|
||||||
@@ -421,7 +417,7 @@ fn slate_v5_serialize_deserialize() {
|
|||||||
|
|
||||||
let v4_bin = SlateV5Bin(v5);
|
let v4_bin = SlateV5Bin(v5);
|
||||||
let mut vec = Vec::new();
|
let mut vec = Vec::new();
|
||||||
let _ = grin_ser::serialize_default(&mut vec, &v4_bin).expect("serialization failed");
|
grin_ser::serialize_default(&mut vec, &v4_bin).expect("serialization failed");
|
||||||
let b4_bin_2: SlateV5Bin = grin_ser::deserialize_default(&mut &vec[..]).unwrap();
|
let b4_bin_2: SlateV5Bin = grin_ser::deserialize_default(&mut &vec[..]).unwrap();
|
||||||
let v4_2 = b4_bin_2.0.clone();
|
let v4_2 = b4_bin_2.0.clone();
|
||||||
assert_eq!(v4_1.ver, v4_2.ver);
|
assert_eq!(v4_1.ver, v4_2.ver);
|
||||||
@@ -448,9 +444,9 @@ fn slate_v5_serialize_deserialize() {
|
|||||||
let pm = PaymentMemo::new("payment details".to_string()).unwrap();
|
let pm = PaymentMemo::new("payment details".to_string()).unwrap();
|
||||||
v5.proof = Some(PaymentInfoV5 {
|
v5.proof = Some(PaymentInfoV5 {
|
||||||
ptype: PaymentProofType::Invoice,
|
ptype: PaymentProofType::Invoice,
|
||||||
raddr: d_pkey.clone(),
|
raddr: d_pkey,
|
||||||
saddr: Some(d_pkey.clone()),
|
saddr: Some(d_pkey),
|
||||||
ts: Some(ts.clone()),
|
ts: Some(ts),
|
||||||
psig: None,
|
psig: None,
|
||||||
memo: Some(pm),
|
memo: Some(pm),
|
||||||
});
|
});
|
||||||
@@ -458,7 +454,7 @@ fn slate_v5_serialize_deserialize() {
|
|||||||
let v5_1 = v5.clone();
|
let v5_1 = v5.clone();
|
||||||
let v5_bin = SlateV5Bin(v5);
|
let v5_bin = SlateV5Bin(v5);
|
||||||
let mut vec = Vec::new();
|
let mut vec = Vec::new();
|
||||||
let _ = grin_ser::serialize_default(&mut vec, &v5_bin).expect("serialization failed");
|
grin_ser::serialize_default(&mut vec, &v5_bin).expect("serialization failed");
|
||||||
let b4_bin_2: SlateV5Bin = grin_ser::deserialize_default(&mut &vec[..]).unwrap();
|
let b4_bin_2: SlateV5Bin = grin_ser::deserialize_default(&mut &vec[..]).unwrap();
|
||||||
let v5_2 = b4_bin_2.0.clone();
|
let v5_2 = b4_bin_2.0.clone();
|
||||||
assert_eq!(v5_1.ver, v5_2.ver);
|
assert_eq!(v5_1.ver, v5_2.ver);
|
||||||
|
|||||||
Reference in New Issue
Block a user