forked from linjie-1/guigulive-operation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment #4
41 lines (31 loc) · 1.38 KB
/
Assignment #4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var Payroll = artifacts.require("./Payroll.sol");
contract('Payroll', function(accounts) {
it("...should add/remove employee.", function() {
return Payroll.deployed().then(function(instance) {
payrollInstance = instance;
return payrollInstance.addEmployee(accounts[1], 1,{from: accounts[0]});
}).then(function() {
return payrollInstance.removeEmployee(accounts[1]);
}).then(function() {
assert(true, "pass");
})
});
it("...should add valid address.", function() {
return Payroll.deployed().then(function(instance) {
payrollInstance = instance;
return payrollInstance.addEmployee("0x0", 1,{from: accounts[0]});
}).catch(function(error) {
assert(error.toString().includes('invalid opcode'), "expect exception here");
});
});
it("...should add employee only once.", function() {
return Payroll.deployed().then(function(instance) {
payrollInstance = instance;
return payrollInstance.addEmployee(accounts[1], 1,{from: accounts[0]});
}).then(function() {
return payrollInstance.addEmployee(accounts[1], 1,{from: accounts[0]});
}).catch(function(error) {
assert(error.toString().includes('invalid opcode'), "expect exception here");
});
});
});