Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions __tests__/SyncReport.model.unit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { BackgroundType } from '@app/AppState';
import { RPCSyncStatusType } from '@app/walletBackend/types/RPCSyncStatusType';
import { RPCSyncScanRangePriorityStatusEnum as Priority } from '@app/walletBackend/enums/RPCSyncScanRangePriorityStatusEnum';
import {
backgroundOutcome,
chainTip,
heights,
MAP_CELLS,
Expand Down Expand Up @@ -96,3 +98,53 @@ test('Tests that the chain tip is the birthday plus the reported span when the s
test('Tests that the chain tip is the server height when the status has no span.', () => {
expect(chainTip({}, BIRTHDAY, TIP)).toBe(TIP);
});

const background = (
message: string,
dateEnd: number,
error?: string,
): BackgroundType => ({
batches: 0,
message,
date: 1_700_000_000,
dateEnd,
error,
});

test('Tests that the background sync finished when the task wrote its end time with no error.', () => {
expect(backgroundOutcome(background('Finished OK.', 1_700_000_100))).toBe(
'ok',
);
});

test('Tests that the background sync was skipped when the task found the wallet offline.', () => {
expect(
backgroundOutcome(
background('Sync skipped - Offline mode.', 1_700_000_100),
),
).toBe('skipped');
});

test('Tests that the background sync failed when the task wrote an error.', () => {
expect(
backgroundOutcome(
background(
'Run sync process KO.',
1_700_000_100,
'Run sync process KO. x',
),
),
).toBe('failed');
});

test('Tests that the background sync failed when the message ends in KO without an error.', () => {
expect(
backgroundOutcome(
background('App in Foreground, Background task KO.', 1_700_000_100),
),
).toBe('failed');
});

test('Tests that the background sync was interrupted when the task never wrote its end time.', () => {
expect(backgroundOutcome(background('Starting OK.', 0))).toBe('interrupted');
});
1 change: 0 additions & 1 deletion app/AppState/AppContextLoaded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default interface AppContextLoaded {

// info about background syncing
backgroundSyncInfo: BackgroundType;
setBackgroundSyncErrorInfo: (e: string) => void;

// Error from the App when is in background
backgroundError: BackgroundErrorType;
Expand Down
8 changes: 0 additions & 8 deletions app/LoadedApp/LoadedApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,6 @@ export class LoadedAppClass extends Component<
translate: props.translate,
readOnly: props.readOnly,
backgroundSyncInfo: props.backgroundSyncInfo,
setBackgroundSyncErrorInfo: this.setBackgroundSyncErrorInfo,
backgroundError: { title: '', error: '' },
setBackgroundError: this.setBackgroundError,
lastError: '',
Expand Down Expand Up @@ -1156,12 +1155,6 @@ export class LoadedAppClass extends Component<
}
};

setBackgroundSyncErrorInfo = async (error: string) => {
const newBackgroundSyncInfo = { ...this.state.backgroundSyncInfo, error };
this.setState({ backgroundSyncInfo: newBackgroundSyncInfo });
await BackgroundFileImpl.writeBackground(newBackgroundSyncInfo);
};

setShieldingAmount = (value: number) => {
//const start = Date.now();
this.setState({ shieldingAmount: value });
Expand Down Expand Up @@ -2087,7 +2080,6 @@ export class LoadedAppClass extends Component<
setSendPageState: this.state.setSendPageState,
translate: this.state.translate,
backgroundSyncInfo: this.state.backgroundSyncInfo,
setBackgroundSyncErrorInfo: this.state.setBackgroundSyncErrorInfo,
backgroundError: this.state.backgroundError,
setBackgroundError: this.state.setBackgroundError,
readOnly: this.state.readOnly,
Expand Down
1 change: 0 additions & 1 deletion app/context/contextAppLoaded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const defaultAppContextLoaded: AppContextLoaded = {
date: 0,
dateEnd: 0,
} as BackgroundType,
setBackgroundSyncErrorInfo: () => {},
backgroundError: { title: '', error: '' },
setBackgroundError: () => {},
lastError: '',
Expand Down
12 changes: 0 additions & 12 deletions app/services/BackgroundFileImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ export default class BackgroundFileImpl {
return RNFS.DocumentDirectoryPath + '/background.json';
}

// Write the server setting
static async writeBackground(data: BackgroundType) {
const fileName = await this.getFileName();
const newBackground: BackgroundType = data;

await RNFS.writeFile(
fileName,
JSON.stringify(newBackground),
GlobalConst.utf8,
);
}

// [{"batches": "622", "date": "1673817518.324613" }]

// Read the server background
Expand Down
15 changes: 6 additions & 9 deletions app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,7 @@
},
"seed": {
"buttontexts": {
"new": [
"I have saved \n the seed"
],
"new": ["I have saved \n the seed"],
"change": [
"",
"Open New",
Expand All @@ -443,12 +441,8 @@
"You really want \n to change your \n actual server",
"Are you certain?"
],
"view": [
"I have saved \n the seed"
],
"restore": [
"Restore Wallet"
]
"view": ["I have saved \n the seed"],
"restore": ["Restore Wallet"]
},
"title": "Seed",
"new": "New",
Expand Down Expand Up @@ -1190,6 +1184,9 @@
"legend-low": "Low priority",
"last-background": "Last background sync",
"finished-ok": "Finished OK",
"failed": "Failed",
"interrupted": "Did not finish",
"skipped": "Skipped, offline",
"back-acc": "Back",
"info-acc": "What is a rescan?",
"rescan-acc": "Rescan wallet",
Expand Down
15 changes: 6 additions & 9 deletions app/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,7 @@
},
"seed": {
"buttontexts": {
"new": [
"Ya he guardado \n la semilla"
],
"new": ["Ya he guardado \n la semilla"],
"change": [
"",
"Abrir Nuevo",
Expand All @@ -443,12 +441,8 @@
"Realmente quieres \n cambiar el \n servidor activo",
"Estás seguro/a?"
],
"view": [
"Ya he guardado \n la semilla"
],
"restore": [
"Restaurar Monedero"
]
"view": ["Ya he guardado \n la semilla"],
"restore": ["Restaurar Monedero"]
},
"title": "Semilla",
"new": "Nueva",
Expand Down Expand Up @@ -1190,6 +1184,9 @@
"legend-low": "Prioridad baja",
"last-background": "Última sincronización en segundo plano",
"finished-ok": "Terminó bien",
"failed": "Falló",
"interrupted": "No terminó",
"skipped": "Omitida, sin conexión",
"back-acc": "Atrás",
"info-acc": "¿Qué es un reescaneo?",
"rescan-acc": "Reescanear el monedero",
Expand Down
15 changes: 6 additions & 9 deletions app/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,7 @@
},
"seed": {
"buttontexts": {
"new": [
"Eu salvei \n as Frases de Recuperação"
],
"new": ["Eu salvei \n as Frases de Recuperação"],
"change": [
"",
"Abrir Nova Carteira",
Expand All @@ -443,12 +441,8 @@
"Você realmente quer \n alterar para o seu \n servidor atual",
"Tem certeza?"
],
"view": [
"Eu salvei as \n Frases de Recuperação"
],
"restore": [
"Restaurar Carteira"
]
"view": ["Eu salvei as \n Frases de Recuperação"],
"restore": ["Restaurar Carteira"]
},
"title": "Frases de Recuperação",
"new": "Novo",
Expand Down Expand Up @@ -1190,6 +1184,9 @@
"legend-low": "Prioridade baixa",
"last-background": "Última sincronização em segundo plano",
"finished-ok": "Concluída",
"failed": "Falhou",
"interrupted": "Não terminou",
"skipped": "Ignorada, offline",
"back-acc": "Voltar",
"info-acc": "O que é um reescaneamento?",
"rescan-acc": "Reescanear a carteira",
Expand Down
15 changes: 6 additions & 9 deletions app/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,7 @@
},
"seed": {
"buttontexts": {
"new": [
"Я сохранил \n начальную фразу"
],
"new": ["Я сохранил \n начальную фразу"],
"change": [
"",
"Открыть новый",
Expand All @@ -441,12 +439,8 @@
"Вы действительно хотите \n изменить свой \n текущий сервер?",
"Вы уверены?"
],
"view": [
"Я сохранил \n начальную фразу"
],
"restore": [
"Восстановить кошелёк"
]
"view": ["Я сохранил \n начальную фразу"],
"restore": ["Восстановить кошелёк"]
},
"title": "Начальная фраза",
"new": "Новый",
Expand Down Expand Up @@ -1188,6 +1182,9 @@
"legend-low": "Низкий приоритет",
"last-background": "Последняя фоновая синхронизация",
"finished-ok": "Завершена успешно",
"failed": "Не удалась",
"interrupted": "Не завершилась",
"skipped": "Пропущена, офлайн",
"back-acc": "Назад",
"info-acc": "Что такое повторное сканирование?",
"rescan-acc": "Пересканировать кошелёк",
Expand Down
15 changes: 6 additions & 9 deletions app/translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,7 @@
},
"seed": {
"buttontexts": {
"new": [
"Yedekleme ifadesini\nKaydettim"
],
"new": ["Yedekleme ifadesini\nKaydettim"],
"change": [
"",
"Yeni aç",
Expand All @@ -441,12 +439,8 @@
"Gerçek cüzdanınızı\nDeğiştirmek istiyor musunuz?",
"Emin misiniz?"
],
"view": [
"Yedekleme ifadesini\nKaydettim"
],
"restore": [
"Cüzdanı geri yükle"
]
"view": ["Yedekleme ifadesini\nKaydettim"],
"restore": ["Cüzdanı geri yükle"]
},
"title": "kurtarma ifadesi",
"new": "Yeni",
Expand Down Expand Up @@ -1188,6 +1182,9 @@
"legend-low": "Düşük öncelik",
"last-background": "Son arka plan senkronizasyonu",
"finished-ok": "Başarıyla bitti",
"failed": "Başarısız",
"interrupted": "Bitmedi",
"skipped": "Atlandı, çevrimdışı",
"back-acc": "Geri",
"info-acc": "Yeniden tarama nedir?",
"rescan-acc": "Cüzdanı yeniden tara",
Expand Down
Loading
Loading