Skip to content

Commit

Permalink
trying to implement mine to t-addr
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar-Pepper committed Oct 12, 2023
1 parent b72a35d commit 2fd151b
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 19 deletions.
7 changes: 5 additions & 2 deletions zingo-testutils/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ pub mod seeds {
pub const CHIMNEY_BETTER_SEED: &str = "chimney better bulb horror rebuild whisper improve intact letter giraffe brave rib appear bulk aim burst snap salt hill sad merge tennis phrase raise";
}

pub const REGSAP_ADDR_FROM_ABANDONART: &str =
// faucet addresses
pub const REG_O_ADDR_FROM_ABANDONART: &str = "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8";
pub const REG_Z_ADDR_FROM_ABANDONART: &str =
"zregtestsapling1fmq2ufux3gm0v8qf7x585wj56le4wjfsqsj27zprjghntrerntggg507hxh2ydcdkn7sx8kya7p";
pub const REG_T_ADDR_FROM_ABANDONART: &str = "tmFLszfkjgim4zoUMAXpuohnFBAKy99rr2i";

// Burn-to regtest address generated by `zcash-cli getnewaddress`
pub const EXT_TADDR: &str = "tmJTBtMwPU96XteSiP89xDz1WARNgRddEHq";
Expand Down Expand Up @@ -104,7 +107,7 @@ minetolocalwallet=0 # This is set to false so that we can mine to a wallet, othe
let regtest_network = zingoconfig::RegtestNetwork::new(1, 2, 3, 4, 5, 6);
assert_eq!(
funded(
super::super::REGSAP_ADDR_FROM_ABANDONART,
super::super::REG_Z_ADDR_FROM_ABANDONART,
"1234",
&regtest_network
),
Expand Down
65 changes: 52 additions & 13 deletions zingo-testutils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ async fn get_synced_wallet_height(client: &LightClient) -> Result<u32, String> {
fn poll_server_height(manager: &RegtestManager) -> JsonValue {
let temp_tips = manager.get_chain_tip().unwrap().stdout;
let tips = json::parse(&String::from_utf8_lossy(&temp_tips)).unwrap();
tips[0]["height"].clone()
// dbg!(tips[0]["height"].clone())
// tips[0]["height"].clone()
dbg!(tips[0]["height"].clone())
}
// This function _DOES NOT SYNC THE CLIENT/WALLET_.
pub async fn increase_server_height(manager: &RegtestManager, n: u32) {
Expand Down Expand Up @@ -239,13 +239,16 @@ pub mod scenarios {
use self::setup::ClientBuilder;
use super::regtest::{ChildProcessHandler, RegtestManager};
use crate::{
data::{self, seeds::HOSPITAL_MUSEUM_SEED, REGSAP_ADDR_FROM_ABANDONART},
data::{
self, seeds::HOSPITAL_MUSEUM_SEED, REG_T_ADDR_FROM_ABANDONART,
REG_Z_ADDR_FROM_ABANDONART,
},
increase_height_and_wait_for_client, BASE_HEIGHT,
};
use zingolib::{get_base_address, lightclient::LightClient, wallet::Pool};

pub mod setup {
use crate::data::REGSAP_ADDR_FROM_ABANDONART;
use crate::data::REG_Z_ADDR_FROM_ABANDONART;
use crate::BASE_HEIGHT;

use super::super::regtest::get_regtest_dir;
Expand Down Expand Up @@ -345,7 +348,7 @@ pub mod scenarios {
.expect("copy operation into fresh dir from known dir to succeed");
dbg!(&sb.test_env.regtest_manager.zcashd_config);
sb.configure_scenario(
Some(REGSAP_ADDR_FROM_ABANDONART.to_string()),
Some(REG_Z_ADDR_FROM_ABANDONART.to_string()),
regtest_network,
);
sb.launch_scenario(false).await;
Expand Down Expand Up @@ -550,7 +553,7 @@ pub mod scenarios {
regtest_network: zingoconfig::RegtestNetwork,
) -> (RegtestManager, ChildProcessHandler, ClientBuilder) {
let sb = setup::ScenarioBuilder::build_configure_launch(
Some(REGSAP_ADDR_FROM_ABANDONART.to_string()),
Some(REG_Z_ADDR_FROM_ABANDONART.to_string()),
None,
None,
&regtest_network,
Expand All @@ -576,7 +579,7 @@ pub mod scenarios {
regtest_network: zingoconfig::RegtestNetwork,
) -> (RegtestManager, ChildProcessHandler, LightClient) {
let mut sb = setup::ScenarioBuilder::build_configure_launch(
Some(REGSAP_ADDR_FROM_ABANDONART.to_string()),
Some(REG_Z_ADDR_FROM_ABANDONART.to_string()),
None,
None,
&regtest_network,
Expand Down Expand Up @@ -644,7 +647,45 @@ pub mod scenarios {
LightClient,
) {
let mut sb = setup::ScenarioBuilder::build_configure_launch(
Some(REGSAP_ADDR_FROM_ABANDONART.to_string()),
Some(REG_Z_ADDR_FROM_ABANDONART.to_string()),
None,
None,
&regtest_network,
)
.await;
let faucet = sb
.client_builder
.build_new_faucet(0, false, regtest_network.clone())
.await;
faucet.do_sync(false).await.unwrap();

let recipient = sb
.client_builder
.build_newseed_client(
HOSPITAL_MUSEUM_SEED.to_string(),
BASE_HEIGHT as u64,
false,
regtest_network,
)
.await;
(
sb.regtest_manager,
sb.child_process_handler.unwrap(),
faucet,
recipient,
)
}

pub async fn two_wallet_one_miner_fund_transparent(
regtest_network: zingoconfig::RegtestNetwork,
) -> (
RegtestManager,
ChildProcessHandler,
LightClient,
LightClient,
) {
let mut sb = setup::ScenarioBuilder::build_configure_launch(
Some(REG_T_ADDR_FROM_ABANDONART.to_string()),
None,
None,
&regtest_network,
Expand Down Expand Up @@ -707,7 +748,7 @@ pub mod scenarios {
pub async fn funded_orchard_mobileclient(value: u64) -> (RegtestManager, ChildProcessHandler) {
let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active();
let mut scenario_builder = setup::ScenarioBuilder::build_configure_launch(
Some(REGSAP_ADDR_FROM_ABANDONART.to_string()),
Some(REG_Z_ADDR_FROM_ABANDONART.to_string()),
None,
Some(20_000),
&regtest_network,
Expand Down Expand Up @@ -745,7 +786,7 @@ pub mod scenarios {
) -> (RegtestManager, ChildProcessHandler) {
let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active();
let mut scenario_builder = setup::ScenarioBuilder::build_configure_launch(
Some(REGSAP_ADDR_FROM_ABANDONART.to_string()),
Some(REG_Z_ADDR_FROM_ABANDONART.to_string()),
None,
Some(20_000),
&regtest_network,
Expand Down Expand Up @@ -810,7 +851,7 @@ pub mod scenarios {
) -> (RegtestManager, ChildProcessHandler) {
let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active();
let mut scenario_builder = setup::ScenarioBuilder::build_configure_launch(
Some(REGSAP_ADDR_FROM_ABANDONART.to_string()),
Some(REG_Z_ADDR_FROM_ABANDONART.to_string()),
None,
Some(20_000),
&regtest_network,
Expand Down Expand Up @@ -952,7 +993,6 @@ pub mod scenarios {
let mut sb =
setup::ScenarioBuilder::new_load_1153_saplingcb_regtest_chain(&regtest_network)
.await;
//(Some(REGSAP_ADDR_FROM_ABANDONART.to_string()), None);
let faucet = sb
.client_builder
.build_new_faucet(0, false, regtest_network.clone())
Expand All @@ -979,7 +1019,6 @@ pub mod scenarios {
let mut sb =
setup::ScenarioBuilder::new_load_1153_saplingcb_regtest_chain(&regtest_network)
.await;
//(Some(REGSAP_ADDR_FROM_ABANDONART.to_string()), None);
let faucet = sb
.client_builder
.build_new_faucet(0, false, regtest_network.clone())
Expand Down
59 changes: 55 additions & 4 deletions zingocli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3359,6 +3359,7 @@ async fn sync_all_epochs_from_sapling() {
}

// test fails to exit when syncing pre-sapling
// possible issue with dropping child process handler?
#[ignore]
#[tokio::test]
async fn sync_all_epochs() {
Expand All @@ -3371,13 +3372,63 @@ async fn sync_all_epochs() {

#[tokio::test]
async fn send_pre_orchard_funds() {
let regtest_network = RegtestNetwork::new(1, 1, 3, 5, 7, 9);
let (regtest_manager, _cph, faucet, recipient) =
let regtest_network = RegtestNetwork::new(1, 1, 1, 1, 7, 9);
let (regtest_manager, _cph, faucet, _recipient) =
scenarios::two_wallet_one_miner_fund(regtest_network).await;
println!("generate blocks and poll");
increase_height_and_wait_for_client(&regtest_manager, &faucet, 7)
println!(
"{}",
serde_json::to_string_pretty(&faucet.do_balance().await).unwrap()
);
increase_height_and_wait_for_client(&regtest_manager, &faucet, 1)
.await
.unwrap();
println!(
"{}",
serde_json::to_string_pretty(&faucet.do_balance().await).unwrap()
);
increase_height_and_wait_for_client(&regtest_manager, &faucet, 1)
.await
.unwrap();
println!(
"{}",
serde_json::to_string_pretty(&faucet.do_balance().await).unwrap()
);
increase_height_and_wait_for_client(&regtest_manager, &faucet, 1)
.await
.unwrap();
println!(
"{}",
serde_json::to_string_pretty(&faucet.do_balance().await).unwrap()
);
increase_height_and_wait_for_client(&regtest_manager, &faucet, 1)
.await
.unwrap();
println!(
"{}",
serde_json::to_string_pretty(&faucet.do_balance().await).unwrap()
);
increase_height_and_wait_for_client(&regtest_manager, &faucet, 1)
.await
.unwrap();
println!(
"{}",
serde_json::to_string_pretty(&faucet.do_balance().await).unwrap()
);
increase_height_and_wait_for_client(&regtest_manager, &faucet, 1)
.await
.unwrap();
println!(
"{}",
serde_json::to_string_pretty(&faucet.do_balance().await).unwrap()
);
increase_height_and_wait_for_client(&regtest_manager, &faucet, 1)
.await
.unwrap();
println!(
"{}",
serde_json::to_string_pretty(&faucet.do_balance().await).unwrap()
);
// increase_height_and_wait_for_client(&regtest_manager, &faucet, 7)
// faucet
// .do_send(vec![(
// &get_base_address!(recipient, "unified"),
Expand Down

0 comments on commit 2fd151b

Please sign in to comment.