Skip to content

Commit 1229a89

Browse files
authored
Merge pull request #959 from Henrichy/main
withdraw on a paused stream returns StreamInactive instead of a distinct paused error completed
2 parents e44acf8 + e5ca56d commit 1229a89

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

contracts/stream_contract/src/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ pub enum StreamError {
2929
InvalidTokenAddress = 10,
3030
/// `amount / duration` rounds to zero — the stream would lock tokens but never accrue.
3131
InvalidRate = 11,
32+
/// Operation requires an active stream, but the stream is currently paused.
33+
StreamPaused = 12,
3234
}

contracts/stream_contract/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl StreamContract {
431431
// Validate stream is active and not paused
432432
Self::validate_stream_active(&stream)?;
433433
if stream.paused {
434-
return Err(StreamError::StreamInactive);
434+
return Err(StreamError::StreamPaused);
435435
}
436436

437437
let now = env.ledger().timestamp();

contracts/stream_contract/src/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ fn test_withdraw_on_paused_stream_fails() {
15681568

15691569
assert_eq!(
15701570
client.try_withdraw(&recipient, &id),
1571-
Err(Ok(StreamError::StreamInactive))
1571+
Err(Ok(StreamError::StreamPaused))
15721572
);
15731573
}
15741574

@@ -2206,7 +2206,7 @@ fn test_withdraw_on_paused_stream_returns_stream_inactive() {
22062206

22072207
// Withdraw must be rejected while paused.
22082208
let result = client.try_withdraw(&recipient, &id);
2209-
assert_eq!(result, Err(Ok(StreamError::StreamInactive)));
2209+
assert_eq!(result, Err(Ok(StreamError::StreamPaused)));
22102210
}
22112211

22122212
#[test]

0 commit comments

Comments
 (0)