Slatepack Workflow (#423)

* debugging tor sends

* use fixed yeast version of hyper-socks2

* send command working according to slatepack

* changes to handling proof address

* modifications of recieve command to work with slatepack and to attempt to return to sender via TOR

* finalize command tested

* attempting to add invoice processing

* fixes to tests, propagation of test mode where needed

* modify return values of api functions that can send as sync

* cleanup, testing and post_tx function

* revert changes to API, many test fixes

* deprecate http on the command-line warning
This commit is contained in:
Yeastplume
2020-06-03 08:39:23 +01:00
committed by GitHub
parent 4fe6bf1c23
commit 60ab3728ab
28 changed files with 1425 additions and 738 deletions
+159 -115
View File
@@ -48,7 +48,7 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
let app = App::from_yaml(yml);
// wallet init
let arg_vec = vec!["grin-wallet", "-p", "password", "init", "-h"];
let arg_vec = vec!["grin-wallet", "-p", "password1", "init", "-h"];
// should create new wallet file
let client1 = LocalWalletClient::new("wallet1", wallet_proxy.tx.clone());
execute_command(&app, test_dir, "wallet1", &client1, arg_vec.clone())?;
@@ -64,7 +64,7 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
let (wallet1, mask1_i) = instantiate_wallet(
wallet_config1.clone(),
client1.clone(),
"password",
"password1",
"default",
)?;
wallet_proxy.add_wallet(
@@ -75,6 +75,7 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
);
// Create wallet 2
let arg_vec = vec!["grin-wallet", "-p", "password2", "init", "-h"];
let client2 = LocalWalletClient::new("wallet2", wallet_proxy.tx.clone());
execute_command(&app, test_dir, "wallet2", &client2, arg_vec.clone())?;
@@ -83,7 +84,7 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
let (wallet2, mask2_i) = instantiate_wallet(
wallet_config2.clone(),
client2.clone(),
"password",
"password2",
"default",
)?;
wallet_proxy.add_wallet(
@@ -101,13 +102,13 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
});
// Create some accounts in wallet 1
let arg_vec = vec!["grin-wallet", "-p", "password", "account", "-c", "mining"];
let arg_vec = vec!["grin-wallet", "-p", "password1", "account", "-c", "mining"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password1",
"account",
"-c",
"account_1",
@@ -118,7 +119,7 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password2",
"account",
"-c",
"account_1",
@@ -130,7 +131,7 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password2",
"account",
"-c",
"account_2",
@@ -138,18 +139,18 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
execute_command(&app, test_dir, "wallet2", &client2, arg_vec)?;
// let's see those accounts
let arg_vec = vec!["grin-wallet", "-p", "password", "account"];
execute_command(&app, test_dir, "wallet2", &client2, arg_vec)?;
let arg_vec = vec!["grin-wallet", "-p", "password1", "account"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
// let's see those accounts
let arg_vec = vec!["grin-wallet", "-p", "password", "account"];
let arg_vec = vec!["grin-wallet", "-p", "password2", "account"];
execute_command(&app, test_dir, "wallet2", &client2, arg_vec)?;
// Mine a bit into wallet 1 so we have something to send
// (TODO: Be able to stop listeners so we can test this better)
let wallet_config1 = config1.clone().members.unwrap().wallet;
let (wallet1, mask1_i) =
instantiate_wallet(wallet_config1, client1.clone(), "password", "default")?;
instantiate_wallet(wallet_config1, client1.clone(), "password1", "default")?;
let mask1 = (&mask1_i).as_ref();
grin_wallet_controller::controller::owner_single_use(
Some(wallet1.clone()),
@@ -166,31 +167,32 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, bh as usize, false);
// Update info and check
let arg_vec = vec!["grin-wallet", "-p", "password", "-a", "mining", "info"];
let arg_vec = vec!["grin-wallet", "-p", "password1", "-a", "mining", "info"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
// try a file exchange
let file_name = format!("{}/tx1.part_tx", test_dir);
let response_file_name = format!("{}/tx1.part_tx.response", test_dir);
let file_name = format!(
"{}/wallet1/slatepack/0436430c-2b02-624c-2032-570501212b00.S1.slatepack",
test_dir
);
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password1",
"-a",
"mining",
"send",
"-m",
"file",
"-d",
&file_name,
"10",
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec!["grin-wallet", "-a", "mining", "-p", "password1", "txs"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password2",
"-a",
"account_1",
"receive",
@@ -202,15 +204,20 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
// shouldn't be allowed to receive twice
assert!(execute_command(&app, test_dir, "wallet2", &client2, arg_vec).is_err());
let file_name = format!(
"{}/wallet2/slatepack/0436430c-2b02-624c-2032-570501212b00.S2.slatepack",
test_dir
);
let arg_vec = vec![
"grin-wallet",
"-a",
"mining",
"-p",
"password",
"password1",
"finalize",
"-i",
&response_file_name,
&file_name,
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
bh += 1;
@@ -219,7 +226,7 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
let (wallet1, mask1_i) = instantiate_wallet(
wallet_config1.clone(),
client1.clone(),
"password",
"password1",
"default",
)?;
let mask1 = (&mask1_i).as_ref();
@@ -245,10 +252,10 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
bh += 10;
// update info for each
let arg_vec = vec!["grin-wallet", "-p", "password", "-a", "mining", "info"];
let arg_vec = vec!["grin-wallet", "-p", "password1", "-a", "mining", "info"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec!["grin-wallet", "-p", "password", "-a", "account_1", "info"];
let arg_vec = vec!["grin-wallet", "-p", "password2", "-a", "account_1", "info"];
execute_command(&app, test_dir, "wallet2", &client1, arg_vec)?;
// check results in wallet 2
@@ -256,7 +263,7 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
let (wallet2, mask2_i) = instantiate_wallet(
wallet_config2.clone(),
client2.clone(),
"password",
"password2",
"default",
)?;
let mask2 = (&mask2_i).as_ref();
@@ -274,28 +281,113 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
},
)?;
// Self-send to same account, using smallest strategy
// Send encrypted from wallet 1 to wallet 2
// output wallet 2's address for test creation purposes,
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password2",
"-a",
"account_1",
"address",
];
execute_command(&app, test_dir, "wallet2", &client2, arg_vec)?;
// Send encrypted to wallet 2
let arg_vec = vec![
"grin-wallet",
"-p",
"password1",
"-a",
"mining",
"send",
"-m",
"file",
"-d",
"slatepack1ak8aaxpjg6ct5uje4lgzvjp65l0nrmgxndp5xjy74sumzp7wasyspux2f5",
"10",
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let file_name = format!(
"{}/wallet1/slatepack/0436430c-2b02-624c-2032-570501212b01.S1.slatepack",
test_dir
);
let arg_vec = vec![
"grin-wallet",
"-p",
"password2",
"-a",
"account_1",
"receive",
"-i",
&file_name,
];
execute_command(&app, test_dir, "wallet2", &client2, arg_vec.clone())?;
let file_name = format!(
"{}/wallet2/slatepack/0436430c-2b02-624c-2032-570501212b01.S2.slatepack",
test_dir
);
let arg_vec = vec![
"grin-wallet",
"-a",
"mining",
"-p",
"password1",
"finalize",
"-i",
&file_name,
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
bh += 1;
// Check our transaction log, should have bh entries
let wallet_config1 = config1.clone().members.unwrap().wallet;
let (wallet1, mask1_i) = instantiate_wallet(
wallet_config1.clone(),
client1.clone(),
"password1",
"default",
)?;
let mask1 = (&mask1_i).as_ref();
grin_wallet_controller::controller::owner_single_use(
Some(wallet1.clone()),
mask1,
None,
|api, m| {
api.set_active_account(m, "mining")?;
let (refreshed, txs) = api.retrieve_txs(m, true, None, None)?;
assert!(refreshed);
assert_eq!(txs.len(), bh as usize);
Ok(())
},
)?;
// Send to self
let arg_vec = vec![
"grin-wallet",
"-p",
"password1",
"-a",
"mining",
"send",
"-o",
"3",
"-s",
"smallest",
"10",
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let file_name = format!(
"{}/wallet1/slatepack/0436430c-2b02-624c-2032-570501212b02.S1.slatepack",
test_dir
);
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password1",
"-a",
"mining",
"receive",
@@ -304,25 +396,30 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec.clone())?;
let file_name = format!(
"{}/wallet1/slatepack/0436430c-2b02-624c-2032-570501212b02.S2.slatepack",
test_dir
);
let arg_vec = vec![
"grin-wallet",
"-a",
"mining",
"-p",
"password",
"password1",
"finalize",
"-i",
&response_file_name,
&file_name,
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
bh += 1;
// Check our transaction log, should have bh entries + one for the self receive
// Check our transaction log, should have bh entries + 1 for self-seld
let wallet_config1 = config1.clone().members.unwrap().wallet;
let (wallet1, mask1_i) = instantiate_wallet(
wallet_config1.clone(),
client1.clone(),
"password",
"password1",
"default",
)?;
let mask1 = (&mask1_i).as_ref();
@@ -340,111 +437,55 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
},
)?;
// Try using the self-send method, splitting up outputs for the fun of it
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"-a",
"mining",
"send",
"-m",
"self",
"-d",
"mining",
"-o",
"3",
"-s",
"smallest",
"10",
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
bh += 1;
// Check our transaction log, should have bh entries + 2 for the self receives
let wallet_config1 = config1.clone().members.unwrap().wallet;
let (wallet1, mask1_i) = instantiate_wallet(
wallet_config1.clone(),
client1.clone(),
"password",
"default",
)?;
let mask1 = (&mask1_i).as_ref();
grin_wallet_controller::controller::owner_single_use(
Some(wallet1.clone()),
mask1,
None,
|api, m| {
api.set_active_account(m, "mining")?;
let (refreshed, txs) = api.retrieve_txs(m, true, None, None)?;
assert!(refreshed);
assert_eq!(txs.len(), bh as usize + 2);
Ok(())
},
)?;
// Another file exchange, don't send, but unlock with repair command
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password1",
"-a",
"mining",
"send",
"-m",
"file",
"-d",
&file_name,
"10",
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec!["grin-wallet", "-p", "password", "scan", "-d"];
let arg_vec = vec!["grin-wallet", "-p", "password1", "scan", "-d"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
// Another file exchange, cancel this time
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password1",
"-a",
"mining",
"send",
"-m",
"file",
"-d",
&file_name,
"10",
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec!["grin-wallet", "-a", "mining", "-p", "password1", "txs"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password1",
"-a",
"mining",
"cancel",
"-i",
"26",
"25",
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
// issue an invoice tx, wallet 2
let file_name = format!("{}/invoice.slate", test_dir);
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"invoice",
"-d",
&file_name,
"-b",
"65",
];
let arg_vec = vec!["grin-wallet", "-p", "password2", "invoice", "65"];
execute_command(&app, test_dir, "wallet2", &client2, arg_vec)?;
let output_file_name = format!("{}/invoice.slate.paid", test_dir);
let file_name = format!(
"{}/wallet2/slatepack/0436430c-2b02-624c-2032-570501212b05.I1.slatepack",
test_dir
);
// now pay the invoice tx, wallet 1
let arg_vec = vec![
@@ -452,23 +493,26 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
"-a",
"mining",
"-p",
"password",
"password1",
"pay",
"-i",
&file_name,
"-d",
&output_file_name,
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let file_name = format!(
"{}/wallet1/slatepack/0436430c-2b02-624c-2032-570501212b05.I2.slatepack",
test_dir
);
// and finalize, wallet 2
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password2",
"finalize",
"-i",
&output_file_name,
&file_name,
];
execute_command(&app, test_dir, "wallet2", &client2, arg_vec)?;
@@ -477,14 +521,14 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
//bh += 5;
// txs and outputs (mostly spit out for a visual in test logs)
let arg_vec = vec!["grin-wallet", "-p", "password", "-a", "mining", "txs"];
let arg_vec = vec!["grin-wallet", "-p", "password1", "-a", "mining", "txs"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
// message output (mostly spit out for a visual in test logs)
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"password1",
"-a",
"mining",
"txs",
@@ -494,13 +538,13 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
// txs and outputs (mostly spit out for a visual in test logs)
let arg_vec = vec!["grin-wallet", "-p", "password", "-a", "mining", "outputs"];
let arg_vec = vec!["grin-wallet", "-p", "password1", "-a", "mining", "outputs"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec!["grin-wallet", "-p", "password", "txs"];
let arg_vec = vec!["grin-wallet", "-p", "password2", "txs"];
execute_command(&app, test_dir, "wallet2", &client2, arg_vec)?;
let arg_vec = vec!["grin-wallet", "-p", "password", "outputs"];
let arg_vec = vec!["grin-wallet", "-p", "password2", "outputs"];
execute_command(&app, test_dir, "wallet2", &client2, arg_vec)?;
// get tx output via -tx parameter
@@ -518,7 +562,7 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
Ok(())
},
)?;
let arg_vec = vec!["grin-wallet", "-p", "password", "txs", "-t", &tx_id[..]];
let arg_vec = vec!["grin-wallet", "-p", "password2", "txs", "-t", &tx_id[..]];
execute_command(&app, test_dir, "wallet2", &client2, arg_vec)?;
// let logging finish