|
1 | 1 | import type { _SERVICE as ConsoleActor } from '$declarations/console/console.did'; |
2 | 2 | import { idlFactory as idlFactorConsole } from '$declarations/console/console.factory.did'; |
| 3 | +import { AnonymousIdentity } from '@dfinity/agent'; |
3 | 4 | import { Ed25519KeyIdentity } from '@dfinity/identity'; |
4 | 5 | import { PocketIc, type Actor } from '@hadronous/pic'; |
5 | 6 | import { afterEach, beforeEach, describe, expect, inject } from 'vitest'; |
| 7 | +import { CONTROLLER_ERROR_MSG } from './constants/console-tests.constants'; |
6 | 8 | import { deploySegments, initMissionControls } from './utils/console-tests.utils'; |
7 | 9 | import { CONSOLE_WASM_PATH } from './utils/setup-tests.utils'; |
8 | 10 |
|
@@ -31,9 +33,49 @@ describe('Console', () => { |
31 | 33 | await pic?.tearDown(); |
32 | 34 | }); |
33 | 35 |
|
34 | | - it('should throw errors if too many users are created quickly', async () => { |
35 | | - await expect( |
36 | | - async () => await initMissionControls({ actor, pic, length: 2 }) |
37 | | - ).rejects.toThrowError(new RegExp('Rate limit reached, try again later', 'i')); |
| 36 | + describe('owner', () => { |
| 37 | + it('should throw errors if too many users are created quickly', async () => { |
| 38 | + await expect( |
| 39 | + async () => await initMissionControls({ actor, pic, length: 2 }) |
| 40 | + ).rejects.toThrowError(new RegExp('Rate limit reached, try again later', 'i')); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + describe('anonymous', () => { |
| 45 | + beforeEach(() => { |
| 46 | + actor.setIdentity(new AnonymousIdentity()); |
| 47 | + }); |
| 48 | + |
| 49 | + it('should throw errors on list payments', async () => { |
| 50 | + const { list_payments } = actor; |
| 51 | + |
| 52 | + await expect(list_payments()).rejects.toThrow(CONTROLLER_ERROR_MSG); |
| 53 | + }); |
| 54 | + |
| 55 | + it('should throw errors on withdraw payments', async () => { |
| 56 | + const { withdraw_payments } = actor; |
| 57 | + |
| 58 | + await expect(withdraw_payments()).rejects.toThrow(CONTROLLER_ERROR_MSG); |
| 59 | + }); |
| 60 | + }); |
| 61 | + |
| 62 | + describe('random', () => { |
| 63 | + const randomCaller = Ed25519KeyIdentity.generate(); |
| 64 | + |
| 65 | + beforeEach(() => { |
| 66 | + actor.setIdentity(randomCaller); |
| 67 | + }); |
| 68 | + |
| 69 | + it('should throw errors on list payments', async () => { |
| 70 | + const { list_payments } = actor; |
| 71 | + |
| 72 | + await expect(list_payments()).rejects.toThrow(CONTROLLER_ERROR_MSG); |
| 73 | + }); |
| 74 | + |
| 75 | + it('should throw errors on withdraw payments', async () => { |
| 76 | + const { withdraw_payments } = actor; |
| 77 | + |
| 78 | + await expect(withdraw_payments()).rejects.toThrow(CONTROLLER_ERROR_MSG); |
| 79 | + }); |
38 | 80 | }); |
39 | 81 | }); |
0 commit comments