[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 06/06: implement time travelling
From: |
gnunet |
Subject: |
[taler-wallet-core] 06/06: implement time travelling |
Date: |
Mon, 23 Mar 2020 13:17:46 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
commit c4d289956275677b24459237d13ed8c23a606079
Author: Florian Dold <address@hidden>
AuthorDate: Mon Mar 23 17:47:35 2020 +0530
implement time travelling
---
src/headless/taler-wallet-cli.ts | 9 +++++++++
src/util/time.ts | 8 +++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts
index c4d8664d..9a21d2a1 100644
--- a/src/headless/taler-wallet-cli.ts
+++ b/src/headless/taler-wallet-cli.ts
@@ -31,6 +31,7 @@ import { Bank } from "./bank";
import { classifyTalerUri, TalerUriType } from "../util/taleruri";
import util = require("util");
import { Configuration } from "../util/talerconfig";
+import { setDangerousTimetravel } from "../util/time";
// Backwards compatibility with nodejs<0.11, where TextEncoder and TextDecoder
// are not globals yet.
@@ -119,6 +120,14 @@ const walletCli = clk
.maybeOption("walletDbFile", ["--wallet-db"], clk.STRING, {
help: "location of the wallet database file"
})
+ .maybeOption("timetravel", ["--timetravel"], clk.INT, {
+ help: "modify system time by given offset in microseconds",
+ onPresentHandler: (x) => {
+ // Convert microseconds to milliseconds and do timetravel
+ logger.info(`timetravelling ${x} microseconds`);
+ setDangerousTimetravel(x / 1000);
+ },
+ })
.maybeOption("inhibit", ["--inhibit"], clk.STRING, {
help:
"Inhibit running certain operations, useful for debugging and testing.",
diff --git a/src/util/time.ts b/src/util/time.ts
index 88297f9a..2740c361 100644
--- a/src/util/time.ts
+++ b/src/util/time.ts
@@ -34,9 +34,15 @@ export interface Duration {
readonly d_ms: number | "forever";
}
+let timeshift: number = 0;
+
+export function setDangerousTimetravel(dt: number) {
+ timeshift = dt;
+}
+
export function getTimestampNow(): Timestamp {
return {
- t_ms: new Date().getTime(),
+ t_ms: new Date().getTime() + timeshift,
};
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [taler-wallet-core] branch master updated (cb2fbc76 -> c4d28995), gnunet, 2020/03/23
- [taler-wallet-core] 02/06: update git URL, gnunet, 2020/03/23
- [taler-wallet-core] 05/06: make sure the 'testing withdraw' subcommand does retries, gnunet, 2020/03/23
- [taler-wallet-core] 01/06: specify node version, gnunet, 2020/03/23
- [taler-wallet-core] 04/06: upgrade ts and prettier, gnunet, 2020/03/23
- [taler-wallet-core] 06/06: implement time travelling,
gnunet <=
- [taler-wallet-core] 03/06: config files WIP, gnunet, 2020/03/23