Skip to content

Commit

Permalink
Merge pull request zingolabs#734 from dorianvp/e2e_parse_address
Browse files Browse the repository at this point in the history
E2E: Add parse for invalid address
  • Loading branch information
juanky201271 authored Oct 16, 2024
2 parents f1441cb + b9fb2ee commit 00f05b8
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 32 deletions.
1 change: 1 addition & 0 deletions .github/workflows/android-ubuntu-e2e-test-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ jobs:
fail-fast: false
matrix:
test: [
"parse_invalid_address",
"tex_send_address",
"reload_while_tx_pending",
"change_custom_server",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ios-e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
fail-fast: false
matrix:
test: [
"parse_invalid_address",
"tex_send_address",
"reload_while_tx_pending",
"change_custom_server",
Expand Down
9 changes: 7 additions & 2 deletions components/Components/ErrorText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ import { ThemeType } from '../../app/types/ThemeType';
type ErrorTextProps = {
style?: TextStyle;
children: string;
testID?: string;
};

const ErrorText: React.FunctionComponent<ErrorTextProps> = ({ style, children }) => {
const ErrorText: React.FunctionComponent<ErrorTextProps> = ({ style, children, testID }) => {
const { colors } = useTheme() as unknown as ThemeType;

return <Text style={{ color: colors.primary, ...style }}>{children}</Text>;
return (
<Text testID={testID} style={{ color: colors.primary, ...style }}>
{children}
</Text>
);
};

export default ErrorText;
4 changes: 3 additions & 1 deletion components/Send/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,9 @@ const Send: React.FunctionComponent<SendProps> = ({
<FontAwesomeIcon icon={faCheck} color={colors.primary} />
</View>
)}
{validAddress === -1 && <ErrorText>{translate('send.invalidaddress') as string}</ErrorText>}
{validAddress === -1 && (
<ErrorText testID="send.address.error">{translate('send.invalidaddress') as string}</ErrorText>
)}
</View>
<View
style={{
Expand Down
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.', () => {
it('loads a wallet', async () => await loadRecipientWallet());
it('does not parse an incorrect address', async () => {
await waitFor(element(by.id('vt-1')))
.toExist()
.withTimeout(30000);
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);
});
});
8 changes: 4 additions & 4 deletions e2e/send.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ describe('Renders wallet data correctly.', () => {
await element(by.id('send.memo-field')).replaceText('1\n2\n3\n4\n5\n6\n7\n8');
await element(by.id('send.scroll-view')).scrollTo('bottom');

await waitFor(element(by.id('send.button'))).toBeVisible().withTimeout(sync_timeout);
await waitFor(element(by.id('send.button')))
.toBeVisible()
.withTimeout(sync_timeout);
await element(by.id('send.button')).tap();

await expect(element(by.id('send.confirm.scroll-view'))).toExist();
Expand All @@ -38,8 +40,6 @@ describe('Renders wallet data correctly.', () => {
//await expect(memo).toHaveText(
// '1\n2\n3\n4\n5\n6\n7\n8\nReply to: \nuregtest1zkuzfv5m3yhv2j4fmvq5rjurkxenxyq8r7h4daun2zkznrjaa8ra8asgdm8wwgwjvlwwrxx7347r8w0ee6dqyw4rufw4wg9djwcr6frzkezmdw6dud3wsm99eany5r8wgsctlxquu009nzd6hsme2tcsk0v3sgjvxa70er7h27z5epr67p5q767s2z5gt88paru56mxpm6pwz0cu35m',
//);
await expect(memo).toHaveText(
'1\n2\n3\n4\n5\n6\n7\n8',
);
await expect(memo).toHaveText('1\n2\n3\n4\n5\n6\n7\n8');
});
});
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 00f05b8

Please sign in to comment.