Skip to content
Open
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
12 changes: 4 additions & 8 deletions backend/tests/deprecated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,21 @@ import app from '../src/app.js';
// so the real route handlers respond directly without interference.

describe('Deprecated route responses', () => {
it('POST /streams returns 410 Gone', async () => {
it('POST /streams returns 404 Not Found', async () => {
const response = await request(app)
.post('/streams')
.send({})
.set('Accept', 'application/json');

expect(response.status).toBe(410);
expect(response.body.deprecated).toBe(true);
expect(response.body.migration).toMatchObject({ old: '/streams', new: '/v1/streams' });
expect(response.status).toBe(404);
});

it('POST /events returns 410 Gone', async () => {
it('POST /events returns 404 Not Found', async () => {
const response = await request(app)
.post('/events')
.send({})
.set('Accept', 'application/json');

expect(response.status).toBe(410);
expect(response.body.deprecated).toBe(true);
expect(response.body.migration).toMatchObject({ old: '/events', new: '/v1/events' });
expect(response.status).toBe(404);
});
});
2 changes: 2 additions & 0 deletions contracts/stream_contract/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ pub enum StreamError {
InvalidTokenAddress = 10,
/// `amount / duration` rounds to zero — the stream would lock tokens but never accrue.
InvalidRate = 11,
/// Operation requires an active stream, but the stream is currently paused.
StreamPaused = 12,
}
2 changes: 1 addition & 1 deletion contracts/stream_contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ impl StreamContract {
// Validate stream is active and not paused
Self::validate_stream_active(&stream)?;
if stream.paused {
return Err(StreamError::StreamInactive);
return Err(StreamError::StreamPaused);
}

let now = env.ledger().timestamp();
Expand Down
4 changes: 2 additions & 2 deletions contracts/stream_contract/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ fn test_withdraw_on_paused_stream_fails() {

assert_eq!(
client.try_withdraw(&recipient, &id),
Err(Ok(StreamError::StreamInactive))
Err(Ok(StreamError::StreamPaused))
);
}

Expand Down Expand Up @@ -2206,7 +2206,7 @@ fn test_withdraw_on_paused_stream_returns_stream_inactive() {

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

#[test]
Expand Down
Loading