@lazy-sol/access-control 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.editorconfig +21 -0
- package/.solcover.js +39 -0
- package/CONTRIBUTING.md +200 -0
- package/CRIBBED_CODE.txt +26 -0
- package/LICENSE.txt +22 -0
- package/README.md +162 -0
- package/artifacts/contracts/OwnableToAccessControlAdapter.sol/OwnableToAccessControlAdapter.json +342 -0
- package/contracts/AccessControl.sol +305 -0
- package/contracts/AdapterFactory.sol +56 -0
- package/contracts/OwnableToAccessControlAdapter.sol +231 -0
- package/contracts/mocks/AccessControlMock.sol +14 -0
- package/contracts/mocks/TetherToken.sol +443 -0
- package/deploy/deploy-AdapterFactory.js +59 -0
- package/deployments/goerli/.chainId +1 -0
- package/deployments/goerli/AdapterFactory.json +104 -0
- package/deployments/goerli/solcInputs/9f8f20c7b4fd0796d45c56d37e790191.json +42 -0
- package/docs/commit_policy.md +201 -0
- package/docs/pull_request_template.md +40 -0
- package/docs/style_guides.md +240 -0
- package/hardhat.config.js +359 -0
- package/package.json +39 -0
- package/test/adapter_factory.js +54 -0
- package/test/include/deployment_routines.js +150 -0
- package/test/include/features_roles.js +42 -0
- package/test/include/rbac.behaviour.js +315 -0
- package/test/ownable_to_rbac_adapter.js +100 -0
- package/test/ownable_to_rbac_adapter_rbac.js +57 -0
- package/test/rbac_core.js +24 -0
- package/test/rbac_modifier.js +53 -0
@@ -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
|
+
});
|