@lazy-sol/access-control 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,53 @@
1
+ // AccessControl (RBAC) restrictedTo modifier tests
2
+
3
+ // Zeppelin test helpers
4
+ const {
5
+ BN,
6
+ constants,
7
+ expectEvent,
8
+ expectRevert,
9
+ } = require("@openzeppelin/test-helpers");
10
+ const {
11
+ assert,
12
+ expect,
13
+ } = require("chai");
14
+ const {
15
+ ZERO_ADDRESS,
16
+ ZERO_BYTES32,
17
+ MAX_UINT256,
18
+ } = constants;
19
+
20
+ // deployment routines in use
21
+ const {
22
+ deploy_access_control,
23
+ } = require("./include/deployment_routines");
24
+
25
+ // run AccessControl (RBAC) tests
26
+ contract('AccessControl (RBAC) "restrictedTo" Modifier tests', function(accounts) {
27
+ // extract accounts to be used:
28
+ // A0 – special default zero account accounts[0] used by Truffle, reserved
29
+ // a0 – deployment account having all the permissions, reserved
30
+ // H0 – initial token holder account
31
+ // a1, a2,... – working accounts to perform tests on
32
+ const [A0, a0, H0, a1, a2, a3] = accounts;
33
+
34
+ // `restrictedTo` modifier check
35
+ describe("restrictedTo modifier check", function() {
36
+ let access_control;
37
+ beforeEach(async function() {
38
+ access_control = await deploy_access_control(a0);
39
+ });
40
+ it("function protected with restrictedTo modifier fails when run not by an admin", async function() {
41
+ await expectRevert(access_control.restricted({from: a1}), "access denied");
42
+ });
43
+ describe("function protected with restrictedTo modifier succeeds when run by admin", async function() {
44
+ let receipt;
45
+ beforeEach(async function() {
46
+ receipt = await access_control.restricted({from: a0});
47
+ });
48
+ it('"Restricted" event is emitted', async function() {
49
+ expectEvent(receipt, "Restricted");
50
+ });
51
+ });
52
+ });
53
+ });