Skip to content

Commit 9a3b42d

Browse files
committed
Use timestamp value for seen in tests.
1 parent 55a821e commit 9a3b42d

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/persistence.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ impl<L: Deref> GossipPersister<L> where L::Target: Logger {
146146
let mut update_signed = Vec::new();
147147
update.write(&mut update_signed).unwrap();
148148

149-
tokio::time::timeout(POSTGRES_INSERT_TIMEOUT, client
150-
.execute("INSERT INTO channel_updates (\
149+
let insertion_statement = if cfg!(test) {
150+
"INSERT INTO channel_updates (\
151151
short_channel_id, \
152152
timestamp, \
153+
seen, \
153154
channel_flags, \
154155
direction, \
155156
disable, \
@@ -159,9 +160,33 @@ impl<L: Deref> GossipPersister<L> where L::Target: Logger {
159160
fee_proportional_millionths, \
160161
htlc_maximum_msat, \
161162
blob_signed \
162-
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) ON CONFLICT DO NOTHING", &[
163+
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) ON CONFLICT DO NOTHING"
164+
} else {
165+
"INSERT INTO channel_updates (\
166+
short_channel_id, \
167+
timestamp, \
168+
channel_flags, \
169+
direction, \
170+
disable, \
171+
cltv_expiry_delta, \
172+
htlc_minimum_msat, \
173+
fee_base_msat, \
174+
fee_proportional_millionths, \
175+
htlc_maximum_msat, \
176+
blob_signed \
177+
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) ON CONFLICT DO NOTHING"
178+
};
179+
180+
// this may not be used outside test cfg
181+
#[cfg(test)]
182+
let system_time: std::time::SystemTime = std::time::UNIX_EPOCH + Duration::from_secs(timestamp as u64);
183+
184+
tokio::time::timeout(POSTGRES_INSERT_TIMEOUT, client
185+
.execute(insertion_statement, &[
163186
&scid,
164187
&timestamp,
188+
#[cfg(test)]
189+
&system_time,
165190
&(update.contents.flags as i16),
166191
&direction,
167192
&disable,

0 commit comments

Comments
 (0)