Skip to content

Commit

Permalink
test: move invalid address to another test file
Browse files Browse the repository at this point in the history
  • Loading branch information
dorianvp committed Oct 16, 2024
1 parent a0761d3 commit ca99a7d
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 37 deletions.
21 changes: 21 additions & 0 deletions e2e/parse_invalid_address.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { log, device, by, element, expect } = require('detox');

import { loadRecipientWallet } from './e2e-utils/loadRecipientWallet.js';

const sleep = ms => new Promise(r => setTimeout(r, ms));

describe('Renders wallet data correctly.', () => {
beforeEach(async () => {
await device.launchApp({
newInstance: true,
});
});
it('loads a wallet', async () => await loadRecipientWallet());
it('does not parse an incorrect address', async () => {
await element(by.text('SEND')).tap();
await element(by.id('send.addressplaceholder')).replaceText('thisisaninvalidaddress');
await waitFor(element(by.id('send.address.error')))
.toExist()
.withTimeout(5000);
});
});
12 changes: 0 additions & 12 deletions e2e/send.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ const sleep = ms => new Promise(r => setTimeout(r, ms));

describe('Renders wallet data correctly.', () => {
// i just pulled this seed out of thin air
beforeEach(async () => {
await device.launchApp({
newInstance: true,
});
});
it('loads a wallet', async () => await loadRecipientWallet());
it('adds return address to the memo if that option is selected, and correctly renders confirm screen', async () => {
await element(by.text('SEND')).tap();
Expand Down Expand Up @@ -47,11 +42,4 @@ describe('Renders wallet data correctly.', () => {
//);
await expect(memo).toHaveText('1\n2\n3\n4\n5\n6\n7\n8');
});
it('does not parse an incorrect address', async () => {
await element(by.text('SEND')).tap();
await element(by.id('send.addressplaceholder')).replaceText('thisisaninvalidaddress');
await waitFor(element(by.id('send.address.error')))
.toExist()
.withTimeout(5000);
});
});
92 changes: 67 additions & 25 deletions rust/android/tests/e2e_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(not(feature = "regchest"))]
use zingolib::testutils::{scenarios};
use zingolib::testutils::scenarios;

use darkside_tests::utils::{prepare_darksidewalletd, DarksideHandler};

Expand All @@ -24,12 +24,42 @@ async fn tex_send_address(abi: &str) {
};

#[cfg(not(feature = "ci"))]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test(abi, "tex_send_address");
let (exit_code, output, error) = zingomobile_utils::android_e2e_test(abi, "tex_send_address");
#[cfg(feature = "ci")]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test_ci(abi, "tex_send_address");


#[cfg(feature = "regchest")]
match regchest_utils::close(&docker).await {
Ok(_) => (),
Err(e) => panic!("Failed to close regchest docker container: {:?}", e),
}

println!("Exit Code: {}", exit_code);
println!("Output: {}", output);
println!("Error: {}", error);

assert_eq!(exit_code, 0);
}

async fn parse_invalid_address(abi: &str) {
#[cfg(not(feature = "regchest"))]
let (_regtest_manager, _child_process_handler) =
scenarios::funded_orchard_mobileclient(1_000_000).await;
#[cfg(feature = "regchest")]
let docker =
match regchest_utils::launch(UNIX_SOCKET, Some("funded_orchard_mobileclient")).await {
Ok(d) => d,
Err(e) => panic!("Failed to launch regchest docker container: {:?}", e),
};

#[cfg(not(feature = "ci"))]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test(abi, "parse_invalid_address");
#[cfg(feature = "ci")]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test_ci(abi, "parse_invalid_address");

#[cfg(feature = "regchest")]
match regchest_utils::close(&docker).await {
Ok(_) => (),
Expand Down Expand Up @@ -60,7 +90,7 @@ async fn reload_while_tx_pending(abi: &str) {
#[cfg(feature = "ci")]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test_ci(abi, "reload_while_tx_pending");

#[cfg(feature = "regchest")]
match regchest_utils::close(&docker).await {
Ok(_) => (),
Expand Down Expand Up @@ -106,13 +136,13 @@ async fn change_custom_regtest_server(abi: &str) {
#[cfg(feature = "ci")]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test_ci(abi, "change_custom_regtest_server");

#[cfg(feature = "regchest")]
match regchest_utils::close(&docker).await {
Ok(_) => (),
Err(e) => panic!("Failed to close regchest docker container: {:?}", e),
}

println!("Exit Code: {}", exit_code);
println!("Output: {}", output);
println!("Error: {}", error);
Expand Down Expand Up @@ -152,11 +182,9 @@ async fn change_server_from_list(abi: &str) {

async fn new_wallet(abi: &str) {
#[cfg(not(feature = "ci"))]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test(abi, "new_wallet");
let (exit_code, output, error) = zingomobile_utils::android_e2e_test(abi, "new_wallet");
#[cfg(feature = "ci")]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test_ci(abi, "new_wallet");
let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "new_wallet");

println!("Exit Code: {}", exit_code);
println!("Output: {}", output);
Expand All @@ -167,11 +195,9 @@ async fn new_wallet(abi: &str) {

async fn screen_awake(abi: &str) {
#[cfg(not(feature = "ci"))]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test(abi, "screen_awake");
let (exit_code, output, error) = zingomobile_utils::android_e2e_test(abi, "screen_awake");
#[cfg(feature = "ci")]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test_ci(abi, "screen_awake");
let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "screen_awake");

println!("Exit Code: {}", exit_code);
println!("Output: {}", output);
Expand All @@ -192,11 +218,9 @@ async fn send(abi: &str) {
};

#[cfg(not(feature = "ci"))]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test(abi, "send");
let (exit_code, output, error) = zingomobile_utils::android_e2e_test(abi, "send");
#[cfg(feature = "ci")]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test_ci(abi, "send");
let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "send");

#[cfg(feature = "regchest")]
match regchest_utils::close(&docker).await {
Expand All @@ -213,11 +237,9 @@ async fn send(abi: &str) {

async fn sync_report(abi: &str) {
#[cfg(not(feature = "ci"))]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test(abi, "sync_report");
let (exit_code, output, error) = zingomobile_utils::android_e2e_test(abi, "sync_report");
#[cfg(feature = "ci")]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test_ci(abi, "sync_report");
let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "sync_report");

println!("Exit Code: {}", exit_code);
println!("Output: {}", output);
Expand Down Expand Up @@ -259,7 +281,7 @@ async fn darkside_simple_sync(abi: &str) {
#[cfg(feature = "ci")]
let (exit_code, output, error) =
zingomobile_utils::android_e2e_test_ci(abi, "darkside_simple_sync");

println!("Exit Code: {}", exit_code);
println!("Output: {}", output);
println!("Error: {}", error);
Expand All @@ -276,6 +298,11 @@ mod e2e {
crate::tex_send_address(ABI).await;
}

#[tokio::test]
async fn parse_invalid_address() {
crate::parse_invalid_address(ABI).await;
}

#[tokio::test]
async fn reload_while_tx_pending() {
crate::reload_while_tx_pending(ABI).await;
Expand Down Expand Up @@ -342,6 +369,11 @@ mod e2e {
crate::tex_send_address(ABI).await;
}

#[tokio::test]
async fn parse_invalid_address() {
crate::parse_invalid_address(ABI).await;
}

#[tokio::test]
async fn reload_while_tx_pending() {
crate::reload_while_tx_pending(ABI).await;
Expand Down Expand Up @@ -408,6 +440,11 @@ mod e2e {
crate::tex_send_address(ABI).await;
}

#[tokio::test]
async fn parse_invalid_address() {
crate::parse_invalid_address(ABI).await;
}

#[tokio::test]
async fn reload_while_tx_pending() {
crate::reload_while_tx_pending(ABI).await;
Expand Down Expand Up @@ -474,6 +511,11 @@ mod e2e {
crate::tex_send_address(ABI).await;
}

#[tokio::test]
async fn parse_invalid_address() {
crate::parse_invalid_address(ABI).await;
}

#[tokio::test]
async fn reload_while_tx_pending() {
crate::reload_while_tx_pending(ABI).await;
Expand Down Expand Up @@ -531,4 +573,4 @@ mod e2e {
}
}
}
}
}

0 comments on commit ca99a7d

Please sign in to comment.