-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix error when eth address is invalid (#837)
- Loading branch information
Showing
6 changed files
with
53 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,19 @@ | ||
import request from 'supertest'; | ||
|
||
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000'; | ||
|
||
describe('/', () => { | ||
describe('when method params is missing', () => { | ||
it('returns a 500 error', async () => { | ||
it('returns a 400 error', async () => { | ||
const response = await request(process.env.HOST).post('/').send({}); | ||
|
||
expect(response.status).toEqual(500); | ||
expect(response.status).toEqual(400); | ||
}); | ||
}); | ||
|
||
describe('when method params is invalid', () => { | ||
it('returns a 500 error', async () => { | ||
it('returns a 400 error', async () => { | ||
const response = await request(process.env.HOST).post('/').send({ method: 'test' }); | ||
|
||
expect(response.status).toEqual(500); | ||
}); | ||
}); | ||
|
||
describe('when the address params is blank', () => { | ||
it('returns a 500 error', async () => { | ||
const response = await request(process.env.HOST) | ||
.post('/') | ||
.send({ method: 'get_vp', address: EMPTY_ADDRESS }); | ||
|
||
expect(response.status).toEqual(500); | ||
}); | ||
}); | ||
|
||
describe('when the author params is blank', () => { | ||
it('returns a 500 error', async () => { | ||
const response = await request(process.env.HOST) | ||
.post('/') | ||
.send({ method: 'get_vp', author: EMPTY_ADDRESS }); | ||
|
||
expect(response.status).toEqual(500); | ||
expect(response.status).toEqual(400); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
import request from 'supertest'; | ||
|
||
describe('validate', () => { | ||
describe('when the author is invalid', () => { | ||
it.each([ | ||
['empty address', '0x0000000000000000000000000000000000000000'], | ||
['empty string', ''], | ||
['null', null], | ||
['invalid address', 'test'] | ||
])('returns a 400 error on %s', async (title, author) => { | ||
const response = await request(process.env.HOST) | ||
.post('/') | ||
.send({ method: 'validate', author }); | ||
|
||
expect(response.status).toEqual(400); | ||
}); | ||
}); | ||
|
||
it.todo('validates the voting power'); | ||
}); |